mutation.go 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360
  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. start_index *uint64
  40782. addstart_index *int64
  40783. end_index *uint64
  40784. addend_index *int64
  40785. organization_id *uint64
  40786. addorganization_id *int64
  40787. clearedFields map[string]struct{}
  40788. done bool
  40789. oldValue func(context.Context) (*UsageTotal, error)
  40790. predicates []predicate.UsageTotal
  40791. }
  40792. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40793. // usagetotalOption allows management of the mutation configuration using functional options.
  40794. type usagetotalOption func(*UsageTotalMutation)
  40795. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40796. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40797. m := &UsageTotalMutation{
  40798. config: c,
  40799. op: op,
  40800. typ: TypeUsageTotal,
  40801. clearedFields: make(map[string]struct{}),
  40802. }
  40803. for _, opt := range opts {
  40804. opt(m)
  40805. }
  40806. return m
  40807. }
  40808. // withUsageTotalID sets the ID field of the mutation.
  40809. func withUsageTotalID(id uint64) usagetotalOption {
  40810. return func(m *UsageTotalMutation) {
  40811. var (
  40812. err error
  40813. once sync.Once
  40814. value *UsageTotal
  40815. )
  40816. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40817. once.Do(func() {
  40818. if m.done {
  40819. err = errors.New("querying old values post mutation is not allowed")
  40820. } else {
  40821. value, err = m.Client().UsageTotal.Get(ctx, id)
  40822. }
  40823. })
  40824. return value, err
  40825. }
  40826. m.id = &id
  40827. }
  40828. }
  40829. // withUsageTotal sets the old UsageTotal of the mutation.
  40830. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40831. return func(m *UsageTotalMutation) {
  40832. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40833. return node, nil
  40834. }
  40835. m.id = &node.ID
  40836. }
  40837. }
  40838. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40839. // executed in a transaction (ent.Tx), a transactional client is returned.
  40840. func (m UsageTotalMutation) Client() *Client {
  40841. client := &Client{config: m.config}
  40842. client.init()
  40843. return client
  40844. }
  40845. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40846. // it returns an error otherwise.
  40847. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40848. if _, ok := m.driver.(*txDriver); !ok {
  40849. return nil, errors.New("ent: mutation is not running in a transaction")
  40850. }
  40851. tx := &Tx{config: m.config}
  40852. tx.init()
  40853. return tx, nil
  40854. }
  40855. // SetID sets the value of the id field. Note that this
  40856. // operation is only accepted on creation of UsageTotal entities.
  40857. func (m *UsageTotalMutation) SetID(id uint64) {
  40858. m.id = &id
  40859. }
  40860. // ID returns the ID value in the mutation. Note that the ID is only available
  40861. // if it was provided to the builder or after it was returned from the database.
  40862. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40863. if m.id == nil {
  40864. return
  40865. }
  40866. return *m.id, true
  40867. }
  40868. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40869. // That means, if the mutation is applied within a transaction with an isolation level such
  40870. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40871. // or updated by the mutation.
  40872. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  40873. switch {
  40874. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40875. id, exists := m.ID()
  40876. if exists {
  40877. return []uint64{id}, nil
  40878. }
  40879. fallthrough
  40880. case m.op.Is(OpUpdate | OpDelete):
  40881. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  40882. default:
  40883. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40884. }
  40885. }
  40886. // SetCreatedAt sets the "created_at" field.
  40887. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  40888. m.created_at = &t
  40889. }
  40890. // CreatedAt returns the value of the "created_at" field in the mutation.
  40891. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  40892. v := m.created_at
  40893. if v == nil {
  40894. return
  40895. }
  40896. return *v, true
  40897. }
  40898. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  40899. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40901. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40902. if !m.op.Is(OpUpdateOne) {
  40903. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40904. }
  40905. if m.id == nil || m.oldValue == nil {
  40906. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40907. }
  40908. oldValue, err := m.oldValue(ctx)
  40909. if err != nil {
  40910. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40911. }
  40912. return oldValue.CreatedAt, nil
  40913. }
  40914. // ResetCreatedAt resets all changes to the "created_at" field.
  40915. func (m *UsageTotalMutation) ResetCreatedAt() {
  40916. m.created_at = nil
  40917. }
  40918. // SetUpdatedAt sets the "updated_at" field.
  40919. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  40920. m.updated_at = &t
  40921. }
  40922. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40923. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  40924. v := m.updated_at
  40925. if v == nil {
  40926. return
  40927. }
  40928. return *v, true
  40929. }
  40930. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  40931. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40933. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40934. if !m.op.Is(OpUpdateOne) {
  40935. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40936. }
  40937. if m.id == nil || m.oldValue == nil {
  40938. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40939. }
  40940. oldValue, err := m.oldValue(ctx)
  40941. if err != nil {
  40942. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40943. }
  40944. return oldValue.UpdatedAt, nil
  40945. }
  40946. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40947. func (m *UsageTotalMutation) ResetUpdatedAt() {
  40948. m.updated_at = nil
  40949. }
  40950. // SetStatus sets the "status" field.
  40951. func (m *UsageTotalMutation) SetStatus(u uint8) {
  40952. m.status = &u
  40953. m.addstatus = nil
  40954. }
  40955. // Status returns the value of the "status" field in the mutation.
  40956. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  40957. v := m.status
  40958. if v == nil {
  40959. return
  40960. }
  40961. return *v, true
  40962. }
  40963. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  40964. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40966. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40967. if !m.op.Is(OpUpdateOne) {
  40968. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40969. }
  40970. if m.id == nil || m.oldValue == nil {
  40971. return v, errors.New("OldStatus requires an ID field in the mutation")
  40972. }
  40973. oldValue, err := m.oldValue(ctx)
  40974. if err != nil {
  40975. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40976. }
  40977. return oldValue.Status, nil
  40978. }
  40979. // AddStatus adds u to the "status" field.
  40980. func (m *UsageTotalMutation) AddStatus(u int8) {
  40981. if m.addstatus != nil {
  40982. *m.addstatus += u
  40983. } else {
  40984. m.addstatus = &u
  40985. }
  40986. }
  40987. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40988. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  40989. v := m.addstatus
  40990. if v == nil {
  40991. return
  40992. }
  40993. return *v, true
  40994. }
  40995. // ClearStatus clears the value of the "status" field.
  40996. func (m *UsageTotalMutation) ClearStatus() {
  40997. m.status = nil
  40998. m.addstatus = nil
  40999. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  41000. }
  41001. // StatusCleared returns if the "status" field was cleared in this mutation.
  41002. func (m *UsageTotalMutation) StatusCleared() bool {
  41003. _, ok := m.clearedFields[usagetotal.FieldStatus]
  41004. return ok
  41005. }
  41006. // ResetStatus resets all changes to the "status" field.
  41007. func (m *UsageTotalMutation) ResetStatus() {
  41008. m.status = nil
  41009. m.addstatus = nil
  41010. delete(m.clearedFields, usagetotal.FieldStatus)
  41011. }
  41012. // SetType sets the "type" field.
  41013. func (m *UsageTotalMutation) SetType(i int) {
  41014. m._type = &i
  41015. m.add_type = nil
  41016. }
  41017. // GetType returns the value of the "type" field in the mutation.
  41018. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  41019. v := m._type
  41020. if v == nil {
  41021. return
  41022. }
  41023. return *v, true
  41024. }
  41025. // OldType returns the old "type" field's value of the UsageTotal entity.
  41026. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41028. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  41029. if !m.op.Is(OpUpdateOne) {
  41030. return v, errors.New("OldType is only allowed on UpdateOne operations")
  41031. }
  41032. if m.id == nil || m.oldValue == nil {
  41033. return v, errors.New("OldType requires an ID field in the mutation")
  41034. }
  41035. oldValue, err := m.oldValue(ctx)
  41036. if err != nil {
  41037. return v, fmt.Errorf("querying old value for OldType: %w", err)
  41038. }
  41039. return oldValue.Type, nil
  41040. }
  41041. // AddType adds i to the "type" field.
  41042. func (m *UsageTotalMutation) AddType(i int) {
  41043. if m.add_type != nil {
  41044. *m.add_type += i
  41045. } else {
  41046. m.add_type = &i
  41047. }
  41048. }
  41049. // AddedType returns the value that was added to the "type" field in this mutation.
  41050. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  41051. v := m.add_type
  41052. if v == nil {
  41053. return
  41054. }
  41055. return *v, true
  41056. }
  41057. // ClearType clears the value of the "type" field.
  41058. func (m *UsageTotalMutation) ClearType() {
  41059. m._type = nil
  41060. m.add_type = nil
  41061. m.clearedFields[usagetotal.FieldType] = struct{}{}
  41062. }
  41063. // TypeCleared returns if the "type" field was cleared in this mutation.
  41064. func (m *UsageTotalMutation) TypeCleared() bool {
  41065. _, ok := m.clearedFields[usagetotal.FieldType]
  41066. return ok
  41067. }
  41068. // ResetType resets all changes to the "type" field.
  41069. func (m *UsageTotalMutation) ResetType() {
  41070. m._type = nil
  41071. m.add_type = nil
  41072. delete(m.clearedFields, usagetotal.FieldType)
  41073. }
  41074. // SetBotID sets the "bot_id" field.
  41075. func (m *UsageTotalMutation) SetBotID(s string) {
  41076. m.bot_id = &s
  41077. }
  41078. // BotID returns the value of the "bot_id" field in the mutation.
  41079. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  41080. v := m.bot_id
  41081. if v == nil {
  41082. return
  41083. }
  41084. return *v, true
  41085. }
  41086. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  41087. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41089. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  41090. if !m.op.Is(OpUpdateOne) {
  41091. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41092. }
  41093. if m.id == nil || m.oldValue == nil {
  41094. return v, errors.New("OldBotID requires an ID field in the mutation")
  41095. }
  41096. oldValue, err := m.oldValue(ctx)
  41097. if err != nil {
  41098. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41099. }
  41100. return oldValue.BotID, nil
  41101. }
  41102. // ResetBotID resets all changes to the "bot_id" field.
  41103. func (m *UsageTotalMutation) ResetBotID() {
  41104. m.bot_id = nil
  41105. }
  41106. // SetTotalTokens sets the "total_tokens" field.
  41107. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  41108. m.total_tokens = &u
  41109. m.addtotal_tokens = nil
  41110. }
  41111. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  41112. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  41113. v := m.total_tokens
  41114. if v == nil {
  41115. return
  41116. }
  41117. return *v, true
  41118. }
  41119. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  41120. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41122. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  41123. if !m.op.Is(OpUpdateOne) {
  41124. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  41125. }
  41126. if m.id == nil || m.oldValue == nil {
  41127. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  41128. }
  41129. oldValue, err := m.oldValue(ctx)
  41130. if err != nil {
  41131. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41132. }
  41133. return oldValue.TotalTokens, nil
  41134. }
  41135. // AddTotalTokens adds u to the "total_tokens" field.
  41136. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41137. if m.addtotal_tokens != nil {
  41138. *m.addtotal_tokens += u
  41139. } else {
  41140. m.addtotal_tokens = &u
  41141. }
  41142. }
  41143. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41144. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41145. v := m.addtotal_tokens
  41146. if v == nil {
  41147. return
  41148. }
  41149. return *v, true
  41150. }
  41151. // ClearTotalTokens clears the value of the "total_tokens" field.
  41152. func (m *UsageTotalMutation) ClearTotalTokens() {
  41153. m.total_tokens = nil
  41154. m.addtotal_tokens = nil
  41155. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41156. }
  41157. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41158. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41159. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41160. return ok
  41161. }
  41162. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41163. func (m *UsageTotalMutation) ResetTotalTokens() {
  41164. m.total_tokens = nil
  41165. m.addtotal_tokens = nil
  41166. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41167. }
  41168. // SetStartIndex sets the "start_index" field.
  41169. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41170. m.start_index = &u
  41171. m.addstart_index = nil
  41172. }
  41173. // StartIndex returns the value of the "start_index" field in the mutation.
  41174. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41175. v := m.start_index
  41176. if v == nil {
  41177. return
  41178. }
  41179. return *v, true
  41180. }
  41181. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41182. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41184. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41185. if !m.op.Is(OpUpdateOne) {
  41186. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41187. }
  41188. if m.id == nil || m.oldValue == nil {
  41189. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41190. }
  41191. oldValue, err := m.oldValue(ctx)
  41192. if err != nil {
  41193. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41194. }
  41195. return oldValue.StartIndex, nil
  41196. }
  41197. // AddStartIndex adds u to the "start_index" field.
  41198. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41199. if m.addstart_index != nil {
  41200. *m.addstart_index += u
  41201. } else {
  41202. m.addstart_index = &u
  41203. }
  41204. }
  41205. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41206. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41207. v := m.addstart_index
  41208. if v == nil {
  41209. return
  41210. }
  41211. return *v, true
  41212. }
  41213. // ClearStartIndex clears the value of the "start_index" field.
  41214. func (m *UsageTotalMutation) ClearStartIndex() {
  41215. m.start_index = nil
  41216. m.addstart_index = nil
  41217. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41218. }
  41219. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41220. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41221. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41222. return ok
  41223. }
  41224. // ResetStartIndex resets all changes to the "start_index" field.
  41225. func (m *UsageTotalMutation) ResetStartIndex() {
  41226. m.start_index = nil
  41227. m.addstart_index = nil
  41228. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41229. }
  41230. // SetEndIndex sets the "end_index" field.
  41231. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41232. m.end_index = &u
  41233. m.addend_index = nil
  41234. }
  41235. // EndIndex returns the value of the "end_index" field in the mutation.
  41236. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41237. v := m.end_index
  41238. if v == nil {
  41239. return
  41240. }
  41241. return *v, true
  41242. }
  41243. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41244. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41246. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41247. if !m.op.Is(OpUpdateOne) {
  41248. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41249. }
  41250. if m.id == nil || m.oldValue == nil {
  41251. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41252. }
  41253. oldValue, err := m.oldValue(ctx)
  41254. if err != nil {
  41255. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41256. }
  41257. return oldValue.EndIndex, nil
  41258. }
  41259. // AddEndIndex adds u to the "end_index" field.
  41260. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41261. if m.addend_index != nil {
  41262. *m.addend_index += u
  41263. } else {
  41264. m.addend_index = &u
  41265. }
  41266. }
  41267. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41268. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41269. v := m.addend_index
  41270. if v == nil {
  41271. return
  41272. }
  41273. return *v, true
  41274. }
  41275. // ClearEndIndex clears the value of the "end_index" field.
  41276. func (m *UsageTotalMutation) ClearEndIndex() {
  41277. m.end_index = nil
  41278. m.addend_index = nil
  41279. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41280. }
  41281. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41282. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41283. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41284. return ok
  41285. }
  41286. // ResetEndIndex resets all changes to the "end_index" field.
  41287. func (m *UsageTotalMutation) ResetEndIndex() {
  41288. m.end_index = nil
  41289. m.addend_index = nil
  41290. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41291. }
  41292. // SetOrganizationID sets the "organization_id" field.
  41293. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41294. m.organization_id = &u
  41295. m.addorganization_id = nil
  41296. }
  41297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41298. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41299. v := m.organization_id
  41300. if v == nil {
  41301. return
  41302. }
  41303. return *v, true
  41304. }
  41305. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41306. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41308. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41309. if !m.op.Is(OpUpdateOne) {
  41310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41311. }
  41312. if m.id == nil || m.oldValue == nil {
  41313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41314. }
  41315. oldValue, err := m.oldValue(ctx)
  41316. if err != nil {
  41317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41318. }
  41319. return oldValue.OrganizationID, nil
  41320. }
  41321. // AddOrganizationID adds u to the "organization_id" field.
  41322. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41323. if m.addorganization_id != nil {
  41324. *m.addorganization_id += u
  41325. } else {
  41326. m.addorganization_id = &u
  41327. }
  41328. }
  41329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41330. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41331. v := m.addorganization_id
  41332. if v == nil {
  41333. return
  41334. }
  41335. return *v, true
  41336. }
  41337. // ClearOrganizationID clears the value of the "organization_id" field.
  41338. func (m *UsageTotalMutation) ClearOrganizationID() {
  41339. m.organization_id = nil
  41340. m.addorganization_id = nil
  41341. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41342. }
  41343. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41344. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41345. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41346. return ok
  41347. }
  41348. // ResetOrganizationID resets all changes to the "organization_id" field.
  41349. func (m *UsageTotalMutation) ResetOrganizationID() {
  41350. m.organization_id = nil
  41351. m.addorganization_id = nil
  41352. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41353. }
  41354. // Where appends a list predicates to the UsageTotalMutation builder.
  41355. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41356. m.predicates = append(m.predicates, ps...)
  41357. }
  41358. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41359. // users can use type-assertion to append predicates that do not depend on any generated package.
  41360. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41361. p := make([]predicate.UsageTotal, len(ps))
  41362. for i := range ps {
  41363. p[i] = ps[i]
  41364. }
  41365. m.Where(p...)
  41366. }
  41367. // Op returns the operation name.
  41368. func (m *UsageTotalMutation) Op() Op {
  41369. return m.op
  41370. }
  41371. // SetOp allows setting the mutation operation.
  41372. func (m *UsageTotalMutation) SetOp(op Op) {
  41373. m.op = op
  41374. }
  41375. // Type returns the node type of this mutation (UsageTotal).
  41376. func (m *UsageTotalMutation) Type() string {
  41377. return m.typ
  41378. }
  41379. // Fields returns all fields that were changed during this mutation. Note that in
  41380. // order to get all numeric fields that were incremented/decremented, call
  41381. // AddedFields().
  41382. func (m *UsageTotalMutation) Fields() []string {
  41383. fields := make([]string, 0, 9)
  41384. if m.created_at != nil {
  41385. fields = append(fields, usagetotal.FieldCreatedAt)
  41386. }
  41387. if m.updated_at != nil {
  41388. fields = append(fields, usagetotal.FieldUpdatedAt)
  41389. }
  41390. if m.status != nil {
  41391. fields = append(fields, usagetotal.FieldStatus)
  41392. }
  41393. if m._type != nil {
  41394. fields = append(fields, usagetotal.FieldType)
  41395. }
  41396. if m.bot_id != nil {
  41397. fields = append(fields, usagetotal.FieldBotID)
  41398. }
  41399. if m.total_tokens != nil {
  41400. fields = append(fields, usagetotal.FieldTotalTokens)
  41401. }
  41402. if m.start_index != nil {
  41403. fields = append(fields, usagetotal.FieldStartIndex)
  41404. }
  41405. if m.end_index != nil {
  41406. fields = append(fields, usagetotal.FieldEndIndex)
  41407. }
  41408. if m.organization_id != nil {
  41409. fields = append(fields, usagetotal.FieldOrganizationID)
  41410. }
  41411. return fields
  41412. }
  41413. // Field returns the value of a field with the given name. The second boolean
  41414. // return value indicates that this field was not set, or was not defined in the
  41415. // schema.
  41416. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41417. switch name {
  41418. case usagetotal.FieldCreatedAt:
  41419. return m.CreatedAt()
  41420. case usagetotal.FieldUpdatedAt:
  41421. return m.UpdatedAt()
  41422. case usagetotal.FieldStatus:
  41423. return m.Status()
  41424. case usagetotal.FieldType:
  41425. return m.GetType()
  41426. case usagetotal.FieldBotID:
  41427. return m.BotID()
  41428. case usagetotal.FieldTotalTokens:
  41429. return m.TotalTokens()
  41430. case usagetotal.FieldStartIndex:
  41431. return m.StartIndex()
  41432. case usagetotal.FieldEndIndex:
  41433. return m.EndIndex()
  41434. case usagetotal.FieldOrganizationID:
  41435. return m.OrganizationID()
  41436. }
  41437. return nil, false
  41438. }
  41439. // OldField returns the old value of the field from the database. An error is
  41440. // returned if the mutation operation is not UpdateOne, or the query to the
  41441. // database failed.
  41442. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41443. switch name {
  41444. case usagetotal.FieldCreatedAt:
  41445. return m.OldCreatedAt(ctx)
  41446. case usagetotal.FieldUpdatedAt:
  41447. return m.OldUpdatedAt(ctx)
  41448. case usagetotal.FieldStatus:
  41449. return m.OldStatus(ctx)
  41450. case usagetotal.FieldType:
  41451. return m.OldType(ctx)
  41452. case usagetotal.FieldBotID:
  41453. return m.OldBotID(ctx)
  41454. case usagetotal.FieldTotalTokens:
  41455. return m.OldTotalTokens(ctx)
  41456. case usagetotal.FieldStartIndex:
  41457. return m.OldStartIndex(ctx)
  41458. case usagetotal.FieldEndIndex:
  41459. return m.OldEndIndex(ctx)
  41460. case usagetotal.FieldOrganizationID:
  41461. return m.OldOrganizationID(ctx)
  41462. }
  41463. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41464. }
  41465. // SetField sets the value of a field with the given name. It returns an error if
  41466. // the field is not defined in the schema, or if the type mismatched the field
  41467. // type.
  41468. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41469. switch name {
  41470. case usagetotal.FieldCreatedAt:
  41471. v, ok := value.(time.Time)
  41472. if !ok {
  41473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41474. }
  41475. m.SetCreatedAt(v)
  41476. return nil
  41477. case usagetotal.FieldUpdatedAt:
  41478. v, ok := value.(time.Time)
  41479. if !ok {
  41480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41481. }
  41482. m.SetUpdatedAt(v)
  41483. return nil
  41484. case usagetotal.FieldStatus:
  41485. v, ok := value.(uint8)
  41486. if !ok {
  41487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41488. }
  41489. m.SetStatus(v)
  41490. return nil
  41491. case usagetotal.FieldType:
  41492. v, ok := value.(int)
  41493. if !ok {
  41494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41495. }
  41496. m.SetType(v)
  41497. return nil
  41498. case usagetotal.FieldBotID:
  41499. v, ok := value.(string)
  41500. if !ok {
  41501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41502. }
  41503. m.SetBotID(v)
  41504. return nil
  41505. case usagetotal.FieldTotalTokens:
  41506. v, ok := value.(uint64)
  41507. if !ok {
  41508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41509. }
  41510. m.SetTotalTokens(v)
  41511. return nil
  41512. case usagetotal.FieldStartIndex:
  41513. v, ok := value.(uint64)
  41514. if !ok {
  41515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41516. }
  41517. m.SetStartIndex(v)
  41518. return nil
  41519. case usagetotal.FieldEndIndex:
  41520. v, ok := value.(uint64)
  41521. if !ok {
  41522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41523. }
  41524. m.SetEndIndex(v)
  41525. return nil
  41526. case usagetotal.FieldOrganizationID:
  41527. v, ok := value.(uint64)
  41528. if !ok {
  41529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41530. }
  41531. m.SetOrganizationID(v)
  41532. return nil
  41533. }
  41534. return fmt.Errorf("unknown UsageTotal field %s", name)
  41535. }
  41536. // AddedFields returns all numeric fields that were incremented/decremented during
  41537. // this mutation.
  41538. func (m *UsageTotalMutation) AddedFields() []string {
  41539. var fields []string
  41540. if m.addstatus != nil {
  41541. fields = append(fields, usagetotal.FieldStatus)
  41542. }
  41543. if m.add_type != nil {
  41544. fields = append(fields, usagetotal.FieldType)
  41545. }
  41546. if m.addtotal_tokens != nil {
  41547. fields = append(fields, usagetotal.FieldTotalTokens)
  41548. }
  41549. if m.addstart_index != nil {
  41550. fields = append(fields, usagetotal.FieldStartIndex)
  41551. }
  41552. if m.addend_index != nil {
  41553. fields = append(fields, usagetotal.FieldEndIndex)
  41554. }
  41555. if m.addorganization_id != nil {
  41556. fields = append(fields, usagetotal.FieldOrganizationID)
  41557. }
  41558. return fields
  41559. }
  41560. // AddedField returns the numeric value that was incremented/decremented on a field
  41561. // with the given name. The second boolean return value indicates that this field
  41562. // was not set, or was not defined in the schema.
  41563. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41564. switch name {
  41565. case usagetotal.FieldStatus:
  41566. return m.AddedStatus()
  41567. case usagetotal.FieldType:
  41568. return m.AddedType()
  41569. case usagetotal.FieldTotalTokens:
  41570. return m.AddedTotalTokens()
  41571. case usagetotal.FieldStartIndex:
  41572. return m.AddedStartIndex()
  41573. case usagetotal.FieldEndIndex:
  41574. return m.AddedEndIndex()
  41575. case usagetotal.FieldOrganizationID:
  41576. return m.AddedOrganizationID()
  41577. }
  41578. return nil, false
  41579. }
  41580. // AddField adds the value to the field with the given name. It returns an error if
  41581. // the field is not defined in the schema, or if the type mismatched the field
  41582. // type.
  41583. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41584. switch name {
  41585. case usagetotal.FieldStatus:
  41586. v, ok := value.(int8)
  41587. if !ok {
  41588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41589. }
  41590. m.AddStatus(v)
  41591. return nil
  41592. case usagetotal.FieldType:
  41593. v, ok := value.(int)
  41594. if !ok {
  41595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41596. }
  41597. m.AddType(v)
  41598. return nil
  41599. case usagetotal.FieldTotalTokens:
  41600. v, ok := value.(int64)
  41601. if !ok {
  41602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41603. }
  41604. m.AddTotalTokens(v)
  41605. return nil
  41606. case usagetotal.FieldStartIndex:
  41607. v, ok := value.(int64)
  41608. if !ok {
  41609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41610. }
  41611. m.AddStartIndex(v)
  41612. return nil
  41613. case usagetotal.FieldEndIndex:
  41614. v, ok := value.(int64)
  41615. if !ok {
  41616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41617. }
  41618. m.AddEndIndex(v)
  41619. return nil
  41620. case usagetotal.FieldOrganizationID:
  41621. v, ok := value.(int64)
  41622. if !ok {
  41623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41624. }
  41625. m.AddOrganizationID(v)
  41626. return nil
  41627. }
  41628. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41629. }
  41630. // ClearedFields returns all nullable fields that were cleared during this
  41631. // mutation.
  41632. func (m *UsageTotalMutation) ClearedFields() []string {
  41633. var fields []string
  41634. if m.FieldCleared(usagetotal.FieldStatus) {
  41635. fields = append(fields, usagetotal.FieldStatus)
  41636. }
  41637. if m.FieldCleared(usagetotal.FieldType) {
  41638. fields = append(fields, usagetotal.FieldType)
  41639. }
  41640. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41641. fields = append(fields, usagetotal.FieldTotalTokens)
  41642. }
  41643. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41644. fields = append(fields, usagetotal.FieldStartIndex)
  41645. }
  41646. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41647. fields = append(fields, usagetotal.FieldEndIndex)
  41648. }
  41649. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41650. fields = append(fields, usagetotal.FieldOrganizationID)
  41651. }
  41652. return fields
  41653. }
  41654. // FieldCleared returns a boolean indicating if a field with the given name was
  41655. // cleared in this mutation.
  41656. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41657. _, ok := m.clearedFields[name]
  41658. return ok
  41659. }
  41660. // ClearField clears the value of the field with the given name. It returns an
  41661. // error if the field is not defined in the schema.
  41662. func (m *UsageTotalMutation) ClearField(name string) error {
  41663. switch name {
  41664. case usagetotal.FieldStatus:
  41665. m.ClearStatus()
  41666. return nil
  41667. case usagetotal.FieldType:
  41668. m.ClearType()
  41669. return nil
  41670. case usagetotal.FieldTotalTokens:
  41671. m.ClearTotalTokens()
  41672. return nil
  41673. case usagetotal.FieldStartIndex:
  41674. m.ClearStartIndex()
  41675. return nil
  41676. case usagetotal.FieldEndIndex:
  41677. m.ClearEndIndex()
  41678. return nil
  41679. case usagetotal.FieldOrganizationID:
  41680. m.ClearOrganizationID()
  41681. return nil
  41682. }
  41683. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41684. }
  41685. // ResetField resets all changes in the mutation for the field with the given name.
  41686. // It returns an error if the field is not defined in the schema.
  41687. func (m *UsageTotalMutation) ResetField(name string) error {
  41688. switch name {
  41689. case usagetotal.FieldCreatedAt:
  41690. m.ResetCreatedAt()
  41691. return nil
  41692. case usagetotal.FieldUpdatedAt:
  41693. m.ResetUpdatedAt()
  41694. return nil
  41695. case usagetotal.FieldStatus:
  41696. m.ResetStatus()
  41697. return nil
  41698. case usagetotal.FieldType:
  41699. m.ResetType()
  41700. return nil
  41701. case usagetotal.FieldBotID:
  41702. m.ResetBotID()
  41703. return nil
  41704. case usagetotal.FieldTotalTokens:
  41705. m.ResetTotalTokens()
  41706. return nil
  41707. case usagetotal.FieldStartIndex:
  41708. m.ResetStartIndex()
  41709. return nil
  41710. case usagetotal.FieldEndIndex:
  41711. m.ResetEndIndex()
  41712. return nil
  41713. case usagetotal.FieldOrganizationID:
  41714. m.ResetOrganizationID()
  41715. return nil
  41716. }
  41717. return fmt.Errorf("unknown UsageTotal field %s", name)
  41718. }
  41719. // AddedEdges returns all edge names that were set/added in this mutation.
  41720. func (m *UsageTotalMutation) AddedEdges() []string {
  41721. edges := make([]string, 0, 0)
  41722. return edges
  41723. }
  41724. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41725. // name in this mutation.
  41726. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41727. return nil
  41728. }
  41729. // RemovedEdges returns all edge names that were removed in this mutation.
  41730. func (m *UsageTotalMutation) RemovedEdges() []string {
  41731. edges := make([]string, 0, 0)
  41732. return edges
  41733. }
  41734. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41735. // the given name in this mutation.
  41736. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41737. return nil
  41738. }
  41739. // ClearedEdges returns all edge names that were cleared in this mutation.
  41740. func (m *UsageTotalMutation) ClearedEdges() []string {
  41741. edges := make([]string, 0, 0)
  41742. return edges
  41743. }
  41744. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41745. // was cleared in this mutation.
  41746. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41747. return false
  41748. }
  41749. // ClearEdge clears the value of the edge with the given name. It returns an error
  41750. // if that edge is not defined in the schema.
  41751. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41752. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41753. }
  41754. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41755. // It returns an error if the edge is not defined in the schema.
  41756. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41757. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41758. }
  41759. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41760. type WhatsappMutation struct {
  41761. config
  41762. op Op
  41763. typ string
  41764. id *uint64
  41765. created_at *time.Time
  41766. updated_at *time.Time
  41767. status *uint8
  41768. addstatus *int8
  41769. deleted_at *time.Time
  41770. wa_id *string
  41771. wa_name *string
  41772. callback *string
  41773. account *string
  41774. cc *string
  41775. phone *string
  41776. cc_phone *string
  41777. phone_name *string
  41778. phone_status *int8
  41779. addphone_status *int8
  41780. organization_id *uint64
  41781. addorganization_id *int64
  41782. api_base *string
  41783. api_key *string
  41784. allow_list *[]string
  41785. appendallow_list []string
  41786. group_allow_list *[]string
  41787. appendgroup_allow_list []string
  41788. block_list *[]string
  41789. appendblock_list []string
  41790. group_block_list *[]string
  41791. appendgroup_block_list []string
  41792. clearedFields map[string]struct{}
  41793. agent *uint64
  41794. clearedagent bool
  41795. done bool
  41796. oldValue func(context.Context) (*Whatsapp, error)
  41797. predicates []predicate.Whatsapp
  41798. }
  41799. var _ ent.Mutation = (*WhatsappMutation)(nil)
  41800. // whatsappOption allows management of the mutation configuration using functional options.
  41801. type whatsappOption func(*WhatsappMutation)
  41802. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  41803. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  41804. m := &WhatsappMutation{
  41805. config: c,
  41806. op: op,
  41807. typ: TypeWhatsapp,
  41808. clearedFields: make(map[string]struct{}),
  41809. }
  41810. for _, opt := range opts {
  41811. opt(m)
  41812. }
  41813. return m
  41814. }
  41815. // withWhatsappID sets the ID field of the mutation.
  41816. func withWhatsappID(id uint64) whatsappOption {
  41817. return func(m *WhatsappMutation) {
  41818. var (
  41819. err error
  41820. once sync.Once
  41821. value *Whatsapp
  41822. )
  41823. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  41824. once.Do(func() {
  41825. if m.done {
  41826. err = errors.New("querying old values post mutation is not allowed")
  41827. } else {
  41828. value, err = m.Client().Whatsapp.Get(ctx, id)
  41829. }
  41830. })
  41831. return value, err
  41832. }
  41833. m.id = &id
  41834. }
  41835. }
  41836. // withWhatsapp sets the old Whatsapp of the mutation.
  41837. func withWhatsapp(node *Whatsapp) whatsappOption {
  41838. return func(m *WhatsappMutation) {
  41839. m.oldValue = func(context.Context) (*Whatsapp, error) {
  41840. return node, nil
  41841. }
  41842. m.id = &node.ID
  41843. }
  41844. }
  41845. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41846. // executed in a transaction (ent.Tx), a transactional client is returned.
  41847. func (m WhatsappMutation) Client() *Client {
  41848. client := &Client{config: m.config}
  41849. client.init()
  41850. return client
  41851. }
  41852. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41853. // it returns an error otherwise.
  41854. func (m WhatsappMutation) Tx() (*Tx, error) {
  41855. if _, ok := m.driver.(*txDriver); !ok {
  41856. return nil, errors.New("ent: mutation is not running in a transaction")
  41857. }
  41858. tx := &Tx{config: m.config}
  41859. tx.init()
  41860. return tx, nil
  41861. }
  41862. // SetID sets the value of the id field. Note that this
  41863. // operation is only accepted on creation of Whatsapp entities.
  41864. func (m *WhatsappMutation) SetID(id uint64) {
  41865. m.id = &id
  41866. }
  41867. // ID returns the ID value in the mutation. Note that the ID is only available
  41868. // if it was provided to the builder or after it was returned from the database.
  41869. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  41870. if m.id == nil {
  41871. return
  41872. }
  41873. return *m.id, true
  41874. }
  41875. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41876. // That means, if the mutation is applied within a transaction with an isolation level such
  41877. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41878. // or updated by the mutation.
  41879. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  41880. switch {
  41881. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41882. id, exists := m.ID()
  41883. if exists {
  41884. return []uint64{id}, nil
  41885. }
  41886. fallthrough
  41887. case m.op.Is(OpUpdate | OpDelete):
  41888. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  41889. default:
  41890. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41891. }
  41892. }
  41893. // SetCreatedAt sets the "created_at" field.
  41894. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  41895. m.created_at = &t
  41896. }
  41897. // CreatedAt returns the value of the "created_at" field in the mutation.
  41898. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  41899. v := m.created_at
  41900. if v == nil {
  41901. return
  41902. }
  41903. return *v, true
  41904. }
  41905. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  41906. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41908. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41909. if !m.op.Is(OpUpdateOne) {
  41910. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41911. }
  41912. if m.id == nil || m.oldValue == nil {
  41913. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41914. }
  41915. oldValue, err := m.oldValue(ctx)
  41916. if err != nil {
  41917. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41918. }
  41919. return oldValue.CreatedAt, nil
  41920. }
  41921. // ResetCreatedAt resets all changes to the "created_at" field.
  41922. func (m *WhatsappMutation) ResetCreatedAt() {
  41923. m.created_at = nil
  41924. }
  41925. // SetUpdatedAt sets the "updated_at" field.
  41926. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  41927. m.updated_at = &t
  41928. }
  41929. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41930. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  41931. v := m.updated_at
  41932. if v == nil {
  41933. return
  41934. }
  41935. return *v, true
  41936. }
  41937. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  41938. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41940. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41941. if !m.op.Is(OpUpdateOne) {
  41942. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41943. }
  41944. if m.id == nil || m.oldValue == nil {
  41945. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41946. }
  41947. oldValue, err := m.oldValue(ctx)
  41948. if err != nil {
  41949. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41950. }
  41951. return oldValue.UpdatedAt, nil
  41952. }
  41953. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41954. func (m *WhatsappMutation) ResetUpdatedAt() {
  41955. m.updated_at = nil
  41956. }
  41957. // SetStatus sets the "status" field.
  41958. func (m *WhatsappMutation) SetStatus(u uint8) {
  41959. m.status = &u
  41960. m.addstatus = nil
  41961. }
  41962. // Status returns the value of the "status" field in the mutation.
  41963. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  41964. v := m.status
  41965. if v == nil {
  41966. return
  41967. }
  41968. return *v, true
  41969. }
  41970. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  41971. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41973. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41974. if !m.op.Is(OpUpdateOne) {
  41975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41976. }
  41977. if m.id == nil || m.oldValue == nil {
  41978. return v, errors.New("OldStatus requires an ID field in the mutation")
  41979. }
  41980. oldValue, err := m.oldValue(ctx)
  41981. if err != nil {
  41982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41983. }
  41984. return oldValue.Status, nil
  41985. }
  41986. // AddStatus adds u to the "status" field.
  41987. func (m *WhatsappMutation) AddStatus(u int8) {
  41988. if m.addstatus != nil {
  41989. *m.addstatus += u
  41990. } else {
  41991. m.addstatus = &u
  41992. }
  41993. }
  41994. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41995. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  41996. v := m.addstatus
  41997. if v == nil {
  41998. return
  41999. }
  42000. return *v, true
  42001. }
  42002. // ClearStatus clears the value of the "status" field.
  42003. func (m *WhatsappMutation) ClearStatus() {
  42004. m.status = nil
  42005. m.addstatus = nil
  42006. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  42007. }
  42008. // StatusCleared returns if the "status" field was cleared in this mutation.
  42009. func (m *WhatsappMutation) StatusCleared() bool {
  42010. _, ok := m.clearedFields[whatsapp.FieldStatus]
  42011. return ok
  42012. }
  42013. // ResetStatus resets all changes to the "status" field.
  42014. func (m *WhatsappMutation) ResetStatus() {
  42015. m.status = nil
  42016. m.addstatus = nil
  42017. delete(m.clearedFields, whatsapp.FieldStatus)
  42018. }
  42019. // SetDeletedAt sets the "deleted_at" field.
  42020. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  42021. m.deleted_at = &t
  42022. }
  42023. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42024. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  42025. v := m.deleted_at
  42026. if v == nil {
  42027. return
  42028. }
  42029. return *v, true
  42030. }
  42031. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  42032. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42034. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42035. if !m.op.Is(OpUpdateOne) {
  42036. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42037. }
  42038. if m.id == nil || m.oldValue == nil {
  42039. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42040. }
  42041. oldValue, err := m.oldValue(ctx)
  42042. if err != nil {
  42043. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42044. }
  42045. return oldValue.DeletedAt, nil
  42046. }
  42047. // ClearDeletedAt clears the value of the "deleted_at" field.
  42048. func (m *WhatsappMutation) ClearDeletedAt() {
  42049. m.deleted_at = nil
  42050. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  42051. }
  42052. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42053. func (m *WhatsappMutation) DeletedAtCleared() bool {
  42054. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  42055. return ok
  42056. }
  42057. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42058. func (m *WhatsappMutation) ResetDeletedAt() {
  42059. m.deleted_at = nil
  42060. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  42061. }
  42062. // SetWaID sets the "wa_id" field.
  42063. func (m *WhatsappMutation) SetWaID(s string) {
  42064. m.wa_id = &s
  42065. }
  42066. // WaID returns the value of the "wa_id" field in the mutation.
  42067. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  42068. v := m.wa_id
  42069. if v == nil {
  42070. return
  42071. }
  42072. return *v, true
  42073. }
  42074. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  42075. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42077. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  42078. if !m.op.Is(OpUpdateOne) {
  42079. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42080. }
  42081. if m.id == nil || m.oldValue == nil {
  42082. return v, errors.New("OldWaID requires an ID field in the mutation")
  42083. }
  42084. oldValue, err := m.oldValue(ctx)
  42085. if err != nil {
  42086. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42087. }
  42088. return oldValue.WaID, nil
  42089. }
  42090. // ClearWaID clears the value of the "wa_id" field.
  42091. func (m *WhatsappMutation) ClearWaID() {
  42092. m.wa_id = nil
  42093. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  42094. }
  42095. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42096. func (m *WhatsappMutation) WaIDCleared() bool {
  42097. _, ok := m.clearedFields[whatsapp.FieldWaID]
  42098. return ok
  42099. }
  42100. // ResetWaID resets all changes to the "wa_id" field.
  42101. func (m *WhatsappMutation) ResetWaID() {
  42102. m.wa_id = nil
  42103. delete(m.clearedFields, whatsapp.FieldWaID)
  42104. }
  42105. // SetWaName sets the "wa_name" field.
  42106. func (m *WhatsappMutation) SetWaName(s string) {
  42107. m.wa_name = &s
  42108. }
  42109. // WaName returns the value of the "wa_name" field in the mutation.
  42110. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  42111. v := m.wa_name
  42112. if v == nil {
  42113. return
  42114. }
  42115. return *v, true
  42116. }
  42117. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  42118. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42120. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  42121. if !m.op.Is(OpUpdateOne) {
  42122. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42123. }
  42124. if m.id == nil || m.oldValue == nil {
  42125. return v, errors.New("OldWaName requires an ID field in the mutation")
  42126. }
  42127. oldValue, err := m.oldValue(ctx)
  42128. if err != nil {
  42129. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42130. }
  42131. return oldValue.WaName, nil
  42132. }
  42133. // ClearWaName clears the value of the "wa_name" field.
  42134. func (m *WhatsappMutation) ClearWaName() {
  42135. m.wa_name = nil
  42136. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42137. }
  42138. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42139. func (m *WhatsappMutation) WaNameCleared() bool {
  42140. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42141. return ok
  42142. }
  42143. // ResetWaName resets all changes to the "wa_name" field.
  42144. func (m *WhatsappMutation) ResetWaName() {
  42145. m.wa_name = nil
  42146. delete(m.clearedFields, whatsapp.FieldWaName)
  42147. }
  42148. // SetCallback sets the "callback" field.
  42149. func (m *WhatsappMutation) SetCallback(s string) {
  42150. m.callback = &s
  42151. }
  42152. // Callback returns the value of the "callback" field in the mutation.
  42153. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42154. v := m.callback
  42155. if v == nil {
  42156. return
  42157. }
  42158. return *v, true
  42159. }
  42160. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42161. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42163. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42164. if !m.op.Is(OpUpdateOne) {
  42165. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42166. }
  42167. if m.id == nil || m.oldValue == nil {
  42168. return v, errors.New("OldCallback requires an ID field in the mutation")
  42169. }
  42170. oldValue, err := m.oldValue(ctx)
  42171. if err != nil {
  42172. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42173. }
  42174. return oldValue.Callback, nil
  42175. }
  42176. // ClearCallback clears the value of the "callback" field.
  42177. func (m *WhatsappMutation) ClearCallback() {
  42178. m.callback = nil
  42179. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42180. }
  42181. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42182. func (m *WhatsappMutation) CallbackCleared() bool {
  42183. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42184. return ok
  42185. }
  42186. // ResetCallback resets all changes to the "callback" field.
  42187. func (m *WhatsappMutation) ResetCallback() {
  42188. m.callback = nil
  42189. delete(m.clearedFields, whatsapp.FieldCallback)
  42190. }
  42191. // SetAgentID sets the "agent_id" field.
  42192. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42193. m.agent = &u
  42194. }
  42195. // AgentID returns the value of the "agent_id" field in the mutation.
  42196. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42197. v := m.agent
  42198. if v == nil {
  42199. return
  42200. }
  42201. return *v, true
  42202. }
  42203. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42204. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42206. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42207. if !m.op.Is(OpUpdateOne) {
  42208. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42209. }
  42210. if m.id == nil || m.oldValue == nil {
  42211. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42212. }
  42213. oldValue, err := m.oldValue(ctx)
  42214. if err != nil {
  42215. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42216. }
  42217. return oldValue.AgentID, nil
  42218. }
  42219. // ResetAgentID resets all changes to the "agent_id" field.
  42220. func (m *WhatsappMutation) ResetAgentID() {
  42221. m.agent = nil
  42222. }
  42223. // SetAccount sets the "account" field.
  42224. func (m *WhatsappMutation) SetAccount(s string) {
  42225. m.account = &s
  42226. }
  42227. // Account returns the value of the "account" field in the mutation.
  42228. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42229. v := m.account
  42230. if v == nil {
  42231. return
  42232. }
  42233. return *v, true
  42234. }
  42235. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42236. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42238. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42239. if !m.op.Is(OpUpdateOne) {
  42240. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42241. }
  42242. if m.id == nil || m.oldValue == nil {
  42243. return v, errors.New("OldAccount requires an ID field in the mutation")
  42244. }
  42245. oldValue, err := m.oldValue(ctx)
  42246. if err != nil {
  42247. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42248. }
  42249. return oldValue.Account, nil
  42250. }
  42251. // ClearAccount clears the value of the "account" field.
  42252. func (m *WhatsappMutation) ClearAccount() {
  42253. m.account = nil
  42254. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42255. }
  42256. // AccountCleared returns if the "account" field was cleared in this mutation.
  42257. func (m *WhatsappMutation) AccountCleared() bool {
  42258. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42259. return ok
  42260. }
  42261. // ResetAccount resets all changes to the "account" field.
  42262. func (m *WhatsappMutation) ResetAccount() {
  42263. m.account = nil
  42264. delete(m.clearedFields, whatsapp.FieldAccount)
  42265. }
  42266. // SetCc sets the "cc" field.
  42267. func (m *WhatsappMutation) SetCc(s string) {
  42268. m.cc = &s
  42269. }
  42270. // Cc returns the value of the "cc" field in the mutation.
  42271. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42272. v := m.cc
  42273. if v == nil {
  42274. return
  42275. }
  42276. return *v, true
  42277. }
  42278. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42279. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42281. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42282. if !m.op.Is(OpUpdateOne) {
  42283. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42284. }
  42285. if m.id == nil || m.oldValue == nil {
  42286. return v, errors.New("OldCc requires an ID field in the mutation")
  42287. }
  42288. oldValue, err := m.oldValue(ctx)
  42289. if err != nil {
  42290. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42291. }
  42292. return oldValue.Cc, nil
  42293. }
  42294. // ResetCc resets all changes to the "cc" field.
  42295. func (m *WhatsappMutation) ResetCc() {
  42296. m.cc = nil
  42297. }
  42298. // SetPhone sets the "phone" field.
  42299. func (m *WhatsappMutation) SetPhone(s string) {
  42300. m.phone = &s
  42301. }
  42302. // Phone returns the value of the "phone" field in the mutation.
  42303. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42304. v := m.phone
  42305. if v == nil {
  42306. return
  42307. }
  42308. return *v, true
  42309. }
  42310. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42311. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42313. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42314. if !m.op.Is(OpUpdateOne) {
  42315. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42316. }
  42317. if m.id == nil || m.oldValue == nil {
  42318. return v, errors.New("OldPhone requires an ID field in the mutation")
  42319. }
  42320. oldValue, err := m.oldValue(ctx)
  42321. if err != nil {
  42322. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42323. }
  42324. return oldValue.Phone, nil
  42325. }
  42326. // ResetPhone resets all changes to the "phone" field.
  42327. func (m *WhatsappMutation) ResetPhone() {
  42328. m.phone = nil
  42329. }
  42330. // SetCcPhone sets the "cc_phone" field.
  42331. func (m *WhatsappMutation) SetCcPhone(s string) {
  42332. m.cc_phone = &s
  42333. }
  42334. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42335. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42336. v := m.cc_phone
  42337. if v == nil {
  42338. return
  42339. }
  42340. return *v, true
  42341. }
  42342. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42343. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42345. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42346. if !m.op.Is(OpUpdateOne) {
  42347. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42348. }
  42349. if m.id == nil || m.oldValue == nil {
  42350. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42351. }
  42352. oldValue, err := m.oldValue(ctx)
  42353. if err != nil {
  42354. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42355. }
  42356. return oldValue.CcPhone, nil
  42357. }
  42358. // ResetCcPhone resets all changes to the "cc_phone" field.
  42359. func (m *WhatsappMutation) ResetCcPhone() {
  42360. m.cc_phone = nil
  42361. }
  42362. // SetPhoneName sets the "phone_name" field.
  42363. func (m *WhatsappMutation) SetPhoneName(s string) {
  42364. m.phone_name = &s
  42365. }
  42366. // PhoneName returns the value of the "phone_name" field in the mutation.
  42367. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42368. v := m.phone_name
  42369. if v == nil {
  42370. return
  42371. }
  42372. return *v, true
  42373. }
  42374. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42375. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42377. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42378. if !m.op.Is(OpUpdateOne) {
  42379. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42380. }
  42381. if m.id == nil || m.oldValue == nil {
  42382. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42383. }
  42384. oldValue, err := m.oldValue(ctx)
  42385. if err != nil {
  42386. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42387. }
  42388. return oldValue.PhoneName, nil
  42389. }
  42390. // ResetPhoneName resets all changes to the "phone_name" field.
  42391. func (m *WhatsappMutation) ResetPhoneName() {
  42392. m.phone_name = nil
  42393. }
  42394. // SetPhoneStatus sets the "phone_status" field.
  42395. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42396. m.phone_status = &i
  42397. m.addphone_status = nil
  42398. }
  42399. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42400. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42401. v := m.phone_status
  42402. if v == nil {
  42403. return
  42404. }
  42405. return *v, true
  42406. }
  42407. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42408. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42410. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42411. if !m.op.Is(OpUpdateOne) {
  42412. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42413. }
  42414. if m.id == nil || m.oldValue == nil {
  42415. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42416. }
  42417. oldValue, err := m.oldValue(ctx)
  42418. if err != nil {
  42419. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42420. }
  42421. return oldValue.PhoneStatus, nil
  42422. }
  42423. // AddPhoneStatus adds i to the "phone_status" field.
  42424. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42425. if m.addphone_status != nil {
  42426. *m.addphone_status += i
  42427. } else {
  42428. m.addphone_status = &i
  42429. }
  42430. }
  42431. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42432. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42433. v := m.addphone_status
  42434. if v == nil {
  42435. return
  42436. }
  42437. return *v, true
  42438. }
  42439. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42440. func (m *WhatsappMutation) ResetPhoneStatus() {
  42441. m.phone_status = nil
  42442. m.addphone_status = nil
  42443. }
  42444. // SetOrganizationID sets the "organization_id" field.
  42445. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42446. m.organization_id = &u
  42447. m.addorganization_id = nil
  42448. }
  42449. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42450. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42451. v := m.organization_id
  42452. if v == nil {
  42453. return
  42454. }
  42455. return *v, true
  42456. }
  42457. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42458. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42460. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42461. if !m.op.Is(OpUpdateOne) {
  42462. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42463. }
  42464. if m.id == nil || m.oldValue == nil {
  42465. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42466. }
  42467. oldValue, err := m.oldValue(ctx)
  42468. if err != nil {
  42469. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42470. }
  42471. return oldValue.OrganizationID, nil
  42472. }
  42473. // AddOrganizationID adds u to the "organization_id" field.
  42474. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42475. if m.addorganization_id != nil {
  42476. *m.addorganization_id += u
  42477. } else {
  42478. m.addorganization_id = &u
  42479. }
  42480. }
  42481. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42482. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42483. v := m.addorganization_id
  42484. if v == nil {
  42485. return
  42486. }
  42487. return *v, true
  42488. }
  42489. // ClearOrganizationID clears the value of the "organization_id" field.
  42490. func (m *WhatsappMutation) ClearOrganizationID() {
  42491. m.organization_id = nil
  42492. m.addorganization_id = nil
  42493. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42494. }
  42495. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42496. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42497. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42498. return ok
  42499. }
  42500. // ResetOrganizationID resets all changes to the "organization_id" field.
  42501. func (m *WhatsappMutation) ResetOrganizationID() {
  42502. m.organization_id = nil
  42503. m.addorganization_id = nil
  42504. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42505. }
  42506. // SetAPIBase sets the "api_base" field.
  42507. func (m *WhatsappMutation) SetAPIBase(s string) {
  42508. m.api_base = &s
  42509. }
  42510. // APIBase returns the value of the "api_base" field in the mutation.
  42511. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42512. v := m.api_base
  42513. if v == nil {
  42514. return
  42515. }
  42516. return *v, true
  42517. }
  42518. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42519. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42521. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42522. if !m.op.Is(OpUpdateOne) {
  42523. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42524. }
  42525. if m.id == nil || m.oldValue == nil {
  42526. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42527. }
  42528. oldValue, err := m.oldValue(ctx)
  42529. if err != nil {
  42530. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42531. }
  42532. return oldValue.APIBase, nil
  42533. }
  42534. // ClearAPIBase clears the value of the "api_base" field.
  42535. func (m *WhatsappMutation) ClearAPIBase() {
  42536. m.api_base = nil
  42537. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42538. }
  42539. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42540. func (m *WhatsappMutation) APIBaseCleared() bool {
  42541. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42542. return ok
  42543. }
  42544. // ResetAPIBase resets all changes to the "api_base" field.
  42545. func (m *WhatsappMutation) ResetAPIBase() {
  42546. m.api_base = nil
  42547. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42548. }
  42549. // SetAPIKey sets the "api_key" field.
  42550. func (m *WhatsappMutation) SetAPIKey(s string) {
  42551. m.api_key = &s
  42552. }
  42553. // APIKey returns the value of the "api_key" field in the mutation.
  42554. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42555. v := m.api_key
  42556. if v == nil {
  42557. return
  42558. }
  42559. return *v, true
  42560. }
  42561. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42562. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42564. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42565. if !m.op.Is(OpUpdateOne) {
  42566. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42567. }
  42568. if m.id == nil || m.oldValue == nil {
  42569. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42570. }
  42571. oldValue, err := m.oldValue(ctx)
  42572. if err != nil {
  42573. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42574. }
  42575. return oldValue.APIKey, nil
  42576. }
  42577. // ClearAPIKey clears the value of the "api_key" field.
  42578. func (m *WhatsappMutation) ClearAPIKey() {
  42579. m.api_key = nil
  42580. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42581. }
  42582. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42583. func (m *WhatsappMutation) APIKeyCleared() bool {
  42584. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42585. return ok
  42586. }
  42587. // ResetAPIKey resets all changes to the "api_key" field.
  42588. func (m *WhatsappMutation) ResetAPIKey() {
  42589. m.api_key = nil
  42590. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42591. }
  42592. // SetAllowList sets the "allow_list" field.
  42593. func (m *WhatsappMutation) SetAllowList(s []string) {
  42594. m.allow_list = &s
  42595. m.appendallow_list = nil
  42596. }
  42597. // AllowList returns the value of the "allow_list" field in the mutation.
  42598. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42599. v := m.allow_list
  42600. if v == nil {
  42601. return
  42602. }
  42603. return *v, true
  42604. }
  42605. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42606. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42608. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42609. if !m.op.Is(OpUpdateOne) {
  42610. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42611. }
  42612. if m.id == nil || m.oldValue == nil {
  42613. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42614. }
  42615. oldValue, err := m.oldValue(ctx)
  42616. if err != nil {
  42617. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42618. }
  42619. return oldValue.AllowList, nil
  42620. }
  42621. // AppendAllowList adds s to the "allow_list" field.
  42622. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42623. m.appendallow_list = append(m.appendallow_list, s...)
  42624. }
  42625. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42626. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42627. if len(m.appendallow_list) == 0 {
  42628. return nil, false
  42629. }
  42630. return m.appendallow_list, true
  42631. }
  42632. // ClearAllowList clears the value of the "allow_list" field.
  42633. func (m *WhatsappMutation) ClearAllowList() {
  42634. m.allow_list = nil
  42635. m.appendallow_list = nil
  42636. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42637. }
  42638. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42639. func (m *WhatsappMutation) AllowListCleared() bool {
  42640. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42641. return ok
  42642. }
  42643. // ResetAllowList resets all changes to the "allow_list" field.
  42644. func (m *WhatsappMutation) ResetAllowList() {
  42645. m.allow_list = nil
  42646. m.appendallow_list = nil
  42647. delete(m.clearedFields, whatsapp.FieldAllowList)
  42648. }
  42649. // SetGroupAllowList sets the "group_allow_list" field.
  42650. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42651. m.group_allow_list = &s
  42652. m.appendgroup_allow_list = nil
  42653. }
  42654. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42655. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42656. v := m.group_allow_list
  42657. if v == nil {
  42658. return
  42659. }
  42660. return *v, true
  42661. }
  42662. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42663. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42665. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42666. if !m.op.Is(OpUpdateOne) {
  42667. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42668. }
  42669. if m.id == nil || m.oldValue == nil {
  42670. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42671. }
  42672. oldValue, err := m.oldValue(ctx)
  42673. if err != nil {
  42674. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42675. }
  42676. return oldValue.GroupAllowList, nil
  42677. }
  42678. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42679. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42680. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42681. }
  42682. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42683. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42684. if len(m.appendgroup_allow_list) == 0 {
  42685. return nil, false
  42686. }
  42687. return m.appendgroup_allow_list, true
  42688. }
  42689. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42690. func (m *WhatsappMutation) ClearGroupAllowList() {
  42691. m.group_allow_list = nil
  42692. m.appendgroup_allow_list = nil
  42693. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42694. }
  42695. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42696. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42697. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42698. return ok
  42699. }
  42700. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42701. func (m *WhatsappMutation) ResetGroupAllowList() {
  42702. m.group_allow_list = nil
  42703. m.appendgroup_allow_list = nil
  42704. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42705. }
  42706. // SetBlockList sets the "block_list" field.
  42707. func (m *WhatsappMutation) SetBlockList(s []string) {
  42708. m.block_list = &s
  42709. m.appendblock_list = nil
  42710. }
  42711. // BlockList returns the value of the "block_list" field in the mutation.
  42712. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42713. v := m.block_list
  42714. if v == nil {
  42715. return
  42716. }
  42717. return *v, true
  42718. }
  42719. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42720. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42722. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42723. if !m.op.Is(OpUpdateOne) {
  42724. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42725. }
  42726. if m.id == nil || m.oldValue == nil {
  42727. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42728. }
  42729. oldValue, err := m.oldValue(ctx)
  42730. if err != nil {
  42731. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42732. }
  42733. return oldValue.BlockList, nil
  42734. }
  42735. // AppendBlockList adds s to the "block_list" field.
  42736. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42737. m.appendblock_list = append(m.appendblock_list, s...)
  42738. }
  42739. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42740. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42741. if len(m.appendblock_list) == 0 {
  42742. return nil, false
  42743. }
  42744. return m.appendblock_list, true
  42745. }
  42746. // ClearBlockList clears the value of the "block_list" field.
  42747. func (m *WhatsappMutation) ClearBlockList() {
  42748. m.block_list = nil
  42749. m.appendblock_list = nil
  42750. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42751. }
  42752. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42753. func (m *WhatsappMutation) BlockListCleared() bool {
  42754. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42755. return ok
  42756. }
  42757. // ResetBlockList resets all changes to the "block_list" field.
  42758. func (m *WhatsappMutation) ResetBlockList() {
  42759. m.block_list = nil
  42760. m.appendblock_list = nil
  42761. delete(m.clearedFields, whatsapp.FieldBlockList)
  42762. }
  42763. // SetGroupBlockList sets the "group_block_list" field.
  42764. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42765. m.group_block_list = &s
  42766. m.appendgroup_block_list = nil
  42767. }
  42768. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42769. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  42770. v := m.group_block_list
  42771. if v == nil {
  42772. return
  42773. }
  42774. return *v, true
  42775. }
  42776. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  42777. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42779. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42780. if !m.op.Is(OpUpdateOne) {
  42781. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42782. }
  42783. if m.id == nil || m.oldValue == nil {
  42784. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42785. }
  42786. oldValue, err := m.oldValue(ctx)
  42787. if err != nil {
  42788. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42789. }
  42790. return oldValue.GroupBlockList, nil
  42791. }
  42792. // AppendGroupBlockList adds s to the "group_block_list" field.
  42793. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  42794. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42795. }
  42796. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42797. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  42798. if len(m.appendgroup_block_list) == 0 {
  42799. return nil, false
  42800. }
  42801. return m.appendgroup_block_list, true
  42802. }
  42803. // ClearGroupBlockList clears the value of the "group_block_list" field.
  42804. func (m *WhatsappMutation) ClearGroupBlockList() {
  42805. m.group_block_list = nil
  42806. m.appendgroup_block_list = nil
  42807. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  42808. }
  42809. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  42810. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  42811. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  42812. return ok
  42813. }
  42814. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42815. func (m *WhatsappMutation) ResetGroupBlockList() {
  42816. m.group_block_list = nil
  42817. m.appendgroup_block_list = nil
  42818. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  42819. }
  42820. // ClearAgent clears the "agent" edge to the Agent entity.
  42821. func (m *WhatsappMutation) ClearAgent() {
  42822. m.clearedagent = true
  42823. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  42824. }
  42825. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42826. func (m *WhatsappMutation) AgentCleared() bool {
  42827. return m.clearedagent
  42828. }
  42829. // AgentIDs returns the "agent" edge IDs in the mutation.
  42830. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42831. // AgentID instead. It exists only for internal usage by the builders.
  42832. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  42833. if id := m.agent; id != nil {
  42834. ids = append(ids, *id)
  42835. }
  42836. return
  42837. }
  42838. // ResetAgent resets all changes to the "agent" edge.
  42839. func (m *WhatsappMutation) ResetAgent() {
  42840. m.agent = nil
  42841. m.clearedagent = false
  42842. }
  42843. // Where appends a list predicates to the WhatsappMutation builder.
  42844. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  42845. m.predicates = append(m.predicates, ps...)
  42846. }
  42847. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  42848. // users can use type-assertion to append predicates that do not depend on any generated package.
  42849. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  42850. p := make([]predicate.Whatsapp, len(ps))
  42851. for i := range ps {
  42852. p[i] = ps[i]
  42853. }
  42854. m.Where(p...)
  42855. }
  42856. // Op returns the operation name.
  42857. func (m *WhatsappMutation) Op() Op {
  42858. return m.op
  42859. }
  42860. // SetOp allows setting the mutation operation.
  42861. func (m *WhatsappMutation) SetOp(op Op) {
  42862. m.op = op
  42863. }
  42864. // Type returns the node type of this mutation (Whatsapp).
  42865. func (m *WhatsappMutation) Type() string {
  42866. return m.typ
  42867. }
  42868. // Fields returns all fields that were changed during this mutation. Note that in
  42869. // order to get all numeric fields that were incremented/decremented, call
  42870. // AddedFields().
  42871. func (m *WhatsappMutation) Fields() []string {
  42872. fields := make([]string, 0, 21)
  42873. if m.created_at != nil {
  42874. fields = append(fields, whatsapp.FieldCreatedAt)
  42875. }
  42876. if m.updated_at != nil {
  42877. fields = append(fields, whatsapp.FieldUpdatedAt)
  42878. }
  42879. if m.status != nil {
  42880. fields = append(fields, whatsapp.FieldStatus)
  42881. }
  42882. if m.deleted_at != nil {
  42883. fields = append(fields, whatsapp.FieldDeletedAt)
  42884. }
  42885. if m.wa_id != nil {
  42886. fields = append(fields, whatsapp.FieldWaID)
  42887. }
  42888. if m.wa_name != nil {
  42889. fields = append(fields, whatsapp.FieldWaName)
  42890. }
  42891. if m.callback != nil {
  42892. fields = append(fields, whatsapp.FieldCallback)
  42893. }
  42894. if m.agent != nil {
  42895. fields = append(fields, whatsapp.FieldAgentID)
  42896. }
  42897. if m.account != nil {
  42898. fields = append(fields, whatsapp.FieldAccount)
  42899. }
  42900. if m.cc != nil {
  42901. fields = append(fields, whatsapp.FieldCc)
  42902. }
  42903. if m.phone != nil {
  42904. fields = append(fields, whatsapp.FieldPhone)
  42905. }
  42906. if m.cc_phone != nil {
  42907. fields = append(fields, whatsapp.FieldCcPhone)
  42908. }
  42909. if m.phone_name != nil {
  42910. fields = append(fields, whatsapp.FieldPhoneName)
  42911. }
  42912. if m.phone_status != nil {
  42913. fields = append(fields, whatsapp.FieldPhoneStatus)
  42914. }
  42915. if m.organization_id != nil {
  42916. fields = append(fields, whatsapp.FieldOrganizationID)
  42917. }
  42918. if m.api_base != nil {
  42919. fields = append(fields, whatsapp.FieldAPIBase)
  42920. }
  42921. if m.api_key != nil {
  42922. fields = append(fields, whatsapp.FieldAPIKey)
  42923. }
  42924. if m.allow_list != nil {
  42925. fields = append(fields, whatsapp.FieldAllowList)
  42926. }
  42927. if m.group_allow_list != nil {
  42928. fields = append(fields, whatsapp.FieldGroupAllowList)
  42929. }
  42930. if m.block_list != nil {
  42931. fields = append(fields, whatsapp.FieldBlockList)
  42932. }
  42933. if m.group_block_list != nil {
  42934. fields = append(fields, whatsapp.FieldGroupBlockList)
  42935. }
  42936. return fields
  42937. }
  42938. // Field returns the value of a field with the given name. The second boolean
  42939. // return value indicates that this field was not set, or was not defined in the
  42940. // schema.
  42941. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  42942. switch name {
  42943. case whatsapp.FieldCreatedAt:
  42944. return m.CreatedAt()
  42945. case whatsapp.FieldUpdatedAt:
  42946. return m.UpdatedAt()
  42947. case whatsapp.FieldStatus:
  42948. return m.Status()
  42949. case whatsapp.FieldDeletedAt:
  42950. return m.DeletedAt()
  42951. case whatsapp.FieldWaID:
  42952. return m.WaID()
  42953. case whatsapp.FieldWaName:
  42954. return m.WaName()
  42955. case whatsapp.FieldCallback:
  42956. return m.Callback()
  42957. case whatsapp.FieldAgentID:
  42958. return m.AgentID()
  42959. case whatsapp.FieldAccount:
  42960. return m.Account()
  42961. case whatsapp.FieldCc:
  42962. return m.Cc()
  42963. case whatsapp.FieldPhone:
  42964. return m.Phone()
  42965. case whatsapp.FieldCcPhone:
  42966. return m.CcPhone()
  42967. case whatsapp.FieldPhoneName:
  42968. return m.PhoneName()
  42969. case whatsapp.FieldPhoneStatus:
  42970. return m.PhoneStatus()
  42971. case whatsapp.FieldOrganizationID:
  42972. return m.OrganizationID()
  42973. case whatsapp.FieldAPIBase:
  42974. return m.APIBase()
  42975. case whatsapp.FieldAPIKey:
  42976. return m.APIKey()
  42977. case whatsapp.FieldAllowList:
  42978. return m.AllowList()
  42979. case whatsapp.FieldGroupAllowList:
  42980. return m.GroupAllowList()
  42981. case whatsapp.FieldBlockList:
  42982. return m.BlockList()
  42983. case whatsapp.FieldGroupBlockList:
  42984. return m.GroupBlockList()
  42985. }
  42986. return nil, false
  42987. }
  42988. // OldField returns the old value of the field from the database. An error is
  42989. // returned if the mutation operation is not UpdateOne, or the query to the
  42990. // database failed.
  42991. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42992. switch name {
  42993. case whatsapp.FieldCreatedAt:
  42994. return m.OldCreatedAt(ctx)
  42995. case whatsapp.FieldUpdatedAt:
  42996. return m.OldUpdatedAt(ctx)
  42997. case whatsapp.FieldStatus:
  42998. return m.OldStatus(ctx)
  42999. case whatsapp.FieldDeletedAt:
  43000. return m.OldDeletedAt(ctx)
  43001. case whatsapp.FieldWaID:
  43002. return m.OldWaID(ctx)
  43003. case whatsapp.FieldWaName:
  43004. return m.OldWaName(ctx)
  43005. case whatsapp.FieldCallback:
  43006. return m.OldCallback(ctx)
  43007. case whatsapp.FieldAgentID:
  43008. return m.OldAgentID(ctx)
  43009. case whatsapp.FieldAccount:
  43010. return m.OldAccount(ctx)
  43011. case whatsapp.FieldCc:
  43012. return m.OldCc(ctx)
  43013. case whatsapp.FieldPhone:
  43014. return m.OldPhone(ctx)
  43015. case whatsapp.FieldCcPhone:
  43016. return m.OldCcPhone(ctx)
  43017. case whatsapp.FieldPhoneName:
  43018. return m.OldPhoneName(ctx)
  43019. case whatsapp.FieldPhoneStatus:
  43020. return m.OldPhoneStatus(ctx)
  43021. case whatsapp.FieldOrganizationID:
  43022. return m.OldOrganizationID(ctx)
  43023. case whatsapp.FieldAPIBase:
  43024. return m.OldAPIBase(ctx)
  43025. case whatsapp.FieldAPIKey:
  43026. return m.OldAPIKey(ctx)
  43027. case whatsapp.FieldAllowList:
  43028. return m.OldAllowList(ctx)
  43029. case whatsapp.FieldGroupAllowList:
  43030. return m.OldGroupAllowList(ctx)
  43031. case whatsapp.FieldBlockList:
  43032. return m.OldBlockList(ctx)
  43033. case whatsapp.FieldGroupBlockList:
  43034. return m.OldGroupBlockList(ctx)
  43035. }
  43036. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  43037. }
  43038. // SetField sets the value of a field with the given name. It returns an error if
  43039. // the field is not defined in the schema, or if the type mismatched the field
  43040. // type.
  43041. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  43042. switch name {
  43043. case whatsapp.FieldCreatedAt:
  43044. v, ok := value.(time.Time)
  43045. if !ok {
  43046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43047. }
  43048. m.SetCreatedAt(v)
  43049. return nil
  43050. case whatsapp.FieldUpdatedAt:
  43051. v, ok := value.(time.Time)
  43052. if !ok {
  43053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43054. }
  43055. m.SetUpdatedAt(v)
  43056. return nil
  43057. case whatsapp.FieldStatus:
  43058. v, ok := value.(uint8)
  43059. if !ok {
  43060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43061. }
  43062. m.SetStatus(v)
  43063. return nil
  43064. case whatsapp.FieldDeletedAt:
  43065. v, ok := value.(time.Time)
  43066. if !ok {
  43067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43068. }
  43069. m.SetDeletedAt(v)
  43070. return nil
  43071. case whatsapp.FieldWaID:
  43072. v, ok := value.(string)
  43073. if !ok {
  43074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43075. }
  43076. m.SetWaID(v)
  43077. return nil
  43078. case whatsapp.FieldWaName:
  43079. v, ok := value.(string)
  43080. if !ok {
  43081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43082. }
  43083. m.SetWaName(v)
  43084. return nil
  43085. case whatsapp.FieldCallback:
  43086. v, ok := value.(string)
  43087. if !ok {
  43088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43089. }
  43090. m.SetCallback(v)
  43091. return nil
  43092. case whatsapp.FieldAgentID:
  43093. v, ok := value.(uint64)
  43094. if !ok {
  43095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43096. }
  43097. m.SetAgentID(v)
  43098. return nil
  43099. case whatsapp.FieldAccount:
  43100. v, ok := value.(string)
  43101. if !ok {
  43102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43103. }
  43104. m.SetAccount(v)
  43105. return nil
  43106. case whatsapp.FieldCc:
  43107. v, ok := value.(string)
  43108. if !ok {
  43109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43110. }
  43111. m.SetCc(v)
  43112. return nil
  43113. case whatsapp.FieldPhone:
  43114. v, ok := value.(string)
  43115. if !ok {
  43116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43117. }
  43118. m.SetPhone(v)
  43119. return nil
  43120. case whatsapp.FieldCcPhone:
  43121. v, ok := value.(string)
  43122. if !ok {
  43123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43124. }
  43125. m.SetCcPhone(v)
  43126. return nil
  43127. case whatsapp.FieldPhoneName:
  43128. v, ok := value.(string)
  43129. if !ok {
  43130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43131. }
  43132. m.SetPhoneName(v)
  43133. return nil
  43134. case whatsapp.FieldPhoneStatus:
  43135. v, ok := value.(int8)
  43136. if !ok {
  43137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43138. }
  43139. m.SetPhoneStatus(v)
  43140. return nil
  43141. case whatsapp.FieldOrganizationID:
  43142. v, ok := value.(uint64)
  43143. if !ok {
  43144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43145. }
  43146. m.SetOrganizationID(v)
  43147. return nil
  43148. case whatsapp.FieldAPIBase:
  43149. v, ok := value.(string)
  43150. if !ok {
  43151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43152. }
  43153. m.SetAPIBase(v)
  43154. return nil
  43155. case whatsapp.FieldAPIKey:
  43156. v, ok := value.(string)
  43157. if !ok {
  43158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43159. }
  43160. m.SetAPIKey(v)
  43161. return nil
  43162. case whatsapp.FieldAllowList:
  43163. v, ok := value.([]string)
  43164. if !ok {
  43165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43166. }
  43167. m.SetAllowList(v)
  43168. return nil
  43169. case whatsapp.FieldGroupAllowList:
  43170. v, ok := value.([]string)
  43171. if !ok {
  43172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43173. }
  43174. m.SetGroupAllowList(v)
  43175. return nil
  43176. case whatsapp.FieldBlockList:
  43177. v, ok := value.([]string)
  43178. if !ok {
  43179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43180. }
  43181. m.SetBlockList(v)
  43182. return nil
  43183. case whatsapp.FieldGroupBlockList:
  43184. v, ok := value.([]string)
  43185. if !ok {
  43186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43187. }
  43188. m.SetGroupBlockList(v)
  43189. return nil
  43190. }
  43191. return fmt.Errorf("unknown Whatsapp field %s", name)
  43192. }
  43193. // AddedFields returns all numeric fields that were incremented/decremented during
  43194. // this mutation.
  43195. func (m *WhatsappMutation) AddedFields() []string {
  43196. var fields []string
  43197. if m.addstatus != nil {
  43198. fields = append(fields, whatsapp.FieldStatus)
  43199. }
  43200. if m.addphone_status != nil {
  43201. fields = append(fields, whatsapp.FieldPhoneStatus)
  43202. }
  43203. if m.addorganization_id != nil {
  43204. fields = append(fields, whatsapp.FieldOrganizationID)
  43205. }
  43206. return fields
  43207. }
  43208. // AddedField returns the numeric value that was incremented/decremented on a field
  43209. // with the given name. The second boolean return value indicates that this field
  43210. // was not set, or was not defined in the schema.
  43211. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43212. switch name {
  43213. case whatsapp.FieldStatus:
  43214. return m.AddedStatus()
  43215. case whatsapp.FieldPhoneStatus:
  43216. return m.AddedPhoneStatus()
  43217. case whatsapp.FieldOrganizationID:
  43218. return m.AddedOrganizationID()
  43219. }
  43220. return nil, false
  43221. }
  43222. // AddField adds the value to the field with the given name. It returns an error if
  43223. // the field is not defined in the schema, or if the type mismatched the field
  43224. // type.
  43225. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43226. switch name {
  43227. case whatsapp.FieldStatus:
  43228. v, ok := value.(int8)
  43229. if !ok {
  43230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43231. }
  43232. m.AddStatus(v)
  43233. return nil
  43234. case whatsapp.FieldPhoneStatus:
  43235. v, ok := value.(int8)
  43236. if !ok {
  43237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43238. }
  43239. m.AddPhoneStatus(v)
  43240. return nil
  43241. case whatsapp.FieldOrganizationID:
  43242. v, ok := value.(int64)
  43243. if !ok {
  43244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43245. }
  43246. m.AddOrganizationID(v)
  43247. return nil
  43248. }
  43249. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43250. }
  43251. // ClearedFields returns all nullable fields that were cleared during this
  43252. // mutation.
  43253. func (m *WhatsappMutation) ClearedFields() []string {
  43254. var fields []string
  43255. if m.FieldCleared(whatsapp.FieldStatus) {
  43256. fields = append(fields, whatsapp.FieldStatus)
  43257. }
  43258. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43259. fields = append(fields, whatsapp.FieldDeletedAt)
  43260. }
  43261. if m.FieldCleared(whatsapp.FieldWaID) {
  43262. fields = append(fields, whatsapp.FieldWaID)
  43263. }
  43264. if m.FieldCleared(whatsapp.FieldWaName) {
  43265. fields = append(fields, whatsapp.FieldWaName)
  43266. }
  43267. if m.FieldCleared(whatsapp.FieldCallback) {
  43268. fields = append(fields, whatsapp.FieldCallback)
  43269. }
  43270. if m.FieldCleared(whatsapp.FieldAccount) {
  43271. fields = append(fields, whatsapp.FieldAccount)
  43272. }
  43273. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43274. fields = append(fields, whatsapp.FieldOrganizationID)
  43275. }
  43276. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43277. fields = append(fields, whatsapp.FieldAPIBase)
  43278. }
  43279. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43280. fields = append(fields, whatsapp.FieldAPIKey)
  43281. }
  43282. if m.FieldCleared(whatsapp.FieldAllowList) {
  43283. fields = append(fields, whatsapp.FieldAllowList)
  43284. }
  43285. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43286. fields = append(fields, whatsapp.FieldGroupAllowList)
  43287. }
  43288. if m.FieldCleared(whatsapp.FieldBlockList) {
  43289. fields = append(fields, whatsapp.FieldBlockList)
  43290. }
  43291. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43292. fields = append(fields, whatsapp.FieldGroupBlockList)
  43293. }
  43294. return fields
  43295. }
  43296. // FieldCleared returns a boolean indicating if a field with the given name was
  43297. // cleared in this mutation.
  43298. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43299. _, ok := m.clearedFields[name]
  43300. return ok
  43301. }
  43302. // ClearField clears the value of the field with the given name. It returns an
  43303. // error if the field is not defined in the schema.
  43304. func (m *WhatsappMutation) ClearField(name string) error {
  43305. switch name {
  43306. case whatsapp.FieldStatus:
  43307. m.ClearStatus()
  43308. return nil
  43309. case whatsapp.FieldDeletedAt:
  43310. m.ClearDeletedAt()
  43311. return nil
  43312. case whatsapp.FieldWaID:
  43313. m.ClearWaID()
  43314. return nil
  43315. case whatsapp.FieldWaName:
  43316. m.ClearWaName()
  43317. return nil
  43318. case whatsapp.FieldCallback:
  43319. m.ClearCallback()
  43320. return nil
  43321. case whatsapp.FieldAccount:
  43322. m.ClearAccount()
  43323. return nil
  43324. case whatsapp.FieldOrganizationID:
  43325. m.ClearOrganizationID()
  43326. return nil
  43327. case whatsapp.FieldAPIBase:
  43328. m.ClearAPIBase()
  43329. return nil
  43330. case whatsapp.FieldAPIKey:
  43331. m.ClearAPIKey()
  43332. return nil
  43333. case whatsapp.FieldAllowList:
  43334. m.ClearAllowList()
  43335. return nil
  43336. case whatsapp.FieldGroupAllowList:
  43337. m.ClearGroupAllowList()
  43338. return nil
  43339. case whatsapp.FieldBlockList:
  43340. m.ClearBlockList()
  43341. return nil
  43342. case whatsapp.FieldGroupBlockList:
  43343. m.ClearGroupBlockList()
  43344. return nil
  43345. }
  43346. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43347. }
  43348. // ResetField resets all changes in the mutation for the field with the given name.
  43349. // It returns an error if the field is not defined in the schema.
  43350. func (m *WhatsappMutation) ResetField(name string) error {
  43351. switch name {
  43352. case whatsapp.FieldCreatedAt:
  43353. m.ResetCreatedAt()
  43354. return nil
  43355. case whatsapp.FieldUpdatedAt:
  43356. m.ResetUpdatedAt()
  43357. return nil
  43358. case whatsapp.FieldStatus:
  43359. m.ResetStatus()
  43360. return nil
  43361. case whatsapp.FieldDeletedAt:
  43362. m.ResetDeletedAt()
  43363. return nil
  43364. case whatsapp.FieldWaID:
  43365. m.ResetWaID()
  43366. return nil
  43367. case whatsapp.FieldWaName:
  43368. m.ResetWaName()
  43369. return nil
  43370. case whatsapp.FieldCallback:
  43371. m.ResetCallback()
  43372. return nil
  43373. case whatsapp.FieldAgentID:
  43374. m.ResetAgentID()
  43375. return nil
  43376. case whatsapp.FieldAccount:
  43377. m.ResetAccount()
  43378. return nil
  43379. case whatsapp.FieldCc:
  43380. m.ResetCc()
  43381. return nil
  43382. case whatsapp.FieldPhone:
  43383. m.ResetPhone()
  43384. return nil
  43385. case whatsapp.FieldCcPhone:
  43386. m.ResetCcPhone()
  43387. return nil
  43388. case whatsapp.FieldPhoneName:
  43389. m.ResetPhoneName()
  43390. return nil
  43391. case whatsapp.FieldPhoneStatus:
  43392. m.ResetPhoneStatus()
  43393. return nil
  43394. case whatsapp.FieldOrganizationID:
  43395. m.ResetOrganizationID()
  43396. return nil
  43397. case whatsapp.FieldAPIBase:
  43398. m.ResetAPIBase()
  43399. return nil
  43400. case whatsapp.FieldAPIKey:
  43401. m.ResetAPIKey()
  43402. return nil
  43403. case whatsapp.FieldAllowList:
  43404. m.ResetAllowList()
  43405. return nil
  43406. case whatsapp.FieldGroupAllowList:
  43407. m.ResetGroupAllowList()
  43408. return nil
  43409. case whatsapp.FieldBlockList:
  43410. m.ResetBlockList()
  43411. return nil
  43412. case whatsapp.FieldGroupBlockList:
  43413. m.ResetGroupBlockList()
  43414. return nil
  43415. }
  43416. return fmt.Errorf("unknown Whatsapp field %s", name)
  43417. }
  43418. // AddedEdges returns all edge names that were set/added in this mutation.
  43419. func (m *WhatsappMutation) AddedEdges() []string {
  43420. edges := make([]string, 0, 1)
  43421. if m.agent != nil {
  43422. edges = append(edges, whatsapp.EdgeAgent)
  43423. }
  43424. return edges
  43425. }
  43426. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43427. // name in this mutation.
  43428. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43429. switch name {
  43430. case whatsapp.EdgeAgent:
  43431. if id := m.agent; id != nil {
  43432. return []ent.Value{*id}
  43433. }
  43434. }
  43435. return nil
  43436. }
  43437. // RemovedEdges returns all edge names that were removed in this mutation.
  43438. func (m *WhatsappMutation) RemovedEdges() []string {
  43439. edges := make([]string, 0, 1)
  43440. return edges
  43441. }
  43442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43443. // the given name in this mutation.
  43444. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43445. return nil
  43446. }
  43447. // ClearedEdges returns all edge names that were cleared in this mutation.
  43448. func (m *WhatsappMutation) ClearedEdges() []string {
  43449. edges := make([]string, 0, 1)
  43450. if m.clearedagent {
  43451. edges = append(edges, whatsapp.EdgeAgent)
  43452. }
  43453. return edges
  43454. }
  43455. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43456. // was cleared in this mutation.
  43457. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43458. switch name {
  43459. case whatsapp.EdgeAgent:
  43460. return m.clearedagent
  43461. }
  43462. return false
  43463. }
  43464. // ClearEdge clears the value of the edge with the given name. It returns an error
  43465. // if that edge is not defined in the schema.
  43466. func (m *WhatsappMutation) ClearEdge(name string) error {
  43467. switch name {
  43468. case whatsapp.EdgeAgent:
  43469. m.ClearAgent()
  43470. return nil
  43471. }
  43472. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43473. }
  43474. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43475. // It returns an error if the edge is not defined in the schema.
  43476. func (m *WhatsappMutation) ResetEdge(name string) error {
  43477. switch name {
  43478. case whatsapp.EdgeAgent:
  43479. m.ResetAgent()
  43480. return nil
  43481. }
  43482. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43483. }
  43484. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43485. type WhatsappChannelMutation struct {
  43486. config
  43487. op Op
  43488. typ string
  43489. id *uint64
  43490. created_at *time.Time
  43491. updated_at *time.Time
  43492. status *uint8
  43493. addstatus *int8
  43494. deleted_at *time.Time
  43495. ak *string
  43496. sk *string
  43497. wa_id *string
  43498. wa_name *string
  43499. waba_id *uint64
  43500. addwaba_id *int64
  43501. business_id *uint64
  43502. addbusiness_id *int64
  43503. organization_id *uint64
  43504. addorganization_id *int64
  43505. verify_account *string
  43506. clearedFields map[string]struct{}
  43507. done bool
  43508. oldValue func(context.Context) (*WhatsappChannel, error)
  43509. predicates []predicate.WhatsappChannel
  43510. }
  43511. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43512. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43513. type whatsappchannelOption func(*WhatsappChannelMutation)
  43514. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43515. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43516. m := &WhatsappChannelMutation{
  43517. config: c,
  43518. op: op,
  43519. typ: TypeWhatsappChannel,
  43520. clearedFields: make(map[string]struct{}),
  43521. }
  43522. for _, opt := range opts {
  43523. opt(m)
  43524. }
  43525. return m
  43526. }
  43527. // withWhatsappChannelID sets the ID field of the mutation.
  43528. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43529. return func(m *WhatsappChannelMutation) {
  43530. var (
  43531. err error
  43532. once sync.Once
  43533. value *WhatsappChannel
  43534. )
  43535. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43536. once.Do(func() {
  43537. if m.done {
  43538. err = errors.New("querying old values post mutation is not allowed")
  43539. } else {
  43540. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43541. }
  43542. })
  43543. return value, err
  43544. }
  43545. m.id = &id
  43546. }
  43547. }
  43548. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43549. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43550. return func(m *WhatsappChannelMutation) {
  43551. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43552. return node, nil
  43553. }
  43554. m.id = &node.ID
  43555. }
  43556. }
  43557. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43558. // executed in a transaction (ent.Tx), a transactional client is returned.
  43559. func (m WhatsappChannelMutation) Client() *Client {
  43560. client := &Client{config: m.config}
  43561. client.init()
  43562. return client
  43563. }
  43564. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43565. // it returns an error otherwise.
  43566. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43567. if _, ok := m.driver.(*txDriver); !ok {
  43568. return nil, errors.New("ent: mutation is not running in a transaction")
  43569. }
  43570. tx := &Tx{config: m.config}
  43571. tx.init()
  43572. return tx, nil
  43573. }
  43574. // SetID sets the value of the id field. Note that this
  43575. // operation is only accepted on creation of WhatsappChannel entities.
  43576. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43577. m.id = &id
  43578. }
  43579. // ID returns the ID value in the mutation. Note that the ID is only available
  43580. // if it was provided to the builder or after it was returned from the database.
  43581. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43582. if m.id == nil {
  43583. return
  43584. }
  43585. return *m.id, true
  43586. }
  43587. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43588. // That means, if the mutation is applied within a transaction with an isolation level such
  43589. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43590. // or updated by the mutation.
  43591. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43592. switch {
  43593. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43594. id, exists := m.ID()
  43595. if exists {
  43596. return []uint64{id}, nil
  43597. }
  43598. fallthrough
  43599. case m.op.Is(OpUpdate | OpDelete):
  43600. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43601. default:
  43602. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43603. }
  43604. }
  43605. // SetCreatedAt sets the "created_at" field.
  43606. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43607. m.created_at = &t
  43608. }
  43609. // CreatedAt returns the value of the "created_at" field in the mutation.
  43610. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43611. v := m.created_at
  43612. if v == nil {
  43613. return
  43614. }
  43615. return *v, true
  43616. }
  43617. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43618. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43620. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43621. if !m.op.Is(OpUpdateOne) {
  43622. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43623. }
  43624. if m.id == nil || m.oldValue == nil {
  43625. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43626. }
  43627. oldValue, err := m.oldValue(ctx)
  43628. if err != nil {
  43629. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43630. }
  43631. return oldValue.CreatedAt, nil
  43632. }
  43633. // ResetCreatedAt resets all changes to the "created_at" field.
  43634. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43635. m.created_at = nil
  43636. }
  43637. // SetUpdatedAt sets the "updated_at" field.
  43638. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43639. m.updated_at = &t
  43640. }
  43641. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43642. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43643. v := m.updated_at
  43644. if v == nil {
  43645. return
  43646. }
  43647. return *v, true
  43648. }
  43649. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43650. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43652. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43653. if !m.op.Is(OpUpdateOne) {
  43654. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43655. }
  43656. if m.id == nil || m.oldValue == nil {
  43657. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43658. }
  43659. oldValue, err := m.oldValue(ctx)
  43660. if err != nil {
  43661. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43662. }
  43663. return oldValue.UpdatedAt, nil
  43664. }
  43665. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43666. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43667. m.updated_at = nil
  43668. }
  43669. // SetStatus sets the "status" field.
  43670. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43671. m.status = &u
  43672. m.addstatus = nil
  43673. }
  43674. // Status returns the value of the "status" field in the mutation.
  43675. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43676. v := m.status
  43677. if v == nil {
  43678. return
  43679. }
  43680. return *v, true
  43681. }
  43682. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43683. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43685. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43686. if !m.op.Is(OpUpdateOne) {
  43687. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43688. }
  43689. if m.id == nil || m.oldValue == nil {
  43690. return v, errors.New("OldStatus requires an ID field in the mutation")
  43691. }
  43692. oldValue, err := m.oldValue(ctx)
  43693. if err != nil {
  43694. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43695. }
  43696. return oldValue.Status, nil
  43697. }
  43698. // AddStatus adds u to the "status" field.
  43699. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43700. if m.addstatus != nil {
  43701. *m.addstatus += u
  43702. } else {
  43703. m.addstatus = &u
  43704. }
  43705. }
  43706. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43707. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43708. v := m.addstatus
  43709. if v == nil {
  43710. return
  43711. }
  43712. return *v, true
  43713. }
  43714. // ClearStatus clears the value of the "status" field.
  43715. func (m *WhatsappChannelMutation) ClearStatus() {
  43716. m.status = nil
  43717. m.addstatus = nil
  43718. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43719. }
  43720. // StatusCleared returns if the "status" field was cleared in this mutation.
  43721. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43722. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43723. return ok
  43724. }
  43725. // ResetStatus resets all changes to the "status" field.
  43726. func (m *WhatsappChannelMutation) ResetStatus() {
  43727. m.status = nil
  43728. m.addstatus = nil
  43729. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43730. }
  43731. // SetDeletedAt sets the "deleted_at" field.
  43732. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43733. m.deleted_at = &t
  43734. }
  43735. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43736. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43737. v := m.deleted_at
  43738. if v == nil {
  43739. return
  43740. }
  43741. return *v, true
  43742. }
  43743. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43744. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43746. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43747. if !m.op.Is(OpUpdateOne) {
  43748. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43749. }
  43750. if m.id == nil || m.oldValue == nil {
  43751. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43752. }
  43753. oldValue, err := m.oldValue(ctx)
  43754. if err != nil {
  43755. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43756. }
  43757. return oldValue.DeletedAt, nil
  43758. }
  43759. // ClearDeletedAt clears the value of the "deleted_at" field.
  43760. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43761. m.deleted_at = nil
  43762. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43763. }
  43764. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43765. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43766. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  43767. return ok
  43768. }
  43769. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43770. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  43771. m.deleted_at = nil
  43772. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  43773. }
  43774. // SetAk sets the "ak" field.
  43775. func (m *WhatsappChannelMutation) SetAk(s string) {
  43776. m.ak = &s
  43777. }
  43778. // Ak returns the value of the "ak" field in the mutation.
  43779. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  43780. v := m.ak
  43781. if v == nil {
  43782. return
  43783. }
  43784. return *v, true
  43785. }
  43786. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  43787. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43789. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  43790. if !m.op.Is(OpUpdateOne) {
  43791. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  43792. }
  43793. if m.id == nil || m.oldValue == nil {
  43794. return v, errors.New("OldAk requires an ID field in the mutation")
  43795. }
  43796. oldValue, err := m.oldValue(ctx)
  43797. if err != nil {
  43798. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  43799. }
  43800. return oldValue.Ak, nil
  43801. }
  43802. // ClearAk clears the value of the "ak" field.
  43803. func (m *WhatsappChannelMutation) ClearAk() {
  43804. m.ak = nil
  43805. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  43806. }
  43807. // AkCleared returns if the "ak" field was cleared in this mutation.
  43808. func (m *WhatsappChannelMutation) AkCleared() bool {
  43809. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  43810. return ok
  43811. }
  43812. // ResetAk resets all changes to the "ak" field.
  43813. func (m *WhatsappChannelMutation) ResetAk() {
  43814. m.ak = nil
  43815. delete(m.clearedFields, whatsappchannel.FieldAk)
  43816. }
  43817. // SetSk sets the "sk" field.
  43818. func (m *WhatsappChannelMutation) SetSk(s string) {
  43819. m.sk = &s
  43820. }
  43821. // Sk returns the value of the "sk" field in the mutation.
  43822. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  43823. v := m.sk
  43824. if v == nil {
  43825. return
  43826. }
  43827. return *v, true
  43828. }
  43829. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  43830. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43832. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  43833. if !m.op.Is(OpUpdateOne) {
  43834. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  43835. }
  43836. if m.id == nil || m.oldValue == nil {
  43837. return v, errors.New("OldSk requires an ID field in the mutation")
  43838. }
  43839. oldValue, err := m.oldValue(ctx)
  43840. if err != nil {
  43841. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  43842. }
  43843. return oldValue.Sk, nil
  43844. }
  43845. // ResetSk resets all changes to the "sk" field.
  43846. func (m *WhatsappChannelMutation) ResetSk() {
  43847. m.sk = nil
  43848. }
  43849. // SetWaID sets the "wa_id" field.
  43850. func (m *WhatsappChannelMutation) SetWaID(s string) {
  43851. m.wa_id = &s
  43852. }
  43853. // WaID returns the value of the "wa_id" field in the mutation.
  43854. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  43855. v := m.wa_id
  43856. if v == nil {
  43857. return
  43858. }
  43859. return *v, true
  43860. }
  43861. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  43862. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43864. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  43865. if !m.op.Is(OpUpdateOne) {
  43866. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  43867. }
  43868. if m.id == nil || m.oldValue == nil {
  43869. return v, errors.New("OldWaID requires an ID field in the mutation")
  43870. }
  43871. oldValue, err := m.oldValue(ctx)
  43872. if err != nil {
  43873. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  43874. }
  43875. return oldValue.WaID, nil
  43876. }
  43877. // ClearWaID clears the value of the "wa_id" field.
  43878. func (m *WhatsappChannelMutation) ClearWaID() {
  43879. m.wa_id = nil
  43880. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  43881. }
  43882. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  43883. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  43884. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  43885. return ok
  43886. }
  43887. // ResetWaID resets all changes to the "wa_id" field.
  43888. func (m *WhatsappChannelMutation) ResetWaID() {
  43889. m.wa_id = nil
  43890. delete(m.clearedFields, whatsappchannel.FieldWaID)
  43891. }
  43892. // SetWaName sets the "wa_name" field.
  43893. func (m *WhatsappChannelMutation) SetWaName(s string) {
  43894. m.wa_name = &s
  43895. }
  43896. // WaName returns the value of the "wa_name" field in the mutation.
  43897. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  43898. v := m.wa_name
  43899. if v == nil {
  43900. return
  43901. }
  43902. return *v, true
  43903. }
  43904. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  43905. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43907. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  43908. if !m.op.Is(OpUpdateOne) {
  43909. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  43910. }
  43911. if m.id == nil || m.oldValue == nil {
  43912. return v, errors.New("OldWaName requires an ID field in the mutation")
  43913. }
  43914. oldValue, err := m.oldValue(ctx)
  43915. if err != nil {
  43916. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  43917. }
  43918. return oldValue.WaName, nil
  43919. }
  43920. // ClearWaName clears the value of the "wa_name" field.
  43921. func (m *WhatsappChannelMutation) ClearWaName() {
  43922. m.wa_name = nil
  43923. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  43924. }
  43925. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  43926. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  43927. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  43928. return ok
  43929. }
  43930. // ResetWaName resets all changes to the "wa_name" field.
  43931. func (m *WhatsappChannelMutation) ResetWaName() {
  43932. m.wa_name = nil
  43933. delete(m.clearedFields, whatsappchannel.FieldWaName)
  43934. }
  43935. // SetWabaID sets the "waba_id" field.
  43936. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  43937. m.waba_id = &u
  43938. m.addwaba_id = nil
  43939. }
  43940. // WabaID returns the value of the "waba_id" field in the mutation.
  43941. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  43942. v := m.waba_id
  43943. if v == nil {
  43944. return
  43945. }
  43946. return *v, true
  43947. }
  43948. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  43949. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43951. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  43952. if !m.op.Is(OpUpdateOne) {
  43953. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  43954. }
  43955. if m.id == nil || m.oldValue == nil {
  43956. return v, errors.New("OldWabaID requires an ID field in the mutation")
  43957. }
  43958. oldValue, err := m.oldValue(ctx)
  43959. if err != nil {
  43960. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  43961. }
  43962. return oldValue.WabaID, nil
  43963. }
  43964. // AddWabaID adds u to the "waba_id" field.
  43965. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  43966. if m.addwaba_id != nil {
  43967. *m.addwaba_id += u
  43968. } else {
  43969. m.addwaba_id = &u
  43970. }
  43971. }
  43972. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  43973. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  43974. v := m.addwaba_id
  43975. if v == nil {
  43976. return
  43977. }
  43978. return *v, true
  43979. }
  43980. // ResetWabaID resets all changes to the "waba_id" field.
  43981. func (m *WhatsappChannelMutation) ResetWabaID() {
  43982. m.waba_id = nil
  43983. m.addwaba_id = nil
  43984. }
  43985. // SetBusinessID sets the "business_id" field.
  43986. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  43987. m.business_id = &u
  43988. m.addbusiness_id = nil
  43989. }
  43990. // BusinessID returns the value of the "business_id" field in the mutation.
  43991. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  43992. v := m.business_id
  43993. if v == nil {
  43994. return
  43995. }
  43996. return *v, true
  43997. }
  43998. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  43999. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44001. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  44002. if !m.op.Is(OpUpdateOne) {
  44003. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  44004. }
  44005. if m.id == nil || m.oldValue == nil {
  44006. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  44007. }
  44008. oldValue, err := m.oldValue(ctx)
  44009. if err != nil {
  44010. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  44011. }
  44012. return oldValue.BusinessID, nil
  44013. }
  44014. // AddBusinessID adds u to the "business_id" field.
  44015. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  44016. if m.addbusiness_id != nil {
  44017. *m.addbusiness_id += u
  44018. } else {
  44019. m.addbusiness_id = &u
  44020. }
  44021. }
  44022. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  44023. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  44024. v := m.addbusiness_id
  44025. if v == nil {
  44026. return
  44027. }
  44028. return *v, true
  44029. }
  44030. // ResetBusinessID resets all changes to the "business_id" field.
  44031. func (m *WhatsappChannelMutation) ResetBusinessID() {
  44032. m.business_id = nil
  44033. m.addbusiness_id = nil
  44034. }
  44035. // SetOrganizationID sets the "organization_id" field.
  44036. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  44037. m.organization_id = &u
  44038. m.addorganization_id = nil
  44039. }
  44040. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44041. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  44042. v := m.organization_id
  44043. if v == nil {
  44044. return
  44045. }
  44046. return *v, true
  44047. }
  44048. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  44049. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44051. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44052. if !m.op.Is(OpUpdateOne) {
  44053. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44054. }
  44055. if m.id == nil || m.oldValue == nil {
  44056. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44057. }
  44058. oldValue, err := m.oldValue(ctx)
  44059. if err != nil {
  44060. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44061. }
  44062. return oldValue.OrganizationID, nil
  44063. }
  44064. // AddOrganizationID adds u to the "organization_id" field.
  44065. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  44066. if m.addorganization_id != nil {
  44067. *m.addorganization_id += u
  44068. } else {
  44069. m.addorganization_id = &u
  44070. }
  44071. }
  44072. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44073. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  44074. v := m.addorganization_id
  44075. if v == nil {
  44076. return
  44077. }
  44078. return *v, true
  44079. }
  44080. // ClearOrganizationID clears the value of the "organization_id" field.
  44081. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  44082. m.organization_id = nil
  44083. m.addorganization_id = nil
  44084. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  44085. }
  44086. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44087. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  44088. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  44089. return ok
  44090. }
  44091. // ResetOrganizationID resets all changes to the "organization_id" field.
  44092. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  44093. m.organization_id = nil
  44094. m.addorganization_id = nil
  44095. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  44096. }
  44097. // SetVerifyAccount sets the "verify_account" field.
  44098. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  44099. m.verify_account = &s
  44100. }
  44101. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  44102. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  44103. v := m.verify_account
  44104. if v == nil {
  44105. return
  44106. }
  44107. return *v, true
  44108. }
  44109. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  44110. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44112. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  44113. if !m.op.Is(OpUpdateOne) {
  44114. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  44115. }
  44116. if m.id == nil || m.oldValue == nil {
  44117. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  44118. }
  44119. oldValue, err := m.oldValue(ctx)
  44120. if err != nil {
  44121. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  44122. }
  44123. return oldValue.VerifyAccount, nil
  44124. }
  44125. // ResetVerifyAccount resets all changes to the "verify_account" field.
  44126. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  44127. m.verify_account = nil
  44128. }
  44129. // Where appends a list predicates to the WhatsappChannelMutation builder.
  44130. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44131. m.predicates = append(m.predicates, ps...)
  44132. }
  44133. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44134. // users can use type-assertion to append predicates that do not depend on any generated package.
  44135. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44136. p := make([]predicate.WhatsappChannel, len(ps))
  44137. for i := range ps {
  44138. p[i] = ps[i]
  44139. }
  44140. m.Where(p...)
  44141. }
  44142. // Op returns the operation name.
  44143. func (m *WhatsappChannelMutation) Op() Op {
  44144. return m.op
  44145. }
  44146. // SetOp allows setting the mutation operation.
  44147. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44148. m.op = op
  44149. }
  44150. // Type returns the node type of this mutation (WhatsappChannel).
  44151. func (m *WhatsappChannelMutation) Type() string {
  44152. return m.typ
  44153. }
  44154. // Fields returns all fields that were changed during this mutation. Note that in
  44155. // order to get all numeric fields that were incremented/decremented, call
  44156. // AddedFields().
  44157. func (m *WhatsappChannelMutation) Fields() []string {
  44158. fields := make([]string, 0, 12)
  44159. if m.created_at != nil {
  44160. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44161. }
  44162. if m.updated_at != nil {
  44163. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44164. }
  44165. if m.status != nil {
  44166. fields = append(fields, whatsappchannel.FieldStatus)
  44167. }
  44168. if m.deleted_at != nil {
  44169. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44170. }
  44171. if m.ak != nil {
  44172. fields = append(fields, whatsappchannel.FieldAk)
  44173. }
  44174. if m.sk != nil {
  44175. fields = append(fields, whatsappchannel.FieldSk)
  44176. }
  44177. if m.wa_id != nil {
  44178. fields = append(fields, whatsappchannel.FieldWaID)
  44179. }
  44180. if m.wa_name != nil {
  44181. fields = append(fields, whatsappchannel.FieldWaName)
  44182. }
  44183. if m.waba_id != nil {
  44184. fields = append(fields, whatsappchannel.FieldWabaID)
  44185. }
  44186. if m.business_id != nil {
  44187. fields = append(fields, whatsappchannel.FieldBusinessID)
  44188. }
  44189. if m.organization_id != nil {
  44190. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44191. }
  44192. if m.verify_account != nil {
  44193. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44194. }
  44195. return fields
  44196. }
  44197. // Field returns the value of a field with the given name. The second boolean
  44198. // return value indicates that this field was not set, or was not defined in the
  44199. // schema.
  44200. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44201. switch name {
  44202. case whatsappchannel.FieldCreatedAt:
  44203. return m.CreatedAt()
  44204. case whatsappchannel.FieldUpdatedAt:
  44205. return m.UpdatedAt()
  44206. case whatsappchannel.FieldStatus:
  44207. return m.Status()
  44208. case whatsappchannel.FieldDeletedAt:
  44209. return m.DeletedAt()
  44210. case whatsappchannel.FieldAk:
  44211. return m.Ak()
  44212. case whatsappchannel.FieldSk:
  44213. return m.Sk()
  44214. case whatsappchannel.FieldWaID:
  44215. return m.WaID()
  44216. case whatsappchannel.FieldWaName:
  44217. return m.WaName()
  44218. case whatsappchannel.FieldWabaID:
  44219. return m.WabaID()
  44220. case whatsappchannel.FieldBusinessID:
  44221. return m.BusinessID()
  44222. case whatsappchannel.FieldOrganizationID:
  44223. return m.OrganizationID()
  44224. case whatsappchannel.FieldVerifyAccount:
  44225. return m.VerifyAccount()
  44226. }
  44227. return nil, false
  44228. }
  44229. // OldField returns the old value of the field from the database. An error is
  44230. // returned if the mutation operation is not UpdateOne, or the query to the
  44231. // database failed.
  44232. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44233. switch name {
  44234. case whatsappchannel.FieldCreatedAt:
  44235. return m.OldCreatedAt(ctx)
  44236. case whatsappchannel.FieldUpdatedAt:
  44237. return m.OldUpdatedAt(ctx)
  44238. case whatsappchannel.FieldStatus:
  44239. return m.OldStatus(ctx)
  44240. case whatsappchannel.FieldDeletedAt:
  44241. return m.OldDeletedAt(ctx)
  44242. case whatsappchannel.FieldAk:
  44243. return m.OldAk(ctx)
  44244. case whatsappchannel.FieldSk:
  44245. return m.OldSk(ctx)
  44246. case whatsappchannel.FieldWaID:
  44247. return m.OldWaID(ctx)
  44248. case whatsappchannel.FieldWaName:
  44249. return m.OldWaName(ctx)
  44250. case whatsappchannel.FieldWabaID:
  44251. return m.OldWabaID(ctx)
  44252. case whatsappchannel.FieldBusinessID:
  44253. return m.OldBusinessID(ctx)
  44254. case whatsappchannel.FieldOrganizationID:
  44255. return m.OldOrganizationID(ctx)
  44256. case whatsappchannel.FieldVerifyAccount:
  44257. return m.OldVerifyAccount(ctx)
  44258. }
  44259. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44260. }
  44261. // SetField sets the value of a field with the given name. It returns an error if
  44262. // the field is not defined in the schema, or if the type mismatched the field
  44263. // type.
  44264. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44265. switch name {
  44266. case whatsappchannel.FieldCreatedAt:
  44267. v, ok := value.(time.Time)
  44268. if !ok {
  44269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44270. }
  44271. m.SetCreatedAt(v)
  44272. return nil
  44273. case whatsappchannel.FieldUpdatedAt:
  44274. v, ok := value.(time.Time)
  44275. if !ok {
  44276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44277. }
  44278. m.SetUpdatedAt(v)
  44279. return nil
  44280. case whatsappchannel.FieldStatus:
  44281. v, ok := value.(uint8)
  44282. if !ok {
  44283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44284. }
  44285. m.SetStatus(v)
  44286. return nil
  44287. case whatsappchannel.FieldDeletedAt:
  44288. v, ok := value.(time.Time)
  44289. if !ok {
  44290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44291. }
  44292. m.SetDeletedAt(v)
  44293. return nil
  44294. case whatsappchannel.FieldAk:
  44295. v, ok := value.(string)
  44296. if !ok {
  44297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44298. }
  44299. m.SetAk(v)
  44300. return nil
  44301. case whatsappchannel.FieldSk:
  44302. v, ok := value.(string)
  44303. if !ok {
  44304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44305. }
  44306. m.SetSk(v)
  44307. return nil
  44308. case whatsappchannel.FieldWaID:
  44309. v, ok := value.(string)
  44310. if !ok {
  44311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44312. }
  44313. m.SetWaID(v)
  44314. return nil
  44315. case whatsappchannel.FieldWaName:
  44316. v, ok := value.(string)
  44317. if !ok {
  44318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44319. }
  44320. m.SetWaName(v)
  44321. return nil
  44322. case whatsappchannel.FieldWabaID:
  44323. v, ok := value.(uint64)
  44324. if !ok {
  44325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44326. }
  44327. m.SetWabaID(v)
  44328. return nil
  44329. case whatsappchannel.FieldBusinessID:
  44330. v, ok := value.(uint64)
  44331. if !ok {
  44332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44333. }
  44334. m.SetBusinessID(v)
  44335. return nil
  44336. case whatsappchannel.FieldOrganizationID:
  44337. v, ok := value.(uint64)
  44338. if !ok {
  44339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44340. }
  44341. m.SetOrganizationID(v)
  44342. return nil
  44343. case whatsappchannel.FieldVerifyAccount:
  44344. v, ok := value.(string)
  44345. if !ok {
  44346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44347. }
  44348. m.SetVerifyAccount(v)
  44349. return nil
  44350. }
  44351. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44352. }
  44353. // AddedFields returns all numeric fields that were incremented/decremented during
  44354. // this mutation.
  44355. func (m *WhatsappChannelMutation) AddedFields() []string {
  44356. var fields []string
  44357. if m.addstatus != nil {
  44358. fields = append(fields, whatsappchannel.FieldStatus)
  44359. }
  44360. if m.addwaba_id != nil {
  44361. fields = append(fields, whatsappchannel.FieldWabaID)
  44362. }
  44363. if m.addbusiness_id != nil {
  44364. fields = append(fields, whatsappchannel.FieldBusinessID)
  44365. }
  44366. if m.addorganization_id != nil {
  44367. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44368. }
  44369. return fields
  44370. }
  44371. // AddedField returns the numeric value that was incremented/decremented on a field
  44372. // with the given name. The second boolean return value indicates that this field
  44373. // was not set, or was not defined in the schema.
  44374. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44375. switch name {
  44376. case whatsappchannel.FieldStatus:
  44377. return m.AddedStatus()
  44378. case whatsappchannel.FieldWabaID:
  44379. return m.AddedWabaID()
  44380. case whatsappchannel.FieldBusinessID:
  44381. return m.AddedBusinessID()
  44382. case whatsappchannel.FieldOrganizationID:
  44383. return m.AddedOrganizationID()
  44384. }
  44385. return nil, false
  44386. }
  44387. // AddField adds the value to the field with the given name. It returns an error if
  44388. // the field is not defined in the schema, or if the type mismatched the field
  44389. // type.
  44390. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44391. switch name {
  44392. case whatsappchannel.FieldStatus:
  44393. v, ok := value.(int8)
  44394. if !ok {
  44395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44396. }
  44397. m.AddStatus(v)
  44398. return nil
  44399. case whatsappchannel.FieldWabaID:
  44400. v, ok := value.(int64)
  44401. if !ok {
  44402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44403. }
  44404. m.AddWabaID(v)
  44405. return nil
  44406. case whatsappchannel.FieldBusinessID:
  44407. v, ok := value.(int64)
  44408. if !ok {
  44409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44410. }
  44411. m.AddBusinessID(v)
  44412. return nil
  44413. case whatsappchannel.FieldOrganizationID:
  44414. v, ok := value.(int64)
  44415. if !ok {
  44416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44417. }
  44418. m.AddOrganizationID(v)
  44419. return nil
  44420. }
  44421. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44422. }
  44423. // ClearedFields returns all nullable fields that were cleared during this
  44424. // mutation.
  44425. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44426. var fields []string
  44427. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44428. fields = append(fields, whatsappchannel.FieldStatus)
  44429. }
  44430. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44431. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44432. }
  44433. if m.FieldCleared(whatsappchannel.FieldAk) {
  44434. fields = append(fields, whatsappchannel.FieldAk)
  44435. }
  44436. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44437. fields = append(fields, whatsappchannel.FieldWaID)
  44438. }
  44439. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44440. fields = append(fields, whatsappchannel.FieldWaName)
  44441. }
  44442. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44443. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44444. }
  44445. return fields
  44446. }
  44447. // FieldCleared returns a boolean indicating if a field with the given name was
  44448. // cleared in this mutation.
  44449. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44450. _, ok := m.clearedFields[name]
  44451. return ok
  44452. }
  44453. // ClearField clears the value of the field with the given name. It returns an
  44454. // error if the field is not defined in the schema.
  44455. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44456. switch name {
  44457. case whatsappchannel.FieldStatus:
  44458. m.ClearStatus()
  44459. return nil
  44460. case whatsappchannel.FieldDeletedAt:
  44461. m.ClearDeletedAt()
  44462. return nil
  44463. case whatsappchannel.FieldAk:
  44464. m.ClearAk()
  44465. return nil
  44466. case whatsappchannel.FieldWaID:
  44467. m.ClearWaID()
  44468. return nil
  44469. case whatsappchannel.FieldWaName:
  44470. m.ClearWaName()
  44471. return nil
  44472. case whatsappchannel.FieldOrganizationID:
  44473. m.ClearOrganizationID()
  44474. return nil
  44475. }
  44476. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44477. }
  44478. // ResetField resets all changes in the mutation for the field with the given name.
  44479. // It returns an error if the field is not defined in the schema.
  44480. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44481. switch name {
  44482. case whatsappchannel.FieldCreatedAt:
  44483. m.ResetCreatedAt()
  44484. return nil
  44485. case whatsappchannel.FieldUpdatedAt:
  44486. m.ResetUpdatedAt()
  44487. return nil
  44488. case whatsappchannel.FieldStatus:
  44489. m.ResetStatus()
  44490. return nil
  44491. case whatsappchannel.FieldDeletedAt:
  44492. m.ResetDeletedAt()
  44493. return nil
  44494. case whatsappchannel.FieldAk:
  44495. m.ResetAk()
  44496. return nil
  44497. case whatsappchannel.FieldSk:
  44498. m.ResetSk()
  44499. return nil
  44500. case whatsappchannel.FieldWaID:
  44501. m.ResetWaID()
  44502. return nil
  44503. case whatsappchannel.FieldWaName:
  44504. m.ResetWaName()
  44505. return nil
  44506. case whatsappchannel.FieldWabaID:
  44507. m.ResetWabaID()
  44508. return nil
  44509. case whatsappchannel.FieldBusinessID:
  44510. m.ResetBusinessID()
  44511. return nil
  44512. case whatsappchannel.FieldOrganizationID:
  44513. m.ResetOrganizationID()
  44514. return nil
  44515. case whatsappchannel.FieldVerifyAccount:
  44516. m.ResetVerifyAccount()
  44517. return nil
  44518. }
  44519. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44520. }
  44521. // AddedEdges returns all edge names that were set/added in this mutation.
  44522. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44523. edges := make([]string, 0, 0)
  44524. return edges
  44525. }
  44526. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44527. // name in this mutation.
  44528. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44529. return nil
  44530. }
  44531. // RemovedEdges returns all edge names that were removed in this mutation.
  44532. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44533. edges := make([]string, 0, 0)
  44534. return edges
  44535. }
  44536. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44537. // the given name in this mutation.
  44538. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44539. return nil
  44540. }
  44541. // ClearedEdges returns all edge names that were cleared in this mutation.
  44542. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44543. edges := make([]string, 0, 0)
  44544. return edges
  44545. }
  44546. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44547. // was cleared in this mutation.
  44548. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44549. return false
  44550. }
  44551. // ClearEdge clears the value of the edge with the given name. It returns an error
  44552. // if that edge is not defined in the schema.
  44553. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44554. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44555. }
  44556. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44557. // It returns an error if the edge is not defined in the schema.
  44558. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44559. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44560. }
  44561. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44562. type WorkExperienceMutation struct {
  44563. config
  44564. op Op
  44565. typ string
  44566. id *uint64
  44567. created_at *time.Time
  44568. updated_at *time.Time
  44569. deleted_at *time.Time
  44570. start_date *time.Time
  44571. end_date *time.Time
  44572. company *string
  44573. experience *string
  44574. organization_id *uint64
  44575. addorganization_id *int64
  44576. clearedFields map[string]struct{}
  44577. employee *uint64
  44578. clearedemployee bool
  44579. done bool
  44580. oldValue func(context.Context) (*WorkExperience, error)
  44581. predicates []predicate.WorkExperience
  44582. }
  44583. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44584. // workexperienceOption allows management of the mutation configuration using functional options.
  44585. type workexperienceOption func(*WorkExperienceMutation)
  44586. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44587. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44588. m := &WorkExperienceMutation{
  44589. config: c,
  44590. op: op,
  44591. typ: TypeWorkExperience,
  44592. clearedFields: make(map[string]struct{}),
  44593. }
  44594. for _, opt := range opts {
  44595. opt(m)
  44596. }
  44597. return m
  44598. }
  44599. // withWorkExperienceID sets the ID field of the mutation.
  44600. func withWorkExperienceID(id uint64) workexperienceOption {
  44601. return func(m *WorkExperienceMutation) {
  44602. var (
  44603. err error
  44604. once sync.Once
  44605. value *WorkExperience
  44606. )
  44607. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44608. once.Do(func() {
  44609. if m.done {
  44610. err = errors.New("querying old values post mutation is not allowed")
  44611. } else {
  44612. value, err = m.Client().WorkExperience.Get(ctx, id)
  44613. }
  44614. })
  44615. return value, err
  44616. }
  44617. m.id = &id
  44618. }
  44619. }
  44620. // withWorkExperience sets the old WorkExperience of the mutation.
  44621. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44622. return func(m *WorkExperienceMutation) {
  44623. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44624. return node, nil
  44625. }
  44626. m.id = &node.ID
  44627. }
  44628. }
  44629. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44630. // executed in a transaction (ent.Tx), a transactional client is returned.
  44631. func (m WorkExperienceMutation) Client() *Client {
  44632. client := &Client{config: m.config}
  44633. client.init()
  44634. return client
  44635. }
  44636. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44637. // it returns an error otherwise.
  44638. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44639. if _, ok := m.driver.(*txDriver); !ok {
  44640. return nil, errors.New("ent: mutation is not running in a transaction")
  44641. }
  44642. tx := &Tx{config: m.config}
  44643. tx.init()
  44644. return tx, nil
  44645. }
  44646. // SetID sets the value of the id field. Note that this
  44647. // operation is only accepted on creation of WorkExperience entities.
  44648. func (m *WorkExperienceMutation) SetID(id uint64) {
  44649. m.id = &id
  44650. }
  44651. // ID returns the ID value in the mutation. Note that the ID is only available
  44652. // if it was provided to the builder or after it was returned from the database.
  44653. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44654. if m.id == nil {
  44655. return
  44656. }
  44657. return *m.id, true
  44658. }
  44659. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44660. // That means, if the mutation is applied within a transaction with an isolation level such
  44661. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44662. // or updated by the mutation.
  44663. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44664. switch {
  44665. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44666. id, exists := m.ID()
  44667. if exists {
  44668. return []uint64{id}, nil
  44669. }
  44670. fallthrough
  44671. case m.op.Is(OpUpdate | OpDelete):
  44672. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44673. default:
  44674. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44675. }
  44676. }
  44677. // SetCreatedAt sets the "created_at" field.
  44678. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44679. m.created_at = &t
  44680. }
  44681. // CreatedAt returns the value of the "created_at" field in the mutation.
  44682. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44683. v := m.created_at
  44684. if v == nil {
  44685. return
  44686. }
  44687. return *v, true
  44688. }
  44689. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44690. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44692. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44693. if !m.op.Is(OpUpdateOne) {
  44694. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44695. }
  44696. if m.id == nil || m.oldValue == nil {
  44697. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44698. }
  44699. oldValue, err := m.oldValue(ctx)
  44700. if err != nil {
  44701. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44702. }
  44703. return oldValue.CreatedAt, nil
  44704. }
  44705. // ResetCreatedAt resets all changes to the "created_at" field.
  44706. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44707. m.created_at = nil
  44708. }
  44709. // SetUpdatedAt sets the "updated_at" field.
  44710. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44711. m.updated_at = &t
  44712. }
  44713. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44714. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44715. v := m.updated_at
  44716. if v == nil {
  44717. return
  44718. }
  44719. return *v, true
  44720. }
  44721. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44722. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44724. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44725. if !m.op.Is(OpUpdateOne) {
  44726. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44727. }
  44728. if m.id == nil || m.oldValue == nil {
  44729. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44730. }
  44731. oldValue, err := m.oldValue(ctx)
  44732. if err != nil {
  44733. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44734. }
  44735. return oldValue.UpdatedAt, nil
  44736. }
  44737. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44738. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44739. m.updated_at = nil
  44740. }
  44741. // SetDeletedAt sets the "deleted_at" field.
  44742. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44743. m.deleted_at = &t
  44744. }
  44745. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44746. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44747. v := m.deleted_at
  44748. if v == nil {
  44749. return
  44750. }
  44751. return *v, true
  44752. }
  44753. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44754. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44756. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44757. if !m.op.Is(OpUpdateOne) {
  44758. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44759. }
  44760. if m.id == nil || m.oldValue == nil {
  44761. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44762. }
  44763. oldValue, err := m.oldValue(ctx)
  44764. if err != nil {
  44765. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44766. }
  44767. return oldValue.DeletedAt, nil
  44768. }
  44769. // ClearDeletedAt clears the value of the "deleted_at" field.
  44770. func (m *WorkExperienceMutation) ClearDeletedAt() {
  44771. m.deleted_at = nil
  44772. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  44773. }
  44774. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44775. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  44776. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  44777. return ok
  44778. }
  44779. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44780. func (m *WorkExperienceMutation) ResetDeletedAt() {
  44781. m.deleted_at = nil
  44782. delete(m.clearedFields, workexperience.FieldDeletedAt)
  44783. }
  44784. // SetEmployeeID sets the "employee_id" field.
  44785. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  44786. m.employee = &u
  44787. }
  44788. // EmployeeID returns the value of the "employee_id" field in the mutation.
  44789. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  44790. v := m.employee
  44791. if v == nil {
  44792. return
  44793. }
  44794. return *v, true
  44795. }
  44796. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  44797. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44799. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  44800. if !m.op.Is(OpUpdateOne) {
  44801. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  44802. }
  44803. if m.id == nil || m.oldValue == nil {
  44804. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  44805. }
  44806. oldValue, err := m.oldValue(ctx)
  44807. if err != nil {
  44808. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  44809. }
  44810. return oldValue.EmployeeID, nil
  44811. }
  44812. // ResetEmployeeID resets all changes to the "employee_id" field.
  44813. func (m *WorkExperienceMutation) ResetEmployeeID() {
  44814. m.employee = nil
  44815. }
  44816. // SetStartDate sets the "start_date" field.
  44817. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  44818. m.start_date = &t
  44819. }
  44820. // StartDate returns the value of the "start_date" field in the mutation.
  44821. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  44822. v := m.start_date
  44823. if v == nil {
  44824. return
  44825. }
  44826. return *v, true
  44827. }
  44828. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  44829. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44831. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  44832. if !m.op.Is(OpUpdateOne) {
  44833. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  44834. }
  44835. if m.id == nil || m.oldValue == nil {
  44836. return v, errors.New("OldStartDate requires an ID field in the mutation")
  44837. }
  44838. oldValue, err := m.oldValue(ctx)
  44839. if err != nil {
  44840. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  44841. }
  44842. return oldValue.StartDate, nil
  44843. }
  44844. // ResetStartDate resets all changes to the "start_date" field.
  44845. func (m *WorkExperienceMutation) ResetStartDate() {
  44846. m.start_date = nil
  44847. }
  44848. // SetEndDate sets the "end_date" field.
  44849. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  44850. m.end_date = &t
  44851. }
  44852. // EndDate returns the value of the "end_date" field in the mutation.
  44853. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  44854. v := m.end_date
  44855. if v == nil {
  44856. return
  44857. }
  44858. return *v, true
  44859. }
  44860. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  44861. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44863. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  44864. if !m.op.Is(OpUpdateOne) {
  44865. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  44866. }
  44867. if m.id == nil || m.oldValue == nil {
  44868. return v, errors.New("OldEndDate requires an ID field in the mutation")
  44869. }
  44870. oldValue, err := m.oldValue(ctx)
  44871. if err != nil {
  44872. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  44873. }
  44874. return oldValue.EndDate, nil
  44875. }
  44876. // ResetEndDate resets all changes to the "end_date" field.
  44877. func (m *WorkExperienceMutation) ResetEndDate() {
  44878. m.end_date = nil
  44879. }
  44880. // SetCompany sets the "company" field.
  44881. func (m *WorkExperienceMutation) SetCompany(s string) {
  44882. m.company = &s
  44883. }
  44884. // Company returns the value of the "company" field in the mutation.
  44885. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  44886. v := m.company
  44887. if v == nil {
  44888. return
  44889. }
  44890. return *v, true
  44891. }
  44892. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  44893. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44895. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  44896. if !m.op.Is(OpUpdateOne) {
  44897. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44898. }
  44899. if m.id == nil || m.oldValue == nil {
  44900. return v, errors.New("OldCompany requires an ID field in the mutation")
  44901. }
  44902. oldValue, err := m.oldValue(ctx)
  44903. if err != nil {
  44904. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44905. }
  44906. return oldValue.Company, nil
  44907. }
  44908. // ResetCompany resets all changes to the "company" field.
  44909. func (m *WorkExperienceMutation) ResetCompany() {
  44910. m.company = nil
  44911. }
  44912. // SetExperience sets the "experience" field.
  44913. func (m *WorkExperienceMutation) SetExperience(s string) {
  44914. m.experience = &s
  44915. }
  44916. // Experience returns the value of the "experience" field in the mutation.
  44917. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  44918. v := m.experience
  44919. if v == nil {
  44920. return
  44921. }
  44922. return *v, true
  44923. }
  44924. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  44925. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44927. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  44928. if !m.op.Is(OpUpdateOne) {
  44929. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  44930. }
  44931. if m.id == nil || m.oldValue == nil {
  44932. return v, errors.New("OldExperience requires an ID field in the mutation")
  44933. }
  44934. oldValue, err := m.oldValue(ctx)
  44935. if err != nil {
  44936. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  44937. }
  44938. return oldValue.Experience, nil
  44939. }
  44940. // ResetExperience resets all changes to the "experience" field.
  44941. func (m *WorkExperienceMutation) ResetExperience() {
  44942. m.experience = nil
  44943. }
  44944. // SetOrganizationID sets the "organization_id" field.
  44945. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  44946. m.organization_id = &u
  44947. m.addorganization_id = nil
  44948. }
  44949. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44950. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  44951. v := m.organization_id
  44952. if v == nil {
  44953. return
  44954. }
  44955. return *v, true
  44956. }
  44957. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  44958. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44960. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44961. if !m.op.Is(OpUpdateOne) {
  44962. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44963. }
  44964. if m.id == nil || m.oldValue == nil {
  44965. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44966. }
  44967. oldValue, err := m.oldValue(ctx)
  44968. if err != nil {
  44969. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44970. }
  44971. return oldValue.OrganizationID, nil
  44972. }
  44973. // AddOrganizationID adds u to the "organization_id" field.
  44974. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  44975. if m.addorganization_id != nil {
  44976. *m.addorganization_id += u
  44977. } else {
  44978. m.addorganization_id = &u
  44979. }
  44980. }
  44981. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44982. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  44983. v := m.addorganization_id
  44984. if v == nil {
  44985. return
  44986. }
  44987. return *v, true
  44988. }
  44989. // ResetOrganizationID resets all changes to the "organization_id" field.
  44990. func (m *WorkExperienceMutation) ResetOrganizationID() {
  44991. m.organization_id = nil
  44992. m.addorganization_id = nil
  44993. }
  44994. // ClearEmployee clears the "employee" edge to the Employee entity.
  44995. func (m *WorkExperienceMutation) ClearEmployee() {
  44996. m.clearedemployee = true
  44997. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  44998. }
  44999. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  45000. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  45001. return m.clearedemployee
  45002. }
  45003. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  45004. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45005. // EmployeeID instead. It exists only for internal usage by the builders.
  45006. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  45007. if id := m.employee; id != nil {
  45008. ids = append(ids, *id)
  45009. }
  45010. return
  45011. }
  45012. // ResetEmployee resets all changes to the "employee" edge.
  45013. func (m *WorkExperienceMutation) ResetEmployee() {
  45014. m.employee = nil
  45015. m.clearedemployee = false
  45016. }
  45017. // Where appends a list predicates to the WorkExperienceMutation builder.
  45018. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  45019. m.predicates = append(m.predicates, ps...)
  45020. }
  45021. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  45022. // users can use type-assertion to append predicates that do not depend on any generated package.
  45023. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  45024. p := make([]predicate.WorkExperience, len(ps))
  45025. for i := range ps {
  45026. p[i] = ps[i]
  45027. }
  45028. m.Where(p...)
  45029. }
  45030. // Op returns the operation name.
  45031. func (m *WorkExperienceMutation) Op() Op {
  45032. return m.op
  45033. }
  45034. // SetOp allows setting the mutation operation.
  45035. func (m *WorkExperienceMutation) SetOp(op Op) {
  45036. m.op = op
  45037. }
  45038. // Type returns the node type of this mutation (WorkExperience).
  45039. func (m *WorkExperienceMutation) Type() string {
  45040. return m.typ
  45041. }
  45042. // Fields returns all fields that were changed during this mutation. Note that in
  45043. // order to get all numeric fields that were incremented/decremented, call
  45044. // AddedFields().
  45045. func (m *WorkExperienceMutation) Fields() []string {
  45046. fields := make([]string, 0, 9)
  45047. if m.created_at != nil {
  45048. fields = append(fields, workexperience.FieldCreatedAt)
  45049. }
  45050. if m.updated_at != nil {
  45051. fields = append(fields, workexperience.FieldUpdatedAt)
  45052. }
  45053. if m.deleted_at != nil {
  45054. fields = append(fields, workexperience.FieldDeletedAt)
  45055. }
  45056. if m.employee != nil {
  45057. fields = append(fields, workexperience.FieldEmployeeID)
  45058. }
  45059. if m.start_date != nil {
  45060. fields = append(fields, workexperience.FieldStartDate)
  45061. }
  45062. if m.end_date != nil {
  45063. fields = append(fields, workexperience.FieldEndDate)
  45064. }
  45065. if m.company != nil {
  45066. fields = append(fields, workexperience.FieldCompany)
  45067. }
  45068. if m.experience != nil {
  45069. fields = append(fields, workexperience.FieldExperience)
  45070. }
  45071. if m.organization_id != nil {
  45072. fields = append(fields, workexperience.FieldOrganizationID)
  45073. }
  45074. return fields
  45075. }
  45076. // Field returns the value of a field with the given name. The second boolean
  45077. // return value indicates that this field was not set, or was not defined in the
  45078. // schema.
  45079. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  45080. switch name {
  45081. case workexperience.FieldCreatedAt:
  45082. return m.CreatedAt()
  45083. case workexperience.FieldUpdatedAt:
  45084. return m.UpdatedAt()
  45085. case workexperience.FieldDeletedAt:
  45086. return m.DeletedAt()
  45087. case workexperience.FieldEmployeeID:
  45088. return m.EmployeeID()
  45089. case workexperience.FieldStartDate:
  45090. return m.StartDate()
  45091. case workexperience.FieldEndDate:
  45092. return m.EndDate()
  45093. case workexperience.FieldCompany:
  45094. return m.Company()
  45095. case workexperience.FieldExperience:
  45096. return m.Experience()
  45097. case workexperience.FieldOrganizationID:
  45098. return m.OrganizationID()
  45099. }
  45100. return nil, false
  45101. }
  45102. // OldField returns the old value of the field from the database. An error is
  45103. // returned if the mutation operation is not UpdateOne, or the query to the
  45104. // database failed.
  45105. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45106. switch name {
  45107. case workexperience.FieldCreatedAt:
  45108. return m.OldCreatedAt(ctx)
  45109. case workexperience.FieldUpdatedAt:
  45110. return m.OldUpdatedAt(ctx)
  45111. case workexperience.FieldDeletedAt:
  45112. return m.OldDeletedAt(ctx)
  45113. case workexperience.FieldEmployeeID:
  45114. return m.OldEmployeeID(ctx)
  45115. case workexperience.FieldStartDate:
  45116. return m.OldStartDate(ctx)
  45117. case workexperience.FieldEndDate:
  45118. return m.OldEndDate(ctx)
  45119. case workexperience.FieldCompany:
  45120. return m.OldCompany(ctx)
  45121. case workexperience.FieldExperience:
  45122. return m.OldExperience(ctx)
  45123. case workexperience.FieldOrganizationID:
  45124. return m.OldOrganizationID(ctx)
  45125. }
  45126. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  45127. }
  45128. // SetField sets the value of a field with the given name. It returns an error if
  45129. // the field is not defined in the schema, or if the type mismatched the field
  45130. // type.
  45131. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45132. switch name {
  45133. case workexperience.FieldCreatedAt:
  45134. v, ok := value.(time.Time)
  45135. if !ok {
  45136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45137. }
  45138. m.SetCreatedAt(v)
  45139. return nil
  45140. case workexperience.FieldUpdatedAt:
  45141. v, ok := value.(time.Time)
  45142. if !ok {
  45143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45144. }
  45145. m.SetUpdatedAt(v)
  45146. return nil
  45147. case workexperience.FieldDeletedAt:
  45148. v, ok := value.(time.Time)
  45149. if !ok {
  45150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45151. }
  45152. m.SetDeletedAt(v)
  45153. return nil
  45154. case workexperience.FieldEmployeeID:
  45155. v, ok := value.(uint64)
  45156. if !ok {
  45157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45158. }
  45159. m.SetEmployeeID(v)
  45160. return nil
  45161. case workexperience.FieldStartDate:
  45162. v, ok := value.(time.Time)
  45163. if !ok {
  45164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45165. }
  45166. m.SetStartDate(v)
  45167. return nil
  45168. case workexperience.FieldEndDate:
  45169. v, ok := value.(time.Time)
  45170. if !ok {
  45171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45172. }
  45173. m.SetEndDate(v)
  45174. return nil
  45175. case workexperience.FieldCompany:
  45176. v, ok := value.(string)
  45177. if !ok {
  45178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45179. }
  45180. m.SetCompany(v)
  45181. return nil
  45182. case workexperience.FieldExperience:
  45183. v, ok := value.(string)
  45184. if !ok {
  45185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45186. }
  45187. m.SetExperience(v)
  45188. return nil
  45189. case workexperience.FieldOrganizationID:
  45190. v, ok := value.(uint64)
  45191. if !ok {
  45192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45193. }
  45194. m.SetOrganizationID(v)
  45195. return nil
  45196. }
  45197. return fmt.Errorf("unknown WorkExperience field %s", name)
  45198. }
  45199. // AddedFields returns all numeric fields that were incremented/decremented during
  45200. // this mutation.
  45201. func (m *WorkExperienceMutation) AddedFields() []string {
  45202. var fields []string
  45203. if m.addorganization_id != nil {
  45204. fields = append(fields, workexperience.FieldOrganizationID)
  45205. }
  45206. return fields
  45207. }
  45208. // AddedField returns the numeric value that was incremented/decremented on a field
  45209. // with the given name. The second boolean return value indicates that this field
  45210. // was not set, or was not defined in the schema.
  45211. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45212. switch name {
  45213. case workexperience.FieldOrganizationID:
  45214. return m.AddedOrganizationID()
  45215. }
  45216. return nil, false
  45217. }
  45218. // AddField adds the value to the field with the given name. It returns an error if
  45219. // the field is not defined in the schema, or if the type mismatched the field
  45220. // type.
  45221. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45222. switch name {
  45223. case workexperience.FieldOrganizationID:
  45224. v, ok := value.(int64)
  45225. if !ok {
  45226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45227. }
  45228. m.AddOrganizationID(v)
  45229. return nil
  45230. }
  45231. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45232. }
  45233. // ClearedFields returns all nullable fields that were cleared during this
  45234. // mutation.
  45235. func (m *WorkExperienceMutation) ClearedFields() []string {
  45236. var fields []string
  45237. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45238. fields = append(fields, workexperience.FieldDeletedAt)
  45239. }
  45240. return fields
  45241. }
  45242. // FieldCleared returns a boolean indicating if a field with the given name was
  45243. // cleared in this mutation.
  45244. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45245. _, ok := m.clearedFields[name]
  45246. return ok
  45247. }
  45248. // ClearField clears the value of the field with the given name. It returns an
  45249. // error if the field is not defined in the schema.
  45250. func (m *WorkExperienceMutation) ClearField(name string) error {
  45251. switch name {
  45252. case workexperience.FieldDeletedAt:
  45253. m.ClearDeletedAt()
  45254. return nil
  45255. }
  45256. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45257. }
  45258. // ResetField resets all changes in the mutation for the field with the given name.
  45259. // It returns an error if the field is not defined in the schema.
  45260. func (m *WorkExperienceMutation) ResetField(name string) error {
  45261. switch name {
  45262. case workexperience.FieldCreatedAt:
  45263. m.ResetCreatedAt()
  45264. return nil
  45265. case workexperience.FieldUpdatedAt:
  45266. m.ResetUpdatedAt()
  45267. return nil
  45268. case workexperience.FieldDeletedAt:
  45269. m.ResetDeletedAt()
  45270. return nil
  45271. case workexperience.FieldEmployeeID:
  45272. m.ResetEmployeeID()
  45273. return nil
  45274. case workexperience.FieldStartDate:
  45275. m.ResetStartDate()
  45276. return nil
  45277. case workexperience.FieldEndDate:
  45278. m.ResetEndDate()
  45279. return nil
  45280. case workexperience.FieldCompany:
  45281. m.ResetCompany()
  45282. return nil
  45283. case workexperience.FieldExperience:
  45284. m.ResetExperience()
  45285. return nil
  45286. case workexperience.FieldOrganizationID:
  45287. m.ResetOrganizationID()
  45288. return nil
  45289. }
  45290. return fmt.Errorf("unknown WorkExperience field %s", name)
  45291. }
  45292. // AddedEdges returns all edge names that were set/added in this mutation.
  45293. func (m *WorkExperienceMutation) AddedEdges() []string {
  45294. edges := make([]string, 0, 1)
  45295. if m.employee != nil {
  45296. edges = append(edges, workexperience.EdgeEmployee)
  45297. }
  45298. return edges
  45299. }
  45300. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45301. // name in this mutation.
  45302. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45303. switch name {
  45304. case workexperience.EdgeEmployee:
  45305. if id := m.employee; id != nil {
  45306. return []ent.Value{*id}
  45307. }
  45308. }
  45309. return nil
  45310. }
  45311. // RemovedEdges returns all edge names that were removed in this mutation.
  45312. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45313. edges := make([]string, 0, 1)
  45314. return edges
  45315. }
  45316. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45317. // the given name in this mutation.
  45318. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45319. return nil
  45320. }
  45321. // ClearedEdges returns all edge names that were cleared in this mutation.
  45322. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45323. edges := make([]string, 0, 1)
  45324. if m.clearedemployee {
  45325. edges = append(edges, workexperience.EdgeEmployee)
  45326. }
  45327. return edges
  45328. }
  45329. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45330. // was cleared in this mutation.
  45331. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45332. switch name {
  45333. case workexperience.EdgeEmployee:
  45334. return m.clearedemployee
  45335. }
  45336. return false
  45337. }
  45338. // ClearEdge clears the value of the edge with the given name. It returns an error
  45339. // if that edge is not defined in the schema.
  45340. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45341. switch name {
  45342. case workexperience.EdgeEmployee:
  45343. m.ClearEmployee()
  45344. return nil
  45345. }
  45346. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45347. }
  45348. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45349. // It returns an error if the edge is not defined in the schema.
  45350. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45351. switch name {
  45352. case workexperience.EdgeEmployee:
  45353. m.ResetEmployee()
  45354. return nil
  45355. }
  45356. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45357. }
  45358. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45359. type WpChatroomMutation struct {
  45360. config
  45361. op Op
  45362. typ string
  45363. id *uint64
  45364. created_at *time.Time
  45365. updated_at *time.Time
  45366. status *uint8
  45367. addstatus *int8
  45368. wx_wxid *string
  45369. chatroom_id *string
  45370. nickname *string
  45371. owner *string
  45372. avatar *string
  45373. member_list *[]string
  45374. appendmember_list []string
  45375. clearedFields map[string]struct{}
  45376. done bool
  45377. oldValue func(context.Context) (*WpChatroom, error)
  45378. predicates []predicate.WpChatroom
  45379. }
  45380. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45381. // wpchatroomOption allows management of the mutation configuration using functional options.
  45382. type wpchatroomOption func(*WpChatroomMutation)
  45383. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45384. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45385. m := &WpChatroomMutation{
  45386. config: c,
  45387. op: op,
  45388. typ: TypeWpChatroom,
  45389. clearedFields: make(map[string]struct{}),
  45390. }
  45391. for _, opt := range opts {
  45392. opt(m)
  45393. }
  45394. return m
  45395. }
  45396. // withWpChatroomID sets the ID field of the mutation.
  45397. func withWpChatroomID(id uint64) wpchatroomOption {
  45398. return func(m *WpChatroomMutation) {
  45399. var (
  45400. err error
  45401. once sync.Once
  45402. value *WpChatroom
  45403. )
  45404. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45405. once.Do(func() {
  45406. if m.done {
  45407. err = errors.New("querying old values post mutation is not allowed")
  45408. } else {
  45409. value, err = m.Client().WpChatroom.Get(ctx, id)
  45410. }
  45411. })
  45412. return value, err
  45413. }
  45414. m.id = &id
  45415. }
  45416. }
  45417. // withWpChatroom sets the old WpChatroom of the mutation.
  45418. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45419. return func(m *WpChatroomMutation) {
  45420. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45421. return node, nil
  45422. }
  45423. m.id = &node.ID
  45424. }
  45425. }
  45426. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45427. // executed in a transaction (ent.Tx), a transactional client is returned.
  45428. func (m WpChatroomMutation) Client() *Client {
  45429. client := &Client{config: m.config}
  45430. client.init()
  45431. return client
  45432. }
  45433. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45434. // it returns an error otherwise.
  45435. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45436. if _, ok := m.driver.(*txDriver); !ok {
  45437. return nil, errors.New("ent: mutation is not running in a transaction")
  45438. }
  45439. tx := &Tx{config: m.config}
  45440. tx.init()
  45441. return tx, nil
  45442. }
  45443. // SetID sets the value of the id field. Note that this
  45444. // operation is only accepted on creation of WpChatroom entities.
  45445. func (m *WpChatroomMutation) SetID(id uint64) {
  45446. m.id = &id
  45447. }
  45448. // ID returns the ID value in the mutation. Note that the ID is only available
  45449. // if it was provided to the builder or after it was returned from the database.
  45450. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45451. if m.id == nil {
  45452. return
  45453. }
  45454. return *m.id, true
  45455. }
  45456. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45457. // That means, if the mutation is applied within a transaction with an isolation level such
  45458. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45459. // or updated by the mutation.
  45460. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45461. switch {
  45462. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45463. id, exists := m.ID()
  45464. if exists {
  45465. return []uint64{id}, nil
  45466. }
  45467. fallthrough
  45468. case m.op.Is(OpUpdate | OpDelete):
  45469. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45470. default:
  45471. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45472. }
  45473. }
  45474. // SetCreatedAt sets the "created_at" field.
  45475. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45476. m.created_at = &t
  45477. }
  45478. // CreatedAt returns the value of the "created_at" field in the mutation.
  45479. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45480. v := m.created_at
  45481. if v == nil {
  45482. return
  45483. }
  45484. return *v, true
  45485. }
  45486. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45487. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45489. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45490. if !m.op.Is(OpUpdateOne) {
  45491. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45492. }
  45493. if m.id == nil || m.oldValue == nil {
  45494. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45495. }
  45496. oldValue, err := m.oldValue(ctx)
  45497. if err != nil {
  45498. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45499. }
  45500. return oldValue.CreatedAt, nil
  45501. }
  45502. // ResetCreatedAt resets all changes to the "created_at" field.
  45503. func (m *WpChatroomMutation) ResetCreatedAt() {
  45504. m.created_at = nil
  45505. }
  45506. // SetUpdatedAt sets the "updated_at" field.
  45507. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45508. m.updated_at = &t
  45509. }
  45510. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45511. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45512. v := m.updated_at
  45513. if v == nil {
  45514. return
  45515. }
  45516. return *v, true
  45517. }
  45518. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45519. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45521. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45522. if !m.op.Is(OpUpdateOne) {
  45523. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45524. }
  45525. if m.id == nil || m.oldValue == nil {
  45526. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45527. }
  45528. oldValue, err := m.oldValue(ctx)
  45529. if err != nil {
  45530. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45531. }
  45532. return oldValue.UpdatedAt, nil
  45533. }
  45534. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45535. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45536. m.updated_at = nil
  45537. }
  45538. // SetStatus sets the "status" field.
  45539. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45540. m.status = &u
  45541. m.addstatus = nil
  45542. }
  45543. // Status returns the value of the "status" field in the mutation.
  45544. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45545. v := m.status
  45546. if v == nil {
  45547. return
  45548. }
  45549. return *v, true
  45550. }
  45551. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45552. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45554. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45555. if !m.op.Is(OpUpdateOne) {
  45556. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45557. }
  45558. if m.id == nil || m.oldValue == nil {
  45559. return v, errors.New("OldStatus requires an ID field in the mutation")
  45560. }
  45561. oldValue, err := m.oldValue(ctx)
  45562. if err != nil {
  45563. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45564. }
  45565. return oldValue.Status, nil
  45566. }
  45567. // AddStatus adds u to the "status" field.
  45568. func (m *WpChatroomMutation) AddStatus(u int8) {
  45569. if m.addstatus != nil {
  45570. *m.addstatus += u
  45571. } else {
  45572. m.addstatus = &u
  45573. }
  45574. }
  45575. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45576. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45577. v := m.addstatus
  45578. if v == nil {
  45579. return
  45580. }
  45581. return *v, true
  45582. }
  45583. // ClearStatus clears the value of the "status" field.
  45584. func (m *WpChatroomMutation) ClearStatus() {
  45585. m.status = nil
  45586. m.addstatus = nil
  45587. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45588. }
  45589. // StatusCleared returns if the "status" field was cleared in this mutation.
  45590. func (m *WpChatroomMutation) StatusCleared() bool {
  45591. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45592. return ok
  45593. }
  45594. // ResetStatus resets all changes to the "status" field.
  45595. func (m *WpChatroomMutation) ResetStatus() {
  45596. m.status = nil
  45597. m.addstatus = nil
  45598. delete(m.clearedFields, wpchatroom.FieldStatus)
  45599. }
  45600. // SetWxWxid sets the "wx_wxid" field.
  45601. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45602. m.wx_wxid = &s
  45603. }
  45604. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45605. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45606. v := m.wx_wxid
  45607. if v == nil {
  45608. return
  45609. }
  45610. return *v, true
  45611. }
  45612. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45613. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45615. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45616. if !m.op.Is(OpUpdateOne) {
  45617. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45618. }
  45619. if m.id == nil || m.oldValue == nil {
  45620. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45621. }
  45622. oldValue, err := m.oldValue(ctx)
  45623. if err != nil {
  45624. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45625. }
  45626. return oldValue.WxWxid, nil
  45627. }
  45628. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45629. func (m *WpChatroomMutation) ResetWxWxid() {
  45630. m.wx_wxid = nil
  45631. }
  45632. // SetChatroomID sets the "chatroom_id" field.
  45633. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45634. m.chatroom_id = &s
  45635. }
  45636. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45637. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45638. v := m.chatroom_id
  45639. if v == nil {
  45640. return
  45641. }
  45642. return *v, true
  45643. }
  45644. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45645. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45647. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45648. if !m.op.Is(OpUpdateOne) {
  45649. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45650. }
  45651. if m.id == nil || m.oldValue == nil {
  45652. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45653. }
  45654. oldValue, err := m.oldValue(ctx)
  45655. if err != nil {
  45656. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45657. }
  45658. return oldValue.ChatroomID, nil
  45659. }
  45660. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45661. func (m *WpChatroomMutation) ResetChatroomID() {
  45662. m.chatroom_id = nil
  45663. }
  45664. // SetNickname sets the "nickname" field.
  45665. func (m *WpChatroomMutation) SetNickname(s string) {
  45666. m.nickname = &s
  45667. }
  45668. // Nickname returns the value of the "nickname" field in the mutation.
  45669. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45670. v := m.nickname
  45671. if v == nil {
  45672. return
  45673. }
  45674. return *v, true
  45675. }
  45676. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45677. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45679. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45680. if !m.op.Is(OpUpdateOne) {
  45681. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45682. }
  45683. if m.id == nil || m.oldValue == nil {
  45684. return v, errors.New("OldNickname requires an ID field in the mutation")
  45685. }
  45686. oldValue, err := m.oldValue(ctx)
  45687. if err != nil {
  45688. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45689. }
  45690. return oldValue.Nickname, nil
  45691. }
  45692. // ResetNickname resets all changes to the "nickname" field.
  45693. func (m *WpChatroomMutation) ResetNickname() {
  45694. m.nickname = nil
  45695. }
  45696. // SetOwner sets the "owner" field.
  45697. func (m *WpChatroomMutation) SetOwner(s string) {
  45698. m.owner = &s
  45699. }
  45700. // Owner returns the value of the "owner" field in the mutation.
  45701. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45702. v := m.owner
  45703. if v == nil {
  45704. return
  45705. }
  45706. return *v, true
  45707. }
  45708. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45709. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45711. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45712. if !m.op.Is(OpUpdateOne) {
  45713. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45714. }
  45715. if m.id == nil || m.oldValue == nil {
  45716. return v, errors.New("OldOwner requires an ID field in the mutation")
  45717. }
  45718. oldValue, err := m.oldValue(ctx)
  45719. if err != nil {
  45720. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45721. }
  45722. return oldValue.Owner, nil
  45723. }
  45724. // ResetOwner resets all changes to the "owner" field.
  45725. func (m *WpChatroomMutation) ResetOwner() {
  45726. m.owner = nil
  45727. }
  45728. // SetAvatar sets the "avatar" field.
  45729. func (m *WpChatroomMutation) SetAvatar(s string) {
  45730. m.avatar = &s
  45731. }
  45732. // Avatar returns the value of the "avatar" field in the mutation.
  45733. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45734. v := m.avatar
  45735. if v == nil {
  45736. return
  45737. }
  45738. return *v, true
  45739. }
  45740. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45741. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45743. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45744. if !m.op.Is(OpUpdateOne) {
  45745. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45746. }
  45747. if m.id == nil || m.oldValue == nil {
  45748. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45749. }
  45750. oldValue, err := m.oldValue(ctx)
  45751. if err != nil {
  45752. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45753. }
  45754. return oldValue.Avatar, nil
  45755. }
  45756. // ResetAvatar resets all changes to the "avatar" field.
  45757. func (m *WpChatroomMutation) ResetAvatar() {
  45758. m.avatar = nil
  45759. }
  45760. // SetMemberList sets the "member_list" field.
  45761. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45762. m.member_list = &s
  45763. m.appendmember_list = nil
  45764. }
  45765. // MemberList returns the value of the "member_list" field in the mutation.
  45766. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  45767. v := m.member_list
  45768. if v == nil {
  45769. return
  45770. }
  45771. return *v, true
  45772. }
  45773. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  45774. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45776. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  45777. if !m.op.Is(OpUpdateOne) {
  45778. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  45779. }
  45780. if m.id == nil || m.oldValue == nil {
  45781. return v, errors.New("OldMemberList requires an ID field in the mutation")
  45782. }
  45783. oldValue, err := m.oldValue(ctx)
  45784. if err != nil {
  45785. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  45786. }
  45787. return oldValue.MemberList, nil
  45788. }
  45789. // AppendMemberList adds s to the "member_list" field.
  45790. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  45791. m.appendmember_list = append(m.appendmember_list, s...)
  45792. }
  45793. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  45794. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  45795. if len(m.appendmember_list) == 0 {
  45796. return nil, false
  45797. }
  45798. return m.appendmember_list, true
  45799. }
  45800. // ResetMemberList resets all changes to the "member_list" field.
  45801. func (m *WpChatroomMutation) ResetMemberList() {
  45802. m.member_list = nil
  45803. m.appendmember_list = nil
  45804. }
  45805. // Where appends a list predicates to the WpChatroomMutation builder.
  45806. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  45807. m.predicates = append(m.predicates, ps...)
  45808. }
  45809. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  45810. // users can use type-assertion to append predicates that do not depend on any generated package.
  45811. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  45812. p := make([]predicate.WpChatroom, len(ps))
  45813. for i := range ps {
  45814. p[i] = ps[i]
  45815. }
  45816. m.Where(p...)
  45817. }
  45818. // Op returns the operation name.
  45819. func (m *WpChatroomMutation) Op() Op {
  45820. return m.op
  45821. }
  45822. // SetOp allows setting the mutation operation.
  45823. func (m *WpChatroomMutation) SetOp(op Op) {
  45824. m.op = op
  45825. }
  45826. // Type returns the node type of this mutation (WpChatroom).
  45827. func (m *WpChatroomMutation) Type() string {
  45828. return m.typ
  45829. }
  45830. // Fields returns all fields that were changed during this mutation. Note that in
  45831. // order to get all numeric fields that were incremented/decremented, call
  45832. // AddedFields().
  45833. func (m *WpChatroomMutation) Fields() []string {
  45834. fields := make([]string, 0, 9)
  45835. if m.created_at != nil {
  45836. fields = append(fields, wpchatroom.FieldCreatedAt)
  45837. }
  45838. if m.updated_at != nil {
  45839. fields = append(fields, wpchatroom.FieldUpdatedAt)
  45840. }
  45841. if m.status != nil {
  45842. fields = append(fields, wpchatroom.FieldStatus)
  45843. }
  45844. if m.wx_wxid != nil {
  45845. fields = append(fields, wpchatroom.FieldWxWxid)
  45846. }
  45847. if m.chatroom_id != nil {
  45848. fields = append(fields, wpchatroom.FieldChatroomID)
  45849. }
  45850. if m.nickname != nil {
  45851. fields = append(fields, wpchatroom.FieldNickname)
  45852. }
  45853. if m.owner != nil {
  45854. fields = append(fields, wpchatroom.FieldOwner)
  45855. }
  45856. if m.avatar != nil {
  45857. fields = append(fields, wpchatroom.FieldAvatar)
  45858. }
  45859. if m.member_list != nil {
  45860. fields = append(fields, wpchatroom.FieldMemberList)
  45861. }
  45862. return fields
  45863. }
  45864. // Field returns the value of a field with the given name. The second boolean
  45865. // return value indicates that this field was not set, or was not defined in the
  45866. // schema.
  45867. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  45868. switch name {
  45869. case wpchatroom.FieldCreatedAt:
  45870. return m.CreatedAt()
  45871. case wpchatroom.FieldUpdatedAt:
  45872. return m.UpdatedAt()
  45873. case wpchatroom.FieldStatus:
  45874. return m.Status()
  45875. case wpchatroom.FieldWxWxid:
  45876. return m.WxWxid()
  45877. case wpchatroom.FieldChatroomID:
  45878. return m.ChatroomID()
  45879. case wpchatroom.FieldNickname:
  45880. return m.Nickname()
  45881. case wpchatroom.FieldOwner:
  45882. return m.Owner()
  45883. case wpchatroom.FieldAvatar:
  45884. return m.Avatar()
  45885. case wpchatroom.FieldMemberList:
  45886. return m.MemberList()
  45887. }
  45888. return nil, false
  45889. }
  45890. // OldField returns the old value of the field from the database. An error is
  45891. // returned if the mutation operation is not UpdateOne, or the query to the
  45892. // database failed.
  45893. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45894. switch name {
  45895. case wpchatroom.FieldCreatedAt:
  45896. return m.OldCreatedAt(ctx)
  45897. case wpchatroom.FieldUpdatedAt:
  45898. return m.OldUpdatedAt(ctx)
  45899. case wpchatroom.FieldStatus:
  45900. return m.OldStatus(ctx)
  45901. case wpchatroom.FieldWxWxid:
  45902. return m.OldWxWxid(ctx)
  45903. case wpchatroom.FieldChatroomID:
  45904. return m.OldChatroomID(ctx)
  45905. case wpchatroom.FieldNickname:
  45906. return m.OldNickname(ctx)
  45907. case wpchatroom.FieldOwner:
  45908. return m.OldOwner(ctx)
  45909. case wpchatroom.FieldAvatar:
  45910. return m.OldAvatar(ctx)
  45911. case wpchatroom.FieldMemberList:
  45912. return m.OldMemberList(ctx)
  45913. }
  45914. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  45915. }
  45916. // SetField sets the value of a field with the given name. It returns an error if
  45917. // the field is not defined in the schema, or if the type mismatched the field
  45918. // type.
  45919. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  45920. switch name {
  45921. case wpchatroom.FieldCreatedAt:
  45922. v, ok := value.(time.Time)
  45923. if !ok {
  45924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45925. }
  45926. m.SetCreatedAt(v)
  45927. return nil
  45928. case wpchatroom.FieldUpdatedAt:
  45929. v, ok := value.(time.Time)
  45930. if !ok {
  45931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45932. }
  45933. m.SetUpdatedAt(v)
  45934. return nil
  45935. case wpchatroom.FieldStatus:
  45936. v, ok := value.(uint8)
  45937. if !ok {
  45938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45939. }
  45940. m.SetStatus(v)
  45941. return nil
  45942. case wpchatroom.FieldWxWxid:
  45943. v, ok := value.(string)
  45944. if !ok {
  45945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45946. }
  45947. m.SetWxWxid(v)
  45948. return nil
  45949. case wpchatroom.FieldChatroomID:
  45950. v, ok := value.(string)
  45951. if !ok {
  45952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45953. }
  45954. m.SetChatroomID(v)
  45955. return nil
  45956. case wpchatroom.FieldNickname:
  45957. v, ok := value.(string)
  45958. if !ok {
  45959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45960. }
  45961. m.SetNickname(v)
  45962. return nil
  45963. case wpchatroom.FieldOwner:
  45964. v, ok := value.(string)
  45965. if !ok {
  45966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45967. }
  45968. m.SetOwner(v)
  45969. return nil
  45970. case wpchatroom.FieldAvatar:
  45971. v, ok := value.(string)
  45972. if !ok {
  45973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45974. }
  45975. m.SetAvatar(v)
  45976. return nil
  45977. case wpchatroom.FieldMemberList:
  45978. v, ok := value.([]string)
  45979. if !ok {
  45980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45981. }
  45982. m.SetMemberList(v)
  45983. return nil
  45984. }
  45985. return fmt.Errorf("unknown WpChatroom field %s", name)
  45986. }
  45987. // AddedFields returns all numeric fields that were incremented/decremented during
  45988. // this mutation.
  45989. func (m *WpChatroomMutation) AddedFields() []string {
  45990. var fields []string
  45991. if m.addstatus != nil {
  45992. fields = append(fields, wpchatroom.FieldStatus)
  45993. }
  45994. return fields
  45995. }
  45996. // AddedField returns the numeric value that was incremented/decremented on a field
  45997. // with the given name. The second boolean return value indicates that this field
  45998. // was not set, or was not defined in the schema.
  45999. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  46000. switch name {
  46001. case wpchatroom.FieldStatus:
  46002. return m.AddedStatus()
  46003. }
  46004. return nil, false
  46005. }
  46006. // AddField adds the value to the field with the given name. It returns an error if
  46007. // the field is not defined in the schema, or if the type mismatched the field
  46008. // type.
  46009. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  46010. switch name {
  46011. case wpchatroom.FieldStatus:
  46012. v, ok := value.(int8)
  46013. if !ok {
  46014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46015. }
  46016. m.AddStatus(v)
  46017. return nil
  46018. }
  46019. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  46020. }
  46021. // ClearedFields returns all nullable fields that were cleared during this
  46022. // mutation.
  46023. func (m *WpChatroomMutation) ClearedFields() []string {
  46024. var fields []string
  46025. if m.FieldCleared(wpchatroom.FieldStatus) {
  46026. fields = append(fields, wpchatroom.FieldStatus)
  46027. }
  46028. return fields
  46029. }
  46030. // FieldCleared returns a boolean indicating if a field with the given name was
  46031. // cleared in this mutation.
  46032. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  46033. _, ok := m.clearedFields[name]
  46034. return ok
  46035. }
  46036. // ClearField clears the value of the field with the given name. It returns an
  46037. // error if the field is not defined in the schema.
  46038. func (m *WpChatroomMutation) ClearField(name string) error {
  46039. switch name {
  46040. case wpchatroom.FieldStatus:
  46041. m.ClearStatus()
  46042. return nil
  46043. }
  46044. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  46045. }
  46046. // ResetField resets all changes in the mutation for the field with the given name.
  46047. // It returns an error if the field is not defined in the schema.
  46048. func (m *WpChatroomMutation) ResetField(name string) error {
  46049. switch name {
  46050. case wpchatroom.FieldCreatedAt:
  46051. m.ResetCreatedAt()
  46052. return nil
  46053. case wpchatroom.FieldUpdatedAt:
  46054. m.ResetUpdatedAt()
  46055. return nil
  46056. case wpchatroom.FieldStatus:
  46057. m.ResetStatus()
  46058. return nil
  46059. case wpchatroom.FieldWxWxid:
  46060. m.ResetWxWxid()
  46061. return nil
  46062. case wpchatroom.FieldChatroomID:
  46063. m.ResetChatroomID()
  46064. return nil
  46065. case wpchatroom.FieldNickname:
  46066. m.ResetNickname()
  46067. return nil
  46068. case wpchatroom.FieldOwner:
  46069. m.ResetOwner()
  46070. return nil
  46071. case wpchatroom.FieldAvatar:
  46072. m.ResetAvatar()
  46073. return nil
  46074. case wpchatroom.FieldMemberList:
  46075. m.ResetMemberList()
  46076. return nil
  46077. }
  46078. return fmt.Errorf("unknown WpChatroom field %s", name)
  46079. }
  46080. // AddedEdges returns all edge names that were set/added in this mutation.
  46081. func (m *WpChatroomMutation) AddedEdges() []string {
  46082. edges := make([]string, 0, 0)
  46083. return edges
  46084. }
  46085. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46086. // name in this mutation.
  46087. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  46088. return nil
  46089. }
  46090. // RemovedEdges returns all edge names that were removed in this mutation.
  46091. func (m *WpChatroomMutation) RemovedEdges() []string {
  46092. edges := make([]string, 0, 0)
  46093. return edges
  46094. }
  46095. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46096. // the given name in this mutation.
  46097. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  46098. return nil
  46099. }
  46100. // ClearedEdges returns all edge names that were cleared in this mutation.
  46101. func (m *WpChatroomMutation) ClearedEdges() []string {
  46102. edges := make([]string, 0, 0)
  46103. return edges
  46104. }
  46105. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46106. // was cleared in this mutation.
  46107. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  46108. return false
  46109. }
  46110. // ClearEdge clears the value of the edge with the given name. It returns an error
  46111. // if that edge is not defined in the schema.
  46112. func (m *WpChatroomMutation) ClearEdge(name string) error {
  46113. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  46114. }
  46115. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46116. // It returns an error if the edge is not defined in the schema.
  46117. func (m *WpChatroomMutation) ResetEdge(name string) error {
  46118. return fmt.Errorf("unknown WpChatroom edge %s", name)
  46119. }
  46120. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  46121. type WpChatroomMemberMutation struct {
  46122. config
  46123. op Op
  46124. typ string
  46125. id *uint64
  46126. created_at *time.Time
  46127. updated_at *time.Time
  46128. status *uint8
  46129. addstatus *int8
  46130. wx_wxid *string
  46131. wxid *string
  46132. nickname *string
  46133. avatar *string
  46134. clearedFields map[string]struct{}
  46135. done bool
  46136. oldValue func(context.Context) (*WpChatroomMember, error)
  46137. predicates []predicate.WpChatroomMember
  46138. }
  46139. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46140. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46141. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46142. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46143. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46144. m := &WpChatroomMemberMutation{
  46145. config: c,
  46146. op: op,
  46147. typ: TypeWpChatroomMember,
  46148. clearedFields: make(map[string]struct{}),
  46149. }
  46150. for _, opt := range opts {
  46151. opt(m)
  46152. }
  46153. return m
  46154. }
  46155. // withWpChatroomMemberID sets the ID field of the mutation.
  46156. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46157. return func(m *WpChatroomMemberMutation) {
  46158. var (
  46159. err error
  46160. once sync.Once
  46161. value *WpChatroomMember
  46162. )
  46163. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46164. once.Do(func() {
  46165. if m.done {
  46166. err = errors.New("querying old values post mutation is not allowed")
  46167. } else {
  46168. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46169. }
  46170. })
  46171. return value, err
  46172. }
  46173. m.id = &id
  46174. }
  46175. }
  46176. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46177. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46178. return func(m *WpChatroomMemberMutation) {
  46179. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46180. return node, nil
  46181. }
  46182. m.id = &node.ID
  46183. }
  46184. }
  46185. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46186. // executed in a transaction (ent.Tx), a transactional client is returned.
  46187. func (m WpChatroomMemberMutation) Client() *Client {
  46188. client := &Client{config: m.config}
  46189. client.init()
  46190. return client
  46191. }
  46192. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46193. // it returns an error otherwise.
  46194. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46195. if _, ok := m.driver.(*txDriver); !ok {
  46196. return nil, errors.New("ent: mutation is not running in a transaction")
  46197. }
  46198. tx := &Tx{config: m.config}
  46199. tx.init()
  46200. return tx, nil
  46201. }
  46202. // SetID sets the value of the id field. Note that this
  46203. // operation is only accepted on creation of WpChatroomMember entities.
  46204. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46205. m.id = &id
  46206. }
  46207. // ID returns the ID value in the mutation. Note that the ID is only available
  46208. // if it was provided to the builder or after it was returned from the database.
  46209. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46210. if m.id == nil {
  46211. return
  46212. }
  46213. return *m.id, true
  46214. }
  46215. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46216. // That means, if the mutation is applied within a transaction with an isolation level such
  46217. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46218. // or updated by the mutation.
  46219. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46220. switch {
  46221. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46222. id, exists := m.ID()
  46223. if exists {
  46224. return []uint64{id}, nil
  46225. }
  46226. fallthrough
  46227. case m.op.Is(OpUpdate | OpDelete):
  46228. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46229. default:
  46230. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46231. }
  46232. }
  46233. // SetCreatedAt sets the "created_at" field.
  46234. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46235. m.created_at = &t
  46236. }
  46237. // CreatedAt returns the value of the "created_at" field in the mutation.
  46238. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46239. v := m.created_at
  46240. if v == nil {
  46241. return
  46242. }
  46243. return *v, true
  46244. }
  46245. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46246. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46248. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46249. if !m.op.Is(OpUpdateOne) {
  46250. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46251. }
  46252. if m.id == nil || m.oldValue == nil {
  46253. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46254. }
  46255. oldValue, err := m.oldValue(ctx)
  46256. if err != nil {
  46257. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46258. }
  46259. return oldValue.CreatedAt, nil
  46260. }
  46261. // ResetCreatedAt resets all changes to the "created_at" field.
  46262. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46263. m.created_at = nil
  46264. }
  46265. // SetUpdatedAt sets the "updated_at" field.
  46266. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46267. m.updated_at = &t
  46268. }
  46269. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46270. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46271. v := m.updated_at
  46272. if v == nil {
  46273. return
  46274. }
  46275. return *v, true
  46276. }
  46277. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46278. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46280. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46281. if !m.op.Is(OpUpdateOne) {
  46282. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46283. }
  46284. if m.id == nil || m.oldValue == nil {
  46285. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46286. }
  46287. oldValue, err := m.oldValue(ctx)
  46288. if err != nil {
  46289. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46290. }
  46291. return oldValue.UpdatedAt, nil
  46292. }
  46293. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46294. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46295. m.updated_at = nil
  46296. }
  46297. // SetStatus sets the "status" field.
  46298. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46299. m.status = &u
  46300. m.addstatus = nil
  46301. }
  46302. // Status returns the value of the "status" field in the mutation.
  46303. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46304. v := m.status
  46305. if v == nil {
  46306. return
  46307. }
  46308. return *v, true
  46309. }
  46310. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46311. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46313. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46314. if !m.op.Is(OpUpdateOne) {
  46315. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46316. }
  46317. if m.id == nil || m.oldValue == nil {
  46318. return v, errors.New("OldStatus requires an ID field in the mutation")
  46319. }
  46320. oldValue, err := m.oldValue(ctx)
  46321. if err != nil {
  46322. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46323. }
  46324. return oldValue.Status, nil
  46325. }
  46326. // AddStatus adds u to the "status" field.
  46327. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46328. if m.addstatus != nil {
  46329. *m.addstatus += u
  46330. } else {
  46331. m.addstatus = &u
  46332. }
  46333. }
  46334. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46335. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46336. v := m.addstatus
  46337. if v == nil {
  46338. return
  46339. }
  46340. return *v, true
  46341. }
  46342. // ClearStatus clears the value of the "status" field.
  46343. func (m *WpChatroomMemberMutation) ClearStatus() {
  46344. m.status = nil
  46345. m.addstatus = nil
  46346. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46347. }
  46348. // StatusCleared returns if the "status" field was cleared in this mutation.
  46349. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46350. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46351. return ok
  46352. }
  46353. // ResetStatus resets all changes to the "status" field.
  46354. func (m *WpChatroomMemberMutation) ResetStatus() {
  46355. m.status = nil
  46356. m.addstatus = nil
  46357. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46358. }
  46359. // SetWxWxid sets the "wx_wxid" field.
  46360. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46361. m.wx_wxid = &s
  46362. }
  46363. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46364. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46365. v := m.wx_wxid
  46366. if v == nil {
  46367. return
  46368. }
  46369. return *v, true
  46370. }
  46371. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46372. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46374. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46375. if !m.op.Is(OpUpdateOne) {
  46376. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46377. }
  46378. if m.id == nil || m.oldValue == nil {
  46379. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46380. }
  46381. oldValue, err := m.oldValue(ctx)
  46382. if err != nil {
  46383. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46384. }
  46385. return oldValue.WxWxid, nil
  46386. }
  46387. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46388. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46389. m.wx_wxid = nil
  46390. }
  46391. // SetWxid sets the "wxid" field.
  46392. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46393. m.wxid = &s
  46394. }
  46395. // Wxid returns the value of the "wxid" field in the mutation.
  46396. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46397. v := m.wxid
  46398. if v == nil {
  46399. return
  46400. }
  46401. return *v, true
  46402. }
  46403. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46404. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46406. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46407. if !m.op.Is(OpUpdateOne) {
  46408. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46409. }
  46410. if m.id == nil || m.oldValue == nil {
  46411. return v, errors.New("OldWxid requires an ID field in the mutation")
  46412. }
  46413. oldValue, err := m.oldValue(ctx)
  46414. if err != nil {
  46415. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46416. }
  46417. return oldValue.Wxid, nil
  46418. }
  46419. // ResetWxid resets all changes to the "wxid" field.
  46420. func (m *WpChatroomMemberMutation) ResetWxid() {
  46421. m.wxid = nil
  46422. }
  46423. // SetNickname sets the "nickname" field.
  46424. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46425. m.nickname = &s
  46426. }
  46427. // Nickname returns the value of the "nickname" field in the mutation.
  46428. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46429. v := m.nickname
  46430. if v == nil {
  46431. return
  46432. }
  46433. return *v, true
  46434. }
  46435. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46436. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46438. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46439. if !m.op.Is(OpUpdateOne) {
  46440. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46441. }
  46442. if m.id == nil || m.oldValue == nil {
  46443. return v, errors.New("OldNickname requires an ID field in the mutation")
  46444. }
  46445. oldValue, err := m.oldValue(ctx)
  46446. if err != nil {
  46447. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46448. }
  46449. return oldValue.Nickname, nil
  46450. }
  46451. // ResetNickname resets all changes to the "nickname" field.
  46452. func (m *WpChatroomMemberMutation) ResetNickname() {
  46453. m.nickname = nil
  46454. }
  46455. // SetAvatar sets the "avatar" field.
  46456. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46457. m.avatar = &s
  46458. }
  46459. // Avatar returns the value of the "avatar" field in the mutation.
  46460. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46461. v := m.avatar
  46462. if v == nil {
  46463. return
  46464. }
  46465. return *v, true
  46466. }
  46467. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46468. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46470. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46471. if !m.op.Is(OpUpdateOne) {
  46472. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46473. }
  46474. if m.id == nil || m.oldValue == nil {
  46475. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46476. }
  46477. oldValue, err := m.oldValue(ctx)
  46478. if err != nil {
  46479. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46480. }
  46481. return oldValue.Avatar, nil
  46482. }
  46483. // ResetAvatar resets all changes to the "avatar" field.
  46484. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46485. m.avatar = nil
  46486. }
  46487. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46488. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46489. m.predicates = append(m.predicates, ps...)
  46490. }
  46491. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46492. // users can use type-assertion to append predicates that do not depend on any generated package.
  46493. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46494. p := make([]predicate.WpChatroomMember, len(ps))
  46495. for i := range ps {
  46496. p[i] = ps[i]
  46497. }
  46498. m.Where(p...)
  46499. }
  46500. // Op returns the operation name.
  46501. func (m *WpChatroomMemberMutation) Op() Op {
  46502. return m.op
  46503. }
  46504. // SetOp allows setting the mutation operation.
  46505. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46506. m.op = op
  46507. }
  46508. // Type returns the node type of this mutation (WpChatroomMember).
  46509. func (m *WpChatroomMemberMutation) Type() string {
  46510. return m.typ
  46511. }
  46512. // Fields returns all fields that were changed during this mutation. Note that in
  46513. // order to get all numeric fields that were incremented/decremented, call
  46514. // AddedFields().
  46515. func (m *WpChatroomMemberMutation) Fields() []string {
  46516. fields := make([]string, 0, 7)
  46517. if m.created_at != nil {
  46518. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46519. }
  46520. if m.updated_at != nil {
  46521. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46522. }
  46523. if m.status != nil {
  46524. fields = append(fields, wpchatroommember.FieldStatus)
  46525. }
  46526. if m.wx_wxid != nil {
  46527. fields = append(fields, wpchatroommember.FieldWxWxid)
  46528. }
  46529. if m.wxid != nil {
  46530. fields = append(fields, wpchatroommember.FieldWxid)
  46531. }
  46532. if m.nickname != nil {
  46533. fields = append(fields, wpchatroommember.FieldNickname)
  46534. }
  46535. if m.avatar != nil {
  46536. fields = append(fields, wpchatroommember.FieldAvatar)
  46537. }
  46538. return fields
  46539. }
  46540. // Field returns the value of a field with the given name. The second boolean
  46541. // return value indicates that this field was not set, or was not defined in the
  46542. // schema.
  46543. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46544. switch name {
  46545. case wpchatroommember.FieldCreatedAt:
  46546. return m.CreatedAt()
  46547. case wpchatroommember.FieldUpdatedAt:
  46548. return m.UpdatedAt()
  46549. case wpchatroommember.FieldStatus:
  46550. return m.Status()
  46551. case wpchatroommember.FieldWxWxid:
  46552. return m.WxWxid()
  46553. case wpchatroommember.FieldWxid:
  46554. return m.Wxid()
  46555. case wpchatroommember.FieldNickname:
  46556. return m.Nickname()
  46557. case wpchatroommember.FieldAvatar:
  46558. return m.Avatar()
  46559. }
  46560. return nil, false
  46561. }
  46562. // OldField returns the old value of the field from the database. An error is
  46563. // returned if the mutation operation is not UpdateOne, or the query to the
  46564. // database failed.
  46565. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46566. switch name {
  46567. case wpchatroommember.FieldCreatedAt:
  46568. return m.OldCreatedAt(ctx)
  46569. case wpchatroommember.FieldUpdatedAt:
  46570. return m.OldUpdatedAt(ctx)
  46571. case wpchatroommember.FieldStatus:
  46572. return m.OldStatus(ctx)
  46573. case wpchatroommember.FieldWxWxid:
  46574. return m.OldWxWxid(ctx)
  46575. case wpchatroommember.FieldWxid:
  46576. return m.OldWxid(ctx)
  46577. case wpchatroommember.FieldNickname:
  46578. return m.OldNickname(ctx)
  46579. case wpchatroommember.FieldAvatar:
  46580. return m.OldAvatar(ctx)
  46581. }
  46582. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46583. }
  46584. // SetField sets the value of a field with the given name. It returns an error if
  46585. // the field is not defined in the schema, or if the type mismatched the field
  46586. // type.
  46587. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46588. switch name {
  46589. case wpchatroommember.FieldCreatedAt:
  46590. v, ok := value.(time.Time)
  46591. if !ok {
  46592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46593. }
  46594. m.SetCreatedAt(v)
  46595. return nil
  46596. case wpchatroommember.FieldUpdatedAt:
  46597. v, ok := value.(time.Time)
  46598. if !ok {
  46599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46600. }
  46601. m.SetUpdatedAt(v)
  46602. return nil
  46603. case wpchatroommember.FieldStatus:
  46604. v, ok := value.(uint8)
  46605. if !ok {
  46606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46607. }
  46608. m.SetStatus(v)
  46609. return nil
  46610. case wpchatroommember.FieldWxWxid:
  46611. v, ok := value.(string)
  46612. if !ok {
  46613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46614. }
  46615. m.SetWxWxid(v)
  46616. return nil
  46617. case wpchatroommember.FieldWxid:
  46618. v, ok := value.(string)
  46619. if !ok {
  46620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46621. }
  46622. m.SetWxid(v)
  46623. return nil
  46624. case wpchatroommember.FieldNickname:
  46625. v, ok := value.(string)
  46626. if !ok {
  46627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46628. }
  46629. m.SetNickname(v)
  46630. return nil
  46631. case wpchatroommember.FieldAvatar:
  46632. v, ok := value.(string)
  46633. if !ok {
  46634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46635. }
  46636. m.SetAvatar(v)
  46637. return nil
  46638. }
  46639. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46640. }
  46641. // AddedFields returns all numeric fields that were incremented/decremented during
  46642. // this mutation.
  46643. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46644. var fields []string
  46645. if m.addstatus != nil {
  46646. fields = append(fields, wpchatroommember.FieldStatus)
  46647. }
  46648. return fields
  46649. }
  46650. // AddedField returns the numeric value that was incremented/decremented on a field
  46651. // with the given name. The second boolean return value indicates that this field
  46652. // was not set, or was not defined in the schema.
  46653. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46654. switch name {
  46655. case wpchatroommember.FieldStatus:
  46656. return m.AddedStatus()
  46657. }
  46658. return nil, false
  46659. }
  46660. // AddField adds the value to the field with the given name. It returns an error if
  46661. // the field is not defined in the schema, or if the type mismatched the field
  46662. // type.
  46663. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46664. switch name {
  46665. case wpchatroommember.FieldStatus:
  46666. v, ok := value.(int8)
  46667. if !ok {
  46668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46669. }
  46670. m.AddStatus(v)
  46671. return nil
  46672. }
  46673. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46674. }
  46675. // ClearedFields returns all nullable fields that were cleared during this
  46676. // mutation.
  46677. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46678. var fields []string
  46679. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46680. fields = append(fields, wpchatroommember.FieldStatus)
  46681. }
  46682. return fields
  46683. }
  46684. // FieldCleared returns a boolean indicating if a field with the given name was
  46685. // cleared in this mutation.
  46686. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46687. _, ok := m.clearedFields[name]
  46688. return ok
  46689. }
  46690. // ClearField clears the value of the field with the given name. It returns an
  46691. // error if the field is not defined in the schema.
  46692. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46693. switch name {
  46694. case wpchatroommember.FieldStatus:
  46695. m.ClearStatus()
  46696. return nil
  46697. }
  46698. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46699. }
  46700. // ResetField resets all changes in the mutation for the field with the given name.
  46701. // It returns an error if the field is not defined in the schema.
  46702. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46703. switch name {
  46704. case wpchatroommember.FieldCreatedAt:
  46705. m.ResetCreatedAt()
  46706. return nil
  46707. case wpchatroommember.FieldUpdatedAt:
  46708. m.ResetUpdatedAt()
  46709. return nil
  46710. case wpchatroommember.FieldStatus:
  46711. m.ResetStatus()
  46712. return nil
  46713. case wpchatroommember.FieldWxWxid:
  46714. m.ResetWxWxid()
  46715. return nil
  46716. case wpchatroommember.FieldWxid:
  46717. m.ResetWxid()
  46718. return nil
  46719. case wpchatroommember.FieldNickname:
  46720. m.ResetNickname()
  46721. return nil
  46722. case wpchatroommember.FieldAvatar:
  46723. m.ResetAvatar()
  46724. return nil
  46725. }
  46726. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46727. }
  46728. // AddedEdges returns all edge names that were set/added in this mutation.
  46729. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46730. edges := make([]string, 0, 0)
  46731. return edges
  46732. }
  46733. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46734. // name in this mutation.
  46735. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46736. return nil
  46737. }
  46738. // RemovedEdges returns all edge names that were removed in this mutation.
  46739. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46740. edges := make([]string, 0, 0)
  46741. return edges
  46742. }
  46743. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46744. // the given name in this mutation.
  46745. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46746. return nil
  46747. }
  46748. // ClearedEdges returns all edge names that were cleared in this mutation.
  46749. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46750. edges := make([]string, 0, 0)
  46751. return edges
  46752. }
  46753. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46754. // was cleared in this mutation.
  46755. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46756. return false
  46757. }
  46758. // ClearEdge clears the value of the edge with the given name. It returns an error
  46759. // if that edge is not defined in the schema.
  46760. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46761. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46762. }
  46763. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46764. // It returns an error if the edge is not defined in the schema.
  46765. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46766. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  46767. }
  46768. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  46769. type WxMutation struct {
  46770. config
  46771. op Op
  46772. typ string
  46773. id *uint64
  46774. created_at *time.Time
  46775. updated_at *time.Time
  46776. status *uint8
  46777. addstatus *int8
  46778. deleted_at *time.Time
  46779. port *string
  46780. process_id *string
  46781. callback *string
  46782. wxid *string
  46783. account *string
  46784. nickname *string
  46785. tel *string
  46786. head_big *string
  46787. organization_id *uint64
  46788. addorganization_id *int64
  46789. api_base *string
  46790. api_key *string
  46791. allow_list *[]string
  46792. appendallow_list []string
  46793. group_allow_list *[]string
  46794. appendgroup_allow_list []string
  46795. block_list *[]string
  46796. appendblock_list []string
  46797. group_block_list *[]string
  46798. appendgroup_block_list []string
  46799. ctype *uint64
  46800. addctype *int64
  46801. clearedFields map[string]struct{}
  46802. server *uint64
  46803. clearedserver bool
  46804. agent *uint64
  46805. clearedagent bool
  46806. done bool
  46807. oldValue func(context.Context) (*Wx, error)
  46808. predicates []predicate.Wx
  46809. }
  46810. var _ ent.Mutation = (*WxMutation)(nil)
  46811. // wxOption allows management of the mutation configuration using functional options.
  46812. type wxOption func(*WxMutation)
  46813. // newWxMutation creates new mutation for the Wx entity.
  46814. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  46815. m := &WxMutation{
  46816. config: c,
  46817. op: op,
  46818. typ: TypeWx,
  46819. clearedFields: make(map[string]struct{}),
  46820. }
  46821. for _, opt := range opts {
  46822. opt(m)
  46823. }
  46824. return m
  46825. }
  46826. // withWxID sets the ID field of the mutation.
  46827. func withWxID(id uint64) wxOption {
  46828. return func(m *WxMutation) {
  46829. var (
  46830. err error
  46831. once sync.Once
  46832. value *Wx
  46833. )
  46834. m.oldValue = func(ctx context.Context) (*Wx, error) {
  46835. once.Do(func() {
  46836. if m.done {
  46837. err = errors.New("querying old values post mutation is not allowed")
  46838. } else {
  46839. value, err = m.Client().Wx.Get(ctx, id)
  46840. }
  46841. })
  46842. return value, err
  46843. }
  46844. m.id = &id
  46845. }
  46846. }
  46847. // withWx sets the old Wx of the mutation.
  46848. func withWx(node *Wx) wxOption {
  46849. return func(m *WxMutation) {
  46850. m.oldValue = func(context.Context) (*Wx, error) {
  46851. return node, nil
  46852. }
  46853. m.id = &node.ID
  46854. }
  46855. }
  46856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46857. // executed in a transaction (ent.Tx), a transactional client is returned.
  46858. func (m WxMutation) Client() *Client {
  46859. client := &Client{config: m.config}
  46860. client.init()
  46861. return client
  46862. }
  46863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46864. // it returns an error otherwise.
  46865. func (m WxMutation) Tx() (*Tx, error) {
  46866. if _, ok := m.driver.(*txDriver); !ok {
  46867. return nil, errors.New("ent: mutation is not running in a transaction")
  46868. }
  46869. tx := &Tx{config: m.config}
  46870. tx.init()
  46871. return tx, nil
  46872. }
  46873. // SetID sets the value of the id field. Note that this
  46874. // operation is only accepted on creation of Wx entities.
  46875. func (m *WxMutation) SetID(id uint64) {
  46876. m.id = &id
  46877. }
  46878. // ID returns the ID value in the mutation. Note that the ID is only available
  46879. // if it was provided to the builder or after it was returned from the database.
  46880. func (m *WxMutation) ID() (id uint64, exists bool) {
  46881. if m.id == nil {
  46882. return
  46883. }
  46884. return *m.id, true
  46885. }
  46886. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46887. // That means, if the mutation is applied within a transaction with an isolation level such
  46888. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46889. // or updated by the mutation.
  46890. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  46891. switch {
  46892. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46893. id, exists := m.ID()
  46894. if exists {
  46895. return []uint64{id}, nil
  46896. }
  46897. fallthrough
  46898. case m.op.Is(OpUpdate | OpDelete):
  46899. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  46900. default:
  46901. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46902. }
  46903. }
  46904. // SetCreatedAt sets the "created_at" field.
  46905. func (m *WxMutation) SetCreatedAt(t time.Time) {
  46906. m.created_at = &t
  46907. }
  46908. // CreatedAt returns the value of the "created_at" field in the mutation.
  46909. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  46910. v := m.created_at
  46911. if v == nil {
  46912. return
  46913. }
  46914. return *v, true
  46915. }
  46916. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  46917. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46919. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46920. if !m.op.Is(OpUpdateOne) {
  46921. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46922. }
  46923. if m.id == nil || m.oldValue == nil {
  46924. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46925. }
  46926. oldValue, err := m.oldValue(ctx)
  46927. if err != nil {
  46928. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46929. }
  46930. return oldValue.CreatedAt, nil
  46931. }
  46932. // ResetCreatedAt resets all changes to the "created_at" field.
  46933. func (m *WxMutation) ResetCreatedAt() {
  46934. m.created_at = nil
  46935. }
  46936. // SetUpdatedAt sets the "updated_at" field.
  46937. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  46938. m.updated_at = &t
  46939. }
  46940. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46941. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  46942. v := m.updated_at
  46943. if v == nil {
  46944. return
  46945. }
  46946. return *v, true
  46947. }
  46948. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  46949. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46951. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46952. if !m.op.Is(OpUpdateOne) {
  46953. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46954. }
  46955. if m.id == nil || m.oldValue == nil {
  46956. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46957. }
  46958. oldValue, err := m.oldValue(ctx)
  46959. if err != nil {
  46960. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46961. }
  46962. return oldValue.UpdatedAt, nil
  46963. }
  46964. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46965. func (m *WxMutation) ResetUpdatedAt() {
  46966. m.updated_at = nil
  46967. }
  46968. // SetStatus sets the "status" field.
  46969. func (m *WxMutation) SetStatus(u uint8) {
  46970. m.status = &u
  46971. m.addstatus = nil
  46972. }
  46973. // Status returns the value of the "status" field in the mutation.
  46974. func (m *WxMutation) Status() (r uint8, exists bool) {
  46975. v := m.status
  46976. if v == nil {
  46977. return
  46978. }
  46979. return *v, true
  46980. }
  46981. // OldStatus returns the old "status" field's value of the Wx entity.
  46982. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46984. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46985. if !m.op.Is(OpUpdateOne) {
  46986. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46987. }
  46988. if m.id == nil || m.oldValue == nil {
  46989. return v, errors.New("OldStatus requires an ID field in the mutation")
  46990. }
  46991. oldValue, err := m.oldValue(ctx)
  46992. if err != nil {
  46993. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46994. }
  46995. return oldValue.Status, nil
  46996. }
  46997. // AddStatus adds u to the "status" field.
  46998. func (m *WxMutation) AddStatus(u int8) {
  46999. if m.addstatus != nil {
  47000. *m.addstatus += u
  47001. } else {
  47002. m.addstatus = &u
  47003. }
  47004. }
  47005. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47006. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  47007. v := m.addstatus
  47008. if v == nil {
  47009. return
  47010. }
  47011. return *v, true
  47012. }
  47013. // ClearStatus clears the value of the "status" field.
  47014. func (m *WxMutation) ClearStatus() {
  47015. m.status = nil
  47016. m.addstatus = nil
  47017. m.clearedFields[wx.FieldStatus] = struct{}{}
  47018. }
  47019. // StatusCleared returns if the "status" field was cleared in this mutation.
  47020. func (m *WxMutation) StatusCleared() bool {
  47021. _, ok := m.clearedFields[wx.FieldStatus]
  47022. return ok
  47023. }
  47024. // ResetStatus resets all changes to the "status" field.
  47025. func (m *WxMutation) ResetStatus() {
  47026. m.status = nil
  47027. m.addstatus = nil
  47028. delete(m.clearedFields, wx.FieldStatus)
  47029. }
  47030. // SetDeletedAt sets the "deleted_at" field.
  47031. func (m *WxMutation) SetDeletedAt(t time.Time) {
  47032. m.deleted_at = &t
  47033. }
  47034. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47035. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  47036. v := m.deleted_at
  47037. if v == nil {
  47038. return
  47039. }
  47040. return *v, true
  47041. }
  47042. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  47043. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47045. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47046. if !m.op.Is(OpUpdateOne) {
  47047. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47048. }
  47049. if m.id == nil || m.oldValue == nil {
  47050. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47051. }
  47052. oldValue, err := m.oldValue(ctx)
  47053. if err != nil {
  47054. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47055. }
  47056. return oldValue.DeletedAt, nil
  47057. }
  47058. // ClearDeletedAt clears the value of the "deleted_at" field.
  47059. func (m *WxMutation) ClearDeletedAt() {
  47060. m.deleted_at = nil
  47061. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  47062. }
  47063. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47064. func (m *WxMutation) DeletedAtCleared() bool {
  47065. _, ok := m.clearedFields[wx.FieldDeletedAt]
  47066. return ok
  47067. }
  47068. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47069. func (m *WxMutation) ResetDeletedAt() {
  47070. m.deleted_at = nil
  47071. delete(m.clearedFields, wx.FieldDeletedAt)
  47072. }
  47073. // SetServerID sets the "server_id" field.
  47074. func (m *WxMutation) SetServerID(u uint64) {
  47075. m.server = &u
  47076. }
  47077. // ServerID returns the value of the "server_id" field in the mutation.
  47078. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  47079. v := m.server
  47080. if v == nil {
  47081. return
  47082. }
  47083. return *v, true
  47084. }
  47085. // OldServerID returns the old "server_id" field's value of the Wx entity.
  47086. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47088. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  47089. if !m.op.Is(OpUpdateOne) {
  47090. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  47091. }
  47092. if m.id == nil || m.oldValue == nil {
  47093. return v, errors.New("OldServerID requires an ID field in the mutation")
  47094. }
  47095. oldValue, err := m.oldValue(ctx)
  47096. if err != nil {
  47097. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  47098. }
  47099. return oldValue.ServerID, nil
  47100. }
  47101. // ClearServerID clears the value of the "server_id" field.
  47102. func (m *WxMutation) ClearServerID() {
  47103. m.server = nil
  47104. m.clearedFields[wx.FieldServerID] = struct{}{}
  47105. }
  47106. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  47107. func (m *WxMutation) ServerIDCleared() bool {
  47108. _, ok := m.clearedFields[wx.FieldServerID]
  47109. return ok
  47110. }
  47111. // ResetServerID resets all changes to the "server_id" field.
  47112. func (m *WxMutation) ResetServerID() {
  47113. m.server = nil
  47114. delete(m.clearedFields, wx.FieldServerID)
  47115. }
  47116. // SetPort sets the "port" field.
  47117. func (m *WxMutation) SetPort(s string) {
  47118. m.port = &s
  47119. }
  47120. // Port returns the value of the "port" field in the mutation.
  47121. func (m *WxMutation) Port() (r string, exists bool) {
  47122. v := m.port
  47123. if v == nil {
  47124. return
  47125. }
  47126. return *v, true
  47127. }
  47128. // OldPort returns the old "port" field's value of the Wx entity.
  47129. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47131. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47132. if !m.op.Is(OpUpdateOne) {
  47133. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47134. }
  47135. if m.id == nil || m.oldValue == nil {
  47136. return v, errors.New("OldPort requires an ID field in the mutation")
  47137. }
  47138. oldValue, err := m.oldValue(ctx)
  47139. if err != nil {
  47140. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47141. }
  47142. return oldValue.Port, nil
  47143. }
  47144. // ResetPort resets all changes to the "port" field.
  47145. func (m *WxMutation) ResetPort() {
  47146. m.port = nil
  47147. }
  47148. // SetProcessID sets the "process_id" field.
  47149. func (m *WxMutation) SetProcessID(s string) {
  47150. m.process_id = &s
  47151. }
  47152. // ProcessID returns the value of the "process_id" field in the mutation.
  47153. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47154. v := m.process_id
  47155. if v == nil {
  47156. return
  47157. }
  47158. return *v, true
  47159. }
  47160. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47161. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47163. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47164. if !m.op.Is(OpUpdateOne) {
  47165. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47166. }
  47167. if m.id == nil || m.oldValue == nil {
  47168. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47169. }
  47170. oldValue, err := m.oldValue(ctx)
  47171. if err != nil {
  47172. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47173. }
  47174. return oldValue.ProcessID, nil
  47175. }
  47176. // ResetProcessID resets all changes to the "process_id" field.
  47177. func (m *WxMutation) ResetProcessID() {
  47178. m.process_id = nil
  47179. }
  47180. // SetCallback sets the "callback" field.
  47181. func (m *WxMutation) SetCallback(s string) {
  47182. m.callback = &s
  47183. }
  47184. // Callback returns the value of the "callback" field in the mutation.
  47185. func (m *WxMutation) Callback() (r string, exists bool) {
  47186. v := m.callback
  47187. if v == nil {
  47188. return
  47189. }
  47190. return *v, true
  47191. }
  47192. // OldCallback returns the old "callback" field's value of the Wx entity.
  47193. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47195. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47196. if !m.op.Is(OpUpdateOne) {
  47197. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47198. }
  47199. if m.id == nil || m.oldValue == nil {
  47200. return v, errors.New("OldCallback requires an ID field in the mutation")
  47201. }
  47202. oldValue, err := m.oldValue(ctx)
  47203. if err != nil {
  47204. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47205. }
  47206. return oldValue.Callback, nil
  47207. }
  47208. // ResetCallback resets all changes to the "callback" field.
  47209. func (m *WxMutation) ResetCallback() {
  47210. m.callback = nil
  47211. }
  47212. // SetWxid sets the "wxid" field.
  47213. func (m *WxMutation) SetWxid(s string) {
  47214. m.wxid = &s
  47215. }
  47216. // Wxid returns the value of the "wxid" field in the mutation.
  47217. func (m *WxMutation) Wxid() (r string, exists bool) {
  47218. v := m.wxid
  47219. if v == nil {
  47220. return
  47221. }
  47222. return *v, true
  47223. }
  47224. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47225. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47227. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47228. if !m.op.Is(OpUpdateOne) {
  47229. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47230. }
  47231. if m.id == nil || m.oldValue == nil {
  47232. return v, errors.New("OldWxid requires an ID field in the mutation")
  47233. }
  47234. oldValue, err := m.oldValue(ctx)
  47235. if err != nil {
  47236. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47237. }
  47238. return oldValue.Wxid, nil
  47239. }
  47240. // ResetWxid resets all changes to the "wxid" field.
  47241. func (m *WxMutation) ResetWxid() {
  47242. m.wxid = nil
  47243. }
  47244. // SetAccount sets the "account" field.
  47245. func (m *WxMutation) SetAccount(s string) {
  47246. m.account = &s
  47247. }
  47248. // Account returns the value of the "account" field in the mutation.
  47249. func (m *WxMutation) Account() (r string, exists bool) {
  47250. v := m.account
  47251. if v == nil {
  47252. return
  47253. }
  47254. return *v, true
  47255. }
  47256. // OldAccount returns the old "account" field's value of the Wx entity.
  47257. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47259. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47260. if !m.op.Is(OpUpdateOne) {
  47261. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47262. }
  47263. if m.id == nil || m.oldValue == nil {
  47264. return v, errors.New("OldAccount requires an ID field in the mutation")
  47265. }
  47266. oldValue, err := m.oldValue(ctx)
  47267. if err != nil {
  47268. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47269. }
  47270. return oldValue.Account, nil
  47271. }
  47272. // ResetAccount resets all changes to the "account" field.
  47273. func (m *WxMutation) ResetAccount() {
  47274. m.account = nil
  47275. }
  47276. // SetNickname sets the "nickname" field.
  47277. func (m *WxMutation) SetNickname(s string) {
  47278. m.nickname = &s
  47279. }
  47280. // Nickname returns the value of the "nickname" field in the mutation.
  47281. func (m *WxMutation) Nickname() (r string, exists bool) {
  47282. v := m.nickname
  47283. if v == nil {
  47284. return
  47285. }
  47286. return *v, true
  47287. }
  47288. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47289. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47291. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47292. if !m.op.Is(OpUpdateOne) {
  47293. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47294. }
  47295. if m.id == nil || m.oldValue == nil {
  47296. return v, errors.New("OldNickname requires an ID field in the mutation")
  47297. }
  47298. oldValue, err := m.oldValue(ctx)
  47299. if err != nil {
  47300. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47301. }
  47302. return oldValue.Nickname, nil
  47303. }
  47304. // ResetNickname resets all changes to the "nickname" field.
  47305. func (m *WxMutation) ResetNickname() {
  47306. m.nickname = nil
  47307. }
  47308. // SetTel sets the "tel" field.
  47309. func (m *WxMutation) SetTel(s string) {
  47310. m.tel = &s
  47311. }
  47312. // Tel returns the value of the "tel" field in the mutation.
  47313. func (m *WxMutation) Tel() (r string, exists bool) {
  47314. v := m.tel
  47315. if v == nil {
  47316. return
  47317. }
  47318. return *v, true
  47319. }
  47320. // OldTel returns the old "tel" field's value of the Wx entity.
  47321. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47323. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47324. if !m.op.Is(OpUpdateOne) {
  47325. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47326. }
  47327. if m.id == nil || m.oldValue == nil {
  47328. return v, errors.New("OldTel requires an ID field in the mutation")
  47329. }
  47330. oldValue, err := m.oldValue(ctx)
  47331. if err != nil {
  47332. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47333. }
  47334. return oldValue.Tel, nil
  47335. }
  47336. // ResetTel resets all changes to the "tel" field.
  47337. func (m *WxMutation) ResetTel() {
  47338. m.tel = nil
  47339. }
  47340. // SetHeadBig sets the "head_big" field.
  47341. func (m *WxMutation) SetHeadBig(s string) {
  47342. m.head_big = &s
  47343. }
  47344. // HeadBig returns the value of the "head_big" field in the mutation.
  47345. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47346. v := m.head_big
  47347. if v == nil {
  47348. return
  47349. }
  47350. return *v, true
  47351. }
  47352. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47353. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47355. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47356. if !m.op.Is(OpUpdateOne) {
  47357. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47358. }
  47359. if m.id == nil || m.oldValue == nil {
  47360. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47361. }
  47362. oldValue, err := m.oldValue(ctx)
  47363. if err != nil {
  47364. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47365. }
  47366. return oldValue.HeadBig, nil
  47367. }
  47368. // ResetHeadBig resets all changes to the "head_big" field.
  47369. func (m *WxMutation) ResetHeadBig() {
  47370. m.head_big = nil
  47371. }
  47372. // SetOrganizationID sets the "organization_id" field.
  47373. func (m *WxMutation) SetOrganizationID(u uint64) {
  47374. m.organization_id = &u
  47375. m.addorganization_id = nil
  47376. }
  47377. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47378. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47379. v := m.organization_id
  47380. if v == nil {
  47381. return
  47382. }
  47383. return *v, true
  47384. }
  47385. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47386. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47388. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47389. if !m.op.Is(OpUpdateOne) {
  47390. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47391. }
  47392. if m.id == nil || m.oldValue == nil {
  47393. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47394. }
  47395. oldValue, err := m.oldValue(ctx)
  47396. if err != nil {
  47397. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47398. }
  47399. return oldValue.OrganizationID, nil
  47400. }
  47401. // AddOrganizationID adds u to the "organization_id" field.
  47402. func (m *WxMutation) AddOrganizationID(u int64) {
  47403. if m.addorganization_id != nil {
  47404. *m.addorganization_id += u
  47405. } else {
  47406. m.addorganization_id = &u
  47407. }
  47408. }
  47409. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47410. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47411. v := m.addorganization_id
  47412. if v == nil {
  47413. return
  47414. }
  47415. return *v, true
  47416. }
  47417. // ClearOrganizationID clears the value of the "organization_id" field.
  47418. func (m *WxMutation) ClearOrganizationID() {
  47419. m.organization_id = nil
  47420. m.addorganization_id = nil
  47421. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47422. }
  47423. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47424. func (m *WxMutation) OrganizationIDCleared() bool {
  47425. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47426. return ok
  47427. }
  47428. // ResetOrganizationID resets all changes to the "organization_id" field.
  47429. func (m *WxMutation) ResetOrganizationID() {
  47430. m.organization_id = nil
  47431. m.addorganization_id = nil
  47432. delete(m.clearedFields, wx.FieldOrganizationID)
  47433. }
  47434. // SetAgentID sets the "agent_id" field.
  47435. func (m *WxMutation) SetAgentID(u uint64) {
  47436. m.agent = &u
  47437. }
  47438. // AgentID returns the value of the "agent_id" field in the mutation.
  47439. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47440. v := m.agent
  47441. if v == nil {
  47442. return
  47443. }
  47444. return *v, true
  47445. }
  47446. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47447. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47449. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47450. if !m.op.Is(OpUpdateOne) {
  47451. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47452. }
  47453. if m.id == nil || m.oldValue == nil {
  47454. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47455. }
  47456. oldValue, err := m.oldValue(ctx)
  47457. if err != nil {
  47458. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47459. }
  47460. return oldValue.AgentID, nil
  47461. }
  47462. // ResetAgentID resets all changes to the "agent_id" field.
  47463. func (m *WxMutation) ResetAgentID() {
  47464. m.agent = nil
  47465. }
  47466. // SetAPIBase sets the "api_base" field.
  47467. func (m *WxMutation) SetAPIBase(s string) {
  47468. m.api_base = &s
  47469. }
  47470. // APIBase returns the value of the "api_base" field in the mutation.
  47471. func (m *WxMutation) APIBase() (r string, exists bool) {
  47472. v := m.api_base
  47473. if v == nil {
  47474. return
  47475. }
  47476. return *v, true
  47477. }
  47478. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47479. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47481. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47482. if !m.op.Is(OpUpdateOne) {
  47483. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47484. }
  47485. if m.id == nil || m.oldValue == nil {
  47486. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47487. }
  47488. oldValue, err := m.oldValue(ctx)
  47489. if err != nil {
  47490. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47491. }
  47492. return oldValue.APIBase, nil
  47493. }
  47494. // ClearAPIBase clears the value of the "api_base" field.
  47495. func (m *WxMutation) ClearAPIBase() {
  47496. m.api_base = nil
  47497. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47498. }
  47499. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47500. func (m *WxMutation) APIBaseCleared() bool {
  47501. _, ok := m.clearedFields[wx.FieldAPIBase]
  47502. return ok
  47503. }
  47504. // ResetAPIBase resets all changes to the "api_base" field.
  47505. func (m *WxMutation) ResetAPIBase() {
  47506. m.api_base = nil
  47507. delete(m.clearedFields, wx.FieldAPIBase)
  47508. }
  47509. // SetAPIKey sets the "api_key" field.
  47510. func (m *WxMutation) SetAPIKey(s string) {
  47511. m.api_key = &s
  47512. }
  47513. // APIKey returns the value of the "api_key" field in the mutation.
  47514. func (m *WxMutation) APIKey() (r string, exists bool) {
  47515. v := m.api_key
  47516. if v == nil {
  47517. return
  47518. }
  47519. return *v, true
  47520. }
  47521. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47522. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47524. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47525. if !m.op.Is(OpUpdateOne) {
  47526. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47527. }
  47528. if m.id == nil || m.oldValue == nil {
  47529. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47530. }
  47531. oldValue, err := m.oldValue(ctx)
  47532. if err != nil {
  47533. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47534. }
  47535. return oldValue.APIKey, nil
  47536. }
  47537. // ClearAPIKey clears the value of the "api_key" field.
  47538. func (m *WxMutation) ClearAPIKey() {
  47539. m.api_key = nil
  47540. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47541. }
  47542. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47543. func (m *WxMutation) APIKeyCleared() bool {
  47544. _, ok := m.clearedFields[wx.FieldAPIKey]
  47545. return ok
  47546. }
  47547. // ResetAPIKey resets all changes to the "api_key" field.
  47548. func (m *WxMutation) ResetAPIKey() {
  47549. m.api_key = nil
  47550. delete(m.clearedFields, wx.FieldAPIKey)
  47551. }
  47552. // SetAllowList sets the "allow_list" field.
  47553. func (m *WxMutation) SetAllowList(s []string) {
  47554. m.allow_list = &s
  47555. m.appendallow_list = nil
  47556. }
  47557. // AllowList returns the value of the "allow_list" field in the mutation.
  47558. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47559. v := m.allow_list
  47560. if v == nil {
  47561. return
  47562. }
  47563. return *v, true
  47564. }
  47565. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47566. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47568. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47569. if !m.op.Is(OpUpdateOne) {
  47570. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47571. }
  47572. if m.id == nil || m.oldValue == nil {
  47573. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47574. }
  47575. oldValue, err := m.oldValue(ctx)
  47576. if err != nil {
  47577. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47578. }
  47579. return oldValue.AllowList, nil
  47580. }
  47581. // AppendAllowList adds s to the "allow_list" field.
  47582. func (m *WxMutation) AppendAllowList(s []string) {
  47583. m.appendallow_list = append(m.appendallow_list, s...)
  47584. }
  47585. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47586. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47587. if len(m.appendallow_list) == 0 {
  47588. return nil, false
  47589. }
  47590. return m.appendallow_list, true
  47591. }
  47592. // ResetAllowList resets all changes to the "allow_list" field.
  47593. func (m *WxMutation) ResetAllowList() {
  47594. m.allow_list = nil
  47595. m.appendallow_list = nil
  47596. }
  47597. // SetGroupAllowList sets the "group_allow_list" field.
  47598. func (m *WxMutation) SetGroupAllowList(s []string) {
  47599. m.group_allow_list = &s
  47600. m.appendgroup_allow_list = nil
  47601. }
  47602. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47603. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47604. v := m.group_allow_list
  47605. if v == nil {
  47606. return
  47607. }
  47608. return *v, true
  47609. }
  47610. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47611. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47613. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47614. if !m.op.Is(OpUpdateOne) {
  47615. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47616. }
  47617. if m.id == nil || m.oldValue == nil {
  47618. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47619. }
  47620. oldValue, err := m.oldValue(ctx)
  47621. if err != nil {
  47622. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47623. }
  47624. return oldValue.GroupAllowList, nil
  47625. }
  47626. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47627. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47628. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47629. }
  47630. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47631. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47632. if len(m.appendgroup_allow_list) == 0 {
  47633. return nil, false
  47634. }
  47635. return m.appendgroup_allow_list, true
  47636. }
  47637. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47638. func (m *WxMutation) ResetGroupAllowList() {
  47639. m.group_allow_list = nil
  47640. m.appendgroup_allow_list = nil
  47641. }
  47642. // SetBlockList sets the "block_list" field.
  47643. func (m *WxMutation) SetBlockList(s []string) {
  47644. m.block_list = &s
  47645. m.appendblock_list = nil
  47646. }
  47647. // BlockList returns the value of the "block_list" field in the mutation.
  47648. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47649. v := m.block_list
  47650. if v == nil {
  47651. return
  47652. }
  47653. return *v, true
  47654. }
  47655. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47656. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47658. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47659. if !m.op.Is(OpUpdateOne) {
  47660. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47661. }
  47662. if m.id == nil || m.oldValue == nil {
  47663. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47664. }
  47665. oldValue, err := m.oldValue(ctx)
  47666. if err != nil {
  47667. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47668. }
  47669. return oldValue.BlockList, nil
  47670. }
  47671. // AppendBlockList adds s to the "block_list" field.
  47672. func (m *WxMutation) AppendBlockList(s []string) {
  47673. m.appendblock_list = append(m.appendblock_list, s...)
  47674. }
  47675. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47676. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47677. if len(m.appendblock_list) == 0 {
  47678. return nil, false
  47679. }
  47680. return m.appendblock_list, true
  47681. }
  47682. // ResetBlockList resets all changes to the "block_list" field.
  47683. func (m *WxMutation) ResetBlockList() {
  47684. m.block_list = nil
  47685. m.appendblock_list = nil
  47686. }
  47687. // SetGroupBlockList sets the "group_block_list" field.
  47688. func (m *WxMutation) SetGroupBlockList(s []string) {
  47689. m.group_block_list = &s
  47690. m.appendgroup_block_list = nil
  47691. }
  47692. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47693. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47694. v := m.group_block_list
  47695. if v == nil {
  47696. return
  47697. }
  47698. return *v, true
  47699. }
  47700. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47701. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47703. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47704. if !m.op.Is(OpUpdateOne) {
  47705. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47706. }
  47707. if m.id == nil || m.oldValue == nil {
  47708. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47709. }
  47710. oldValue, err := m.oldValue(ctx)
  47711. if err != nil {
  47712. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47713. }
  47714. return oldValue.GroupBlockList, nil
  47715. }
  47716. // AppendGroupBlockList adds s to the "group_block_list" field.
  47717. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47718. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47719. }
  47720. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47721. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47722. if len(m.appendgroup_block_list) == 0 {
  47723. return nil, false
  47724. }
  47725. return m.appendgroup_block_list, true
  47726. }
  47727. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47728. func (m *WxMutation) ResetGroupBlockList() {
  47729. m.group_block_list = nil
  47730. m.appendgroup_block_list = nil
  47731. }
  47732. // SetCtype sets the "ctype" field.
  47733. func (m *WxMutation) SetCtype(u uint64) {
  47734. m.ctype = &u
  47735. m.addctype = nil
  47736. }
  47737. // Ctype returns the value of the "ctype" field in the mutation.
  47738. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47739. v := m.ctype
  47740. if v == nil {
  47741. return
  47742. }
  47743. return *v, true
  47744. }
  47745. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47746. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47748. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47749. if !m.op.Is(OpUpdateOne) {
  47750. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47751. }
  47752. if m.id == nil || m.oldValue == nil {
  47753. return v, errors.New("OldCtype requires an ID field in the mutation")
  47754. }
  47755. oldValue, err := m.oldValue(ctx)
  47756. if err != nil {
  47757. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47758. }
  47759. return oldValue.Ctype, nil
  47760. }
  47761. // AddCtype adds u to the "ctype" field.
  47762. func (m *WxMutation) AddCtype(u int64) {
  47763. if m.addctype != nil {
  47764. *m.addctype += u
  47765. } else {
  47766. m.addctype = &u
  47767. }
  47768. }
  47769. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  47770. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  47771. v := m.addctype
  47772. if v == nil {
  47773. return
  47774. }
  47775. return *v, true
  47776. }
  47777. // ClearCtype clears the value of the "ctype" field.
  47778. func (m *WxMutation) ClearCtype() {
  47779. m.ctype = nil
  47780. m.addctype = nil
  47781. m.clearedFields[wx.FieldCtype] = struct{}{}
  47782. }
  47783. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  47784. func (m *WxMutation) CtypeCleared() bool {
  47785. _, ok := m.clearedFields[wx.FieldCtype]
  47786. return ok
  47787. }
  47788. // ResetCtype resets all changes to the "ctype" field.
  47789. func (m *WxMutation) ResetCtype() {
  47790. m.ctype = nil
  47791. m.addctype = nil
  47792. delete(m.clearedFields, wx.FieldCtype)
  47793. }
  47794. // ClearServer clears the "server" edge to the Server entity.
  47795. func (m *WxMutation) ClearServer() {
  47796. m.clearedserver = true
  47797. m.clearedFields[wx.FieldServerID] = struct{}{}
  47798. }
  47799. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  47800. func (m *WxMutation) ServerCleared() bool {
  47801. return m.ServerIDCleared() || m.clearedserver
  47802. }
  47803. // ServerIDs returns the "server" edge IDs in the mutation.
  47804. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47805. // ServerID instead. It exists only for internal usage by the builders.
  47806. func (m *WxMutation) ServerIDs() (ids []uint64) {
  47807. if id := m.server; id != nil {
  47808. ids = append(ids, *id)
  47809. }
  47810. return
  47811. }
  47812. // ResetServer resets all changes to the "server" edge.
  47813. func (m *WxMutation) ResetServer() {
  47814. m.server = nil
  47815. m.clearedserver = false
  47816. }
  47817. // ClearAgent clears the "agent" edge to the Agent entity.
  47818. func (m *WxMutation) ClearAgent() {
  47819. m.clearedagent = true
  47820. m.clearedFields[wx.FieldAgentID] = struct{}{}
  47821. }
  47822. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47823. func (m *WxMutation) AgentCleared() bool {
  47824. return m.clearedagent
  47825. }
  47826. // AgentIDs returns the "agent" edge IDs in the mutation.
  47827. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47828. // AgentID instead. It exists only for internal usage by the builders.
  47829. func (m *WxMutation) AgentIDs() (ids []uint64) {
  47830. if id := m.agent; id != nil {
  47831. ids = append(ids, *id)
  47832. }
  47833. return
  47834. }
  47835. // ResetAgent resets all changes to the "agent" edge.
  47836. func (m *WxMutation) ResetAgent() {
  47837. m.agent = nil
  47838. m.clearedagent = false
  47839. }
  47840. // Where appends a list predicates to the WxMutation builder.
  47841. func (m *WxMutation) Where(ps ...predicate.Wx) {
  47842. m.predicates = append(m.predicates, ps...)
  47843. }
  47844. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  47845. // users can use type-assertion to append predicates that do not depend on any generated package.
  47846. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  47847. p := make([]predicate.Wx, len(ps))
  47848. for i := range ps {
  47849. p[i] = ps[i]
  47850. }
  47851. m.Where(p...)
  47852. }
  47853. // Op returns the operation name.
  47854. func (m *WxMutation) Op() Op {
  47855. return m.op
  47856. }
  47857. // SetOp allows setting the mutation operation.
  47858. func (m *WxMutation) SetOp(op Op) {
  47859. m.op = op
  47860. }
  47861. // Type returns the node type of this mutation (Wx).
  47862. func (m *WxMutation) Type() string {
  47863. return m.typ
  47864. }
  47865. // Fields returns all fields that were changed during this mutation. Note that in
  47866. // order to get all numeric fields that were incremented/decremented, call
  47867. // AddedFields().
  47868. func (m *WxMutation) Fields() []string {
  47869. fields := make([]string, 0, 22)
  47870. if m.created_at != nil {
  47871. fields = append(fields, wx.FieldCreatedAt)
  47872. }
  47873. if m.updated_at != nil {
  47874. fields = append(fields, wx.FieldUpdatedAt)
  47875. }
  47876. if m.status != nil {
  47877. fields = append(fields, wx.FieldStatus)
  47878. }
  47879. if m.deleted_at != nil {
  47880. fields = append(fields, wx.FieldDeletedAt)
  47881. }
  47882. if m.server != nil {
  47883. fields = append(fields, wx.FieldServerID)
  47884. }
  47885. if m.port != nil {
  47886. fields = append(fields, wx.FieldPort)
  47887. }
  47888. if m.process_id != nil {
  47889. fields = append(fields, wx.FieldProcessID)
  47890. }
  47891. if m.callback != nil {
  47892. fields = append(fields, wx.FieldCallback)
  47893. }
  47894. if m.wxid != nil {
  47895. fields = append(fields, wx.FieldWxid)
  47896. }
  47897. if m.account != nil {
  47898. fields = append(fields, wx.FieldAccount)
  47899. }
  47900. if m.nickname != nil {
  47901. fields = append(fields, wx.FieldNickname)
  47902. }
  47903. if m.tel != nil {
  47904. fields = append(fields, wx.FieldTel)
  47905. }
  47906. if m.head_big != nil {
  47907. fields = append(fields, wx.FieldHeadBig)
  47908. }
  47909. if m.organization_id != nil {
  47910. fields = append(fields, wx.FieldOrganizationID)
  47911. }
  47912. if m.agent != nil {
  47913. fields = append(fields, wx.FieldAgentID)
  47914. }
  47915. if m.api_base != nil {
  47916. fields = append(fields, wx.FieldAPIBase)
  47917. }
  47918. if m.api_key != nil {
  47919. fields = append(fields, wx.FieldAPIKey)
  47920. }
  47921. if m.allow_list != nil {
  47922. fields = append(fields, wx.FieldAllowList)
  47923. }
  47924. if m.group_allow_list != nil {
  47925. fields = append(fields, wx.FieldGroupAllowList)
  47926. }
  47927. if m.block_list != nil {
  47928. fields = append(fields, wx.FieldBlockList)
  47929. }
  47930. if m.group_block_list != nil {
  47931. fields = append(fields, wx.FieldGroupBlockList)
  47932. }
  47933. if m.ctype != nil {
  47934. fields = append(fields, wx.FieldCtype)
  47935. }
  47936. return fields
  47937. }
  47938. // Field returns the value of a field with the given name. The second boolean
  47939. // return value indicates that this field was not set, or was not defined in the
  47940. // schema.
  47941. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  47942. switch name {
  47943. case wx.FieldCreatedAt:
  47944. return m.CreatedAt()
  47945. case wx.FieldUpdatedAt:
  47946. return m.UpdatedAt()
  47947. case wx.FieldStatus:
  47948. return m.Status()
  47949. case wx.FieldDeletedAt:
  47950. return m.DeletedAt()
  47951. case wx.FieldServerID:
  47952. return m.ServerID()
  47953. case wx.FieldPort:
  47954. return m.Port()
  47955. case wx.FieldProcessID:
  47956. return m.ProcessID()
  47957. case wx.FieldCallback:
  47958. return m.Callback()
  47959. case wx.FieldWxid:
  47960. return m.Wxid()
  47961. case wx.FieldAccount:
  47962. return m.Account()
  47963. case wx.FieldNickname:
  47964. return m.Nickname()
  47965. case wx.FieldTel:
  47966. return m.Tel()
  47967. case wx.FieldHeadBig:
  47968. return m.HeadBig()
  47969. case wx.FieldOrganizationID:
  47970. return m.OrganizationID()
  47971. case wx.FieldAgentID:
  47972. return m.AgentID()
  47973. case wx.FieldAPIBase:
  47974. return m.APIBase()
  47975. case wx.FieldAPIKey:
  47976. return m.APIKey()
  47977. case wx.FieldAllowList:
  47978. return m.AllowList()
  47979. case wx.FieldGroupAllowList:
  47980. return m.GroupAllowList()
  47981. case wx.FieldBlockList:
  47982. return m.BlockList()
  47983. case wx.FieldGroupBlockList:
  47984. return m.GroupBlockList()
  47985. case wx.FieldCtype:
  47986. return m.Ctype()
  47987. }
  47988. return nil, false
  47989. }
  47990. // OldField returns the old value of the field from the database. An error is
  47991. // returned if the mutation operation is not UpdateOne, or the query to the
  47992. // database failed.
  47993. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47994. switch name {
  47995. case wx.FieldCreatedAt:
  47996. return m.OldCreatedAt(ctx)
  47997. case wx.FieldUpdatedAt:
  47998. return m.OldUpdatedAt(ctx)
  47999. case wx.FieldStatus:
  48000. return m.OldStatus(ctx)
  48001. case wx.FieldDeletedAt:
  48002. return m.OldDeletedAt(ctx)
  48003. case wx.FieldServerID:
  48004. return m.OldServerID(ctx)
  48005. case wx.FieldPort:
  48006. return m.OldPort(ctx)
  48007. case wx.FieldProcessID:
  48008. return m.OldProcessID(ctx)
  48009. case wx.FieldCallback:
  48010. return m.OldCallback(ctx)
  48011. case wx.FieldWxid:
  48012. return m.OldWxid(ctx)
  48013. case wx.FieldAccount:
  48014. return m.OldAccount(ctx)
  48015. case wx.FieldNickname:
  48016. return m.OldNickname(ctx)
  48017. case wx.FieldTel:
  48018. return m.OldTel(ctx)
  48019. case wx.FieldHeadBig:
  48020. return m.OldHeadBig(ctx)
  48021. case wx.FieldOrganizationID:
  48022. return m.OldOrganizationID(ctx)
  48023. case wx.FieldAgentID:
  48024. return m.OldAgentID(ctx)
  48025. case wx.FieldAPIBase:
  48026. return m.OldAPIBase(ctx)
  48027. case wx.FieldAPIKey:
  48028. return m.OldAPIKey(ctx)
  48029. case wx.FieldAllowList:
  48030. return m.OldAllowList(ctx)
  48031. case wx.FieldGroupAllowList:
  48032. return m.OldGroupAllowList(ctx)
  48033. case wx.FieldBlockList:
  48034. return m.OldBlockList(ctx)
  48035. case wx.FieldGroupBlockList:
  48036. return m.OldGroupBlockList(ctx)
  48037. case wx.FieldCtype:
  48038. return m.OldCtype(ctx)
  48039. }
  48040. return nil, fmt.Errorf("unknown Wx field %s", name)
  48041. }
  48042. // SetField sets the value of a field with the given name. It returns an error if
  48043. // the field is not defined in the schema, or if the type mismatched the field
  48044. // type.
  48045. func (m *WxMutation) SetField(name string, value ent.Value) error {
  48046. switch name {
  48047. case wx.FieldCreatedAt:
  48048. v, ok := value.(time.Time)
  48049. if !ok {
  48050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48051. }
  48052. m.SetCreatedAt(v)
  48053. return nil
  48054. case wx.FieldUpdatedAt:
  48055. v, ok := value.(time.Time)
  48056. if !ok {
  48057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48058. }
  48059. m.SetUpdatedAt(v)
  48060. return nil
  48061. case wx.FieldStatus:
  48062. v, ok := value.(uint8)
  48063. if !ok {
  48064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48065. }
  48066. m.SetStatus(v)
  48067. return nil
  48068. case wx.FieldDeletedAt:
  48069. v, ok := value.(time.Time)
  48070. if !ok {
  48071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48072. }
  48073. m.SetDeletedAt(v)
  48074. return nil
  48075. case wx.FieldServerID:
  48076. v, ok := value.(uint64)
  48077. if !ok {
  48078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48079. }
  48080. m.SetServerID(v)
  48081. return nil
  48082. case wx.FieldPort:
  48083. v, ok := value.(string)
  48084. if !ok {
  48085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48086. }
  48087. m.SetPort(v)
  48088. return nil
  48089. case wx.FieldProcessID:
  48090. v, ok := value.(string)
  48091. if !ok {
  48092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48093. }
  48094. m.SetProcessID(v)
  48095. return nil
  48096. case wx.FieldCallback:
  48097. v, ok := value.(string)
  48098. if !ok {
  48099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48100. }
  48101. m.SetCallback(v)
  48102. return nil
  48103. case wx.FieldWxid:
  48104. v, ok := value.(string)
  48105. if !ok {
  48106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48107. }
  48108. m.SetWxid(v)
  48109. return nil
  48110. case wx.FieldAccount:
  48111. v, ok := value.(string)
  48112. if !ok {
  48113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48114. }
  48115. m.SetAccount(v)
  48116. return nil
  48117. case wx.FieldNickname:
  48118. v, ok := value.(string)
  48119. if !ok {
  48120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48121. }
  48122. m.SetNickname(v)
  48123. return nil
  48124. case wx.FieldTel:
  48125. v, ok := value.(string)
  48126. if !ok {
  48127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48128. }
  48129. m.SetTel(v)
  48130. return nil
  48131. case wx.FieldHeadBig:
  48132. v, ok := value.(string)
  48133. if !ok {
  48134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48135. }
  48136. m.SetHeadBig(v)
  48137. return nil
  48138. case wx.FieldOrganizationID:
  48139. v, ok := value.(uint64)
  48140. if !ok {
  48141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48142. }
  48143. m.SetOrganizationID(v)
  48144. return nil
  48145. case wx.FieldAgentID:
  48146. v, ok := value.(uint64)
  48147. if !ok {
  48148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48149. }
  48150. m.SetAgentID(v)
  48151. return nil
  48152. case wx.FieldAPIBase:
  48153. v, ok := value.(string)
  48154. if !ok {
  48155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48156. }
  48157. m.SetAPIBase(v)
  48158. return nil
  48159. case wx.FieldAPIKey:
  48160. v, ok := value.(string)
  48161. if !ok {
  48162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48163. }
  48164. m.SetAPIKey(v)
  48165. return nil
  48166. case wx.FieldAllowList:
  48167. v, ok := value.([]string)
  48168. if !ok {
  48169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48170. }
  48171. m.SetAllowList(v)
  48172. return nil
  48173. case wx.FieldGroupAllowList:
  48174. v, ok := value.([]string)
  48175. if !ok {
  48176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48177. }
  48178. m.SetGroupAllowList(v)
  48179. return nil
  48180. case wx.FieldBlockList:
  48181. v, ok := value.([]string)
  48182. if !ok {
  48183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48184. }
  48185. m.SetBlockList(v)
  48186. return nil
  48187. case wx.FieldGroupBlockList:
  48188. v, ok := value.([]string)
  48189. if !ok {
  48190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48191. }
  48192. m.SetGroupBlockList(v)
  48193. return nil
  48194. case wx.FieldCtype:
  48195. v, ok := value.(uint64)
  48196. if !ok {
  48197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48198. }
  48199. m.SetCtype(v)
  48200. return nil
  48201. }
  48202. return fmt.Errorf("unknown Wx field %s", name)
  48203. }
  48204. // AddedFields returns all numeric fields that were incremented/decremented during
  48205. // this mutation.
  48206. func (m *WxMutation) AddedFields() []string {
  48207. var fields []string
  48208. if m.addstatus != nil {
  48209. fields = append(fields, wx.FieldStatus)
  48210. }
  48211. if m.addorganization_id != nil {
  48212. fields = append(fields, wx.FieldOrganizationID)
  48213. }
  48214. if m.addctype != nil {
  48215. fields = append(fields, wx.FieldCtype)
  48216. }
  48217. return fields
  48218. }
  48219. // AddedField returns the numeric value that was incremented/decremented on a field
  48220. // with the given name. The second boolean return value indicates that this field
  48221. // was not set, or was not defined in the schema.
  48222. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48223. switch name {
  48224. case wx.FieldStatus:
  48225. return m.AddedStatus()
  48226. case wx.FieldOrganizationID:
  48227. return m.AddedOrganizationID()
  48228. case wx.FieldCtype:
  48229. return m.AddedCtype()
  48230. }
  48231. return nil, false
  48232. }
  48233. // AddField adds the value to the field with the given name. It returns an error if
  48234. // the field is not defined in the schema, or if the type mismatched the field
  48235. // type.
  48236. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48237. switch name {
  48238. case wx.FieldStatus:
  48239. v, ok := value.(int8)
  48240. if !ok {
  48241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48242. }
  48243. m.AddStatus(v)
  48244. return nil
  48245. case wx.FieldOrganizationID:
  48246. v, ok := value.(int64)
  48247. if !ok {
  48248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48249. }
  48250. m.AddOrganizationID(v)
  48251. return nil
  48252. case wx.FieldCtype:
  48253. v, ok := value.(int64)
  48254. if !ok {
  48255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48256. }
  48257. m.AddCtype(v)
  48258. return nil
  48259. }
  48260. return fmt.Errorf("unknown Wx numeric field %s", name)
  48261. }
  48262. // ClearedFields returns all nullable fields that were cleared during this
  48263. // mutation.
  48264. func (m *WxMutation) ClearedFields() []string {
  48265. var fields []string
  48266. if m.FieldCleared(wx.FieldStatus) {
  48267. fields = append(fields, wx.FieldStatus)
  48268. }
  48269. if m.FieldCleared(wx.FieldDeletedAt) {
  48270. fields = append(fields, wx.FieldDeletedAt)
  48271. }
  48272. if m.FieldCleared(wx.FieldServerID) {
  48273. fields = append(fields, wx.FieldServerID)
  48274. }
  48275. if m.FieldCleared(wx.FieldOrganizationID) {
  48276. fields = append(fields, wx.FieldOrganizationID)
  48277. }
  48278. if m.FieldCleared(wx.FieldAPIBase) {
  48279. fields = append(fields, wx.FieldAPIBase)
  48280. }
  48281. if m.FieldCleared(wx.FieldAPIKey) {
  48282. fields = append(fields, wx.FieldAPIKey)
  48283. }
  48284. if m.FieldCleared(wx.FieldCtype) {
  48285. fields = append(fields, wx.FieldCtype)
  48286. }
  48287. return fields
  48288. }
  48289. // FieldCleared returns a boolean indicating if a field with the given name was
  48290. // cleared in this mutation.
  48291. func (m *WxMutation) FieldCleared(name string) bool {
  48292. _, ok := m.clearedFields[name]
  48293. return ok
  48294. }
  48295. // ClearField clears the value of the field with the given name. It returns an
  48296. // error if the field is not defined in the schema.
  48297. func (m *WxMutation) ClearField(name string) error {
  48298. switch name {
  48299. case wx.FieldStatus:
  48300. m.ClearStatus()
  48301. return nil
  48302. case wx.FieldDeletedAt:
  48303. m.ClearDeletedAt()
  48304. return nil
  48305. case wx.FieldServerID:
  48306. m.ClearServerID()
  48307. return nil
  48308. case wx.FieldOrganizationID:
  48309. m.ClearOrganizationID()
  48310. return nil
  48311. case wx.FieldAPIBase:
  48312. m.ClearAPIBase()
  48313. return nil
  48314. case wx.FieldAPIKey:
  48315. m.ClearAPIKey()
  48316. return nil
  48317. case wx.FieldCtype:
  48318. m.ClearCtype()
  48319. return nil
  48320. }
  48321. return fmt.Errorf("unknown Wx nullable field %s", name)
  48322. }
  48323. // ResetField resets all changes in the mutation for the field with the given name.
  48324. // It returns an error if the field is not defined in the schema.
  48325. func (m *WxMutation) ResetField(name string) error {
  48326. switch name {
  48327. case wx.FieldCreatedAt:
  48328. m.ResetCreatedAt()
  48329. return nil
  48330. case wx.FieldUpdatedAt:
  48331. m.ResetUpdatedAt()
  48332. return nil
  48333. case wx.FieldStatus:
  48334. m.ResetStatus()
  48335. return nil
  48336. case wx.FieldDeletedAt:
  48337. m.ResetDeletedAt()
  48338. return nil
  48339. case wx.FieldServerID:
  48340. m.ResetServerID()
  48341. return nil
  48342. case wx.FieldPort:
  48343. m.ResetPort()
  48344. return nil
  48345. case wx.FieldProcessID:
  48346. m.ResetProcessID()
  48347. return nil
  48348. case wx.FieldCallback:
  48349. m.ResetCallback()
  48350. return nil
  48351. case wx.FieldWxid:
  48352. m.ResetWxid()
  48353. return nil
  48354. case wx.FieldAccount:
  48355. m.ResetAccount()
  48356. return nil
  48357. case wx.FieldNickname:
  48358. m.ResetNickname()
  48359. return nil
  48360. case wx.FieldTel:
  48361. m.ResetTel()
  48362. return nil
  48363. case wx.FieldHeadBig:
  48364. m.ResetHeadBig()
  48365. return nil
  48366. case wx.FieldOrganizationID:
  48367. m.ResetOrganizationID()
  48368. return nil
  48369. case wx.FieldAgentID:
  48370. m.ResetAgentID()
  48371. return nil
  48372. case wx.FieldAPIBase:
  48373. m.ResetAPIBase()
  48374. return nil
  48375. case wx.FieldAPIKey:
  48376. m.ResetAPIKey()
  48377. return nil
  48378. case wx.FieldAllowList:
  48379. m.ResetAllowList()
  48380. return nil
  48381. case wx.FieldGroupAllowList:
  48382. m.ResetGroupAllowList()
  48383. return nil
  48384. case wx.FieldBlockList:
  48385. m.ResetBlockList()
  48386. return nil
  48387. case wx.FieldGroupBlockList:
  48388. m.ResetGroupBlockList()
  48389. return nil
  48390. case wx.FieldCtype:
  48391. m.ResetCtype()
  48392. return nil
  48393. }
  48394. return fmt.Errorf("unknown Wx field %s", name)
  48395. }
  48396. // AddedEdges returns all edge names that were set/added in this mutation.
  48397. func (m *WxMutation) AddedEdges() []string {
  48398. edges := make([]string, 0, 2)
  48399. if m.server != nil {
  48400. edges = append(edges, wx.EdgeServer)
  48401. }
  48402. if m.agent != nil {
  48403. edges = append(edges, wx.EdgeAgent)
  48404. }
  48405. return edges
  48406. }
  48407. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48408. // name in this mutation.
  48409. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48410. switch name {
  48411. case wx.EdgeServer:
  48412. if id := m.server; id != nil {
  48413. return []ent.Value{*id}
  48414. }
  48415. case wx.EdgeAgent:
  48416. if id := m.agent; id != nil {
  48417. return []ent.Value{*id}
  48418. }
  48419. }
  48420. return nil
  48421. }
  48422. // RemovedEdges returns all edge names that were removed in this mutation.
  48423. func (m *WxMutation) RemovedEdges() []string {
  48424. edges := make([]string, 0, 2)
  48425. return edges
  48426. }
  48427. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48428. // the given name in this mutation.
  48429. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48430. return nil
  48431. }
  48432. // ClearedEdges returns all edge names that were cleared in this mutation.
  48433. func (m *WxMutation) ClearedEdges() []string {
  48434. edges := make([]string, 0, 2)
  48435. if m.clearedserver {
  48436. edges = append(edges, wx.EdgeServer)
  48437. }
  48438. if m.clearedagent {
  48439. edges = append(edges, wx.EdgeAgent)
  48440. }
  48441. return edges
  48442. }
  48443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48444. // was cleared in this mutation.
  48445. func (m *WxMutation) EdgeCleared(name string) bool {
  48446. switch name {
  48447. case wx.EdgeServer:
  48448. return m.clearedserver
  48449. case wx.EdgeAgent:
  48450. return m.clearedagent
  48451. }
  48452. return false
  48453. }
  48454. // ClearEdge clears the value of the edge with the given name. It returns an error
  48455. // if that edge is not defined in the schema.
  48456. func (m *WxMutation) ClearEdge(name string) error {
  48457. switch name {
  48458. case wx.EdgeServer:
  48459. m.ClearServer()
  48460. return nil
  48461. case wx.EdgeAgent:
  48462. m.ClearAgent()
  48463. return nil
  48464. }
  48465. return fmt.Errorf("unknown Wx unique edge %s", name)
  48466. }
  48467. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48468. // It returns an error if the edge is not defined in the schema.
  48469. func (m *WxMutation) ResetEdge(name string) error {
  48470. switch name {
  48471. case wx.EdgeServer:
  48472. m.ResetServer()
  48473. return nil
  48474. case wx.EdgeAgent:
  48475. m.ResetAgent()
  48476. return nil
  48477. }
  48478. return fmt.Errorf("unknown Wx edge %s", name)
  48479. }
  48480. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48481. type WxCardMutation struct {
  48482. config
  48483. op Op
  48484. typ string
  48485. id *uint64
  48486. created_at *time.Time
  48487. updated_at *time.Time
  48488. deleted_at *time.Time
  48489. user_id *uint64
  48490. adduser_id *int64
  48491. wx_user_id *uint64
  48492. addwx_user_id *int64
  48493. avatar *string
  48494. logo *string
  48495. name *string
  48496. company *string
  48497. address *string
  48498. phone *string
  48499. official_account *string
  48500. wechat_account *string
  48501. email *string
  48502. api_base *string
  48503. api_key *string
  48504. ai_info *string
  48505. intro *string
  48506. clearedFields map[string]struct{}
  48507. done bool
  48508. oldValue func(context.Context) (*WxCard, error)
  48509. predicates []predicate.WxCard
  48510. }
  48511. var _ ent.Mutation = (*WxCardMutation)(nil)
  48512. // wxcardOption allows management of the mutation configuration using functional options.
  48513. type wxcardOption func(*WxCardMutation)
  48514. // newWxCardMutation creates new mutation for the WxCard entity.
  48515. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48516. m := &WxCardMutation{
  48517. config: c,
  48518. op: op,
  48519. typ: TypeWxCard,
  48520. clearedFields: make(map[string]struct{}),
  48521. }
  48522. for _, opt := range opts {
  48523. opt(m)
  48524. }
  48525. return m
  48526. }
  48527. // withWxCardID sets the ID field of the mutation.
  48528. func withWxCardID(id uint64) wxcardOption {
  48529. return func(m *WxCardMutation) {
  48530. var (
  48531. err error
  48532. once sync.Once
  48533. value *WxCard
  48534. )
  48535. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48536. once.Do(func() {
  48537. if m.done {
  48538. err = errors.New("querying old values post mutation is not allowed")
  48539. } else {
  48540. value, err = m.Client().WxCard.Get(ctx, id)
  48541. }
  48542. })
  48543. return value, err
  48544. }
  48545. m.id = &id
  48546. }
  48547. }
  48548. // withWxCard sets the old WxCard of the mutation.
  48549. func withWxCard(node *WxCard) wxcardOption {
  48550. return func(m *WxCardMutation) {
  48551. m.oldValue = func(context.Context) (*WxCard, error) {
  48552. return node, nil
  48553. }
  48554. m.id = &node.ID
  48555. }
  48556. }
  48557. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48558. // executed in a transaction (ent.Tx), a transactional client is returned.
  48559. func (m WxCardMutation) Client() *Client {
  48560. client := &Client{config: m.config}
  48561. client.init()
  48562. return client
  48563. }
  48564. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48565. // it returns an error otherwise.
  48566. func (m WxCardMutation) Tx() (*Tx, error) {
  48567. if _, ok := m.driver.(*txDriver); !ok {
  48568. return nil, errors.New("ent: mutation is not running in a transaction")
  48569. }
  48570. tx := &Tx{config: m.config}
  48571. tx.init()
  48572. return tx, nil
  48573. }
  48574. // SetID sets the value of the id field. Note that this
  48575. // operation is only accepted on creation of WxCard entities.
  48576. func (m *WxCardMutation) SetID(id uint64) {
  48577. m.id = &id
  48578. }
  48579. // ID returns the ID value in the mutation. Note that the ID is only available
  48580. // if it was provided to the builder or after it was returned from the database.
  48581. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48582. if m.id == nil {
  48583. return
  48584. }
  48585. return *m.id, true
  48586. }
  48587. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48588. // That means, if the mutation is applied within a transaction with an isolation level such
  48589. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48590. // or updated by the mutation.
  48591. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48592. switch {
  48593. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48594. id, exists := m.ID()
  48595. if exists {
  48596. return []uint64{id}, nil
  48597. }
  48598. fallthrough
  48599. case m.op.Is(OpUpdate | OpDelete):
  48600. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48601. default:
  48602. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48603. }
  48604. }
  48605. // SetCreatedAt sets the "created_at" field.
  48606. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48607. m.created_at = &t
  48608. }
  48609. // CreatedAt returns the value of the "created_at" field in the mutation.
  48610. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48611. v := m.created_at
  48612. if v == nil {
  48613. return
  48614. }
  48615. return *v, true
  48616. }
  48617. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48618. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48620. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48621. if !m.op.Is(OpUpdateOne) {
  48622. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48623. }
  48624. if m.id == nil || m.oldValue == nil {
  48625. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48626. }
  48627. oldValue, err := m.oldValue(ctx)
  48628. if err != nil {
  48629. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48630. }
  48631. return oldValue.CreatedAt, nil
  48632. }
  48633. // ResetCreatedAt resets all changes to the "created_at" field.
  48634. func (m *WxCardMutation) ResetCreatedAt() {
  48635. m.created_at = nil
  48636. }
  48637. // SetUpdatedAt sets the "updated_at" field.
  48638. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48639. m.updated_at = &t
  48640. }
  48641. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48642. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48643. v := m.updated_at
  48644. if v == nil {
  48645. return
  48646. }
  48647. return *v, true
  48648. }
  48649. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48650. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48652. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48653. if !m.op.Is(OpUpdateOne) {
  48654. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48655. }
  48656. if m.id == nil || m.oldValue == nil {
  48657. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48658. }
  48659. oldValue, err := m.oldValue(ctx)
  48660. if err != nil {
  48661. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48662. }
  48663. return oldValue.UpdatedAt, nil
  48664. }
  48665. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48666. func (m *WxCardMutation) ResetUpdatedAt() {
  48667. m.updated_at = nil
  48668. }
  48669. // SetDeletedAt sets the "deleted_at" field.
  48670. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48671. m.deleted_at = &t
  48672. }
  48673. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48674. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48675. v := m.deleted_at
  48676. if v == nil {
  48677. return
  48678. }
  48679. return *v, true
  48680. }
  48681. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48682. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48684. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48685. if !m.op.Is(OpUpdateOne) {
  48686. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48687. }
  48688. if m.id == nil || m.oldValue == nil {
  48689. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48690. }
  48691. oldValue, err := m.oldValue(ctx)
  48692. if err != nil {
  48693. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48694. }
  48695. return oldValue.DeletedAt, nil
  48696. }
  48697. // ClearDeletedAt clears the value of the "deleted_at" field.
  48698. func (m *WxCardMutation) ClearDeletedAt() {
  48699. m.deleted_at = nil
  48700. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48701. }
  48702. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48703. func (m *WxCardMutation) DeletedAtCleared() bool {
  48704. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48705. return ok
  48706. }
  48707. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48708. func (m *WxCardMutation) ResetDeletedAt() {
  48709. m.deleted_at = nil
  48710. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48711. }
  48712. // SetUserID sets the "user_id" field.
  48713. func (m *WxCardMutation) SetUserID(u uint64) {
  48714. m.user_id = &u
  48715. m.adduser_id = nil
  48716. }
  48717. // UserID returns the value of the "user_id" field in the mutation.
  48718. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48719. v := m.user_id
  48720. if v == nil {
  48721. return
  48722. }
  48723. return *v, true
  48724. }
  48725. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48726. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48728. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48729. if !m.op.Is(OpUpdateOne) {
  48730. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48731. }
  48732. if m.id == nil || m.oldValue == nil {
  48733. return v, errors.New("OldUserID requires an ID field in the mutation")
  48734. }
  48735. oldValue, err := m.oldValue(ctx)
  48736. if err != nil {
  48737. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48738. }
  48739. return oldValue.UserID, nil
  48740. }
  48741. // AddUserID adds u to the "user_id" field.
  48742. func (m *WxCardMutation) AddUserID(u int64) {
  48743. if m.adduser_id != nil {
  48744. *m.adduser_id += u
  48745. } else {
  48746. m.adduser_id = &u
  48747. }
  48748. }
  48749. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48750. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48751. v := m.adduser_id
  48752. if v == nil {
  48753. return
  48754. }
  48755. return *v, true
  48756. }
  48757. // ClearUserID clears the value of the "user_id" field.
  48758. func (m *WxCardMutation) ClearUserID() {
  48759. m.user_id = nil
  48760. m.adduser_id = nil
  48761. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48762. }
  48763. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48764. func (m *WxCardMutation) UserIDCleared() bool {
  48765. _, ok := m.clearedFields[wxcard.FieldUserID]
  48766. return ok
  48767. }
  48768. // ResetUserID resets all changes to the "user_id" field.
  48769. func (m *WxCardMutation) ResetUserID() {
  48770. m.user_id = nil
  48771. m.adduser_id = nil
  48772. delete(m.clearedFields, wxcard.FieldUserID)
  48773. }
  48774. // SetWxUserID sets the "wx_user_id" field.
  48775. func (m *WxCardMutation) SetWxUserID(u uint64) {
  48776. m.wx_user_id = &u
  48777. m.addwx_user_id = nil
  48778. }
  48779. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  48780. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  48781. v := m.wx_user_id
  48782. if v == nil {
  48783. return
  48784. }
  48785. return *v, true
  48786. }
  48787. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  48788. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48790. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  48791. if !m.op.Is(OpUpdateOne) {
  48792. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  48793. }
  48794. if m.id == nil || m.oldValue == nil {
  48795. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  48796. }
  48797. oldValue, err := m.oldValue(ctx)
  48798. if err != nil {
  48799. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  48800. }
  48801. return oldValue.WxUserID, nil
  48802. }
  48803. // AddWxUserID adds u to the "wx_user_id" field.
  48804. func (m *WxCardMutation) AddWxUserID(u int64) {
  48805. if m.addwx_user_id != nil {
  48806. *m.addwx_user_id += u
  48807. } else {
  48808. m.addwx_user_id = &u
  48809. }
  48810. }
  48811. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  48812. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  48813. v := m.addwx_user_id
  48814. if v == nil {
  48815. return
  48816. }
  48817. return *v, true
  48818. }
  48819. // ClearWxUserID clears the value of the "wx_user_id" field.
  48820. func (m *WxCardMutation) ClearWxUserID() {
  48821. m.wx_user_id = nil
  48822. m.addwx_user_id = nil
  48823. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  48824. }
  48825. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  48826. func (m *WxCardMutation) WxUserIDCleared() bool {
  48827. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  48828. return ok
  48829. }
  48830. // ResetWxUserID resets all changes to the "wx_user_id" field.
  48831. func (m *WxCardMutation) ResetWxUserID() {
  48832. m.wx_user_id = nil
  48833. m.addwx_user_id = nil
  48834. delete(m.clearedFields, wxcard.FieldWxUserID)
  48835. }
  48836. // SetAvatar sets the "avatar" field.
  48837. func (m *WxCardMutation) SetAvatar(s string) {
  48838. m.avatar = &s
  48839. }
  48840. // Avatar returns the value of the "avatar" field in the mutation.
  48841. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  48842. v := m.avatar
  48843. if v == nil {
  48844. return
  48845. }
  48846. return *v, true
  48847. }
  48848. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  48849. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48851. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48852. if !m.op.Is(OpUpdateOne) {
  48853. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48854. }
  48855. if m.id == nil || m.oldValue == nil {
  48856. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48857. }
  48858. oldValue, err := m.oldValue(ctx)
  48859. if err != nil {
  48860. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48861. }
  48862. return oldValue.Avatar, nil
  48863. }
  48864. // ResetAvatar resets all changes to the "avatar" field.
  48865. func (m *WxCardMutation) ResetAvatar() {
  48866. m.avatar = nil
  48867. }
  48868. // SetLogo sets the "logo" field.
  48869. func (m *WxCardMutation) SetLogo(s string) {
  48870. m.logo = &s
  48871. }
  48872. // Logo returns the value of the "logo" field in the mutation.
  48873. func (m *WxCardMutation) Logo() (r string, exists bool) {
  48874. v := m.logo
  48875. if v == nil {
  48876. return
  48877. }
  48878. return *v, true
  48879. }
  48880. // OldLogo returns the old "logo" field's value of the WxCard entity.
  48881. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48883. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  48884. if !m.op.Is(OpUpdateOne) {
  48885. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  48886. }
  48887. if m.id == nil || m.oldValue == nil {
  48888. return v, errors.New("OldLogo requires an ID field in the mutation")
  48889. }
  48890. oldValue, err := m.oldValue(ctx)
  48891. if err != nil {
  48892. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  48893. }
  48894. return oldValue.Logo, nil
  48895. }
  48896. // ResetLogo resets all changes to the "logo" field.
  48897. func (m *WxCardMutation) ResetLogo() {
  48898. m.logo = nil
  48899. }
  48900. // SetName sets the "name" field.
  48901. func (m *WxCardMutation) SetName(s string) {
  48902. m.name = &s
  48903. }
  48904. // Name returns the value of the "name" field in the mutation.
  48905. func (m *WxCardMutation) Name() (r string, exists bool) {
  48906. v := m.name
  48907. if v == nil {
  48908. return
  48909. }
  48910. return *v, true
  48911. }
  48912. // OldName returns the old "name" field's value of the WxCard entity.
  48913. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48915. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  48916. if !m.op.Is(OpUpdateOne) {
  48917. return v, errors.New("OldName is only allowed on UpdateOne operations")
  48918. }
  48919. if m.id == nil || m.oldValue == nil {
  48920. return v, errors.New("OldName requires an ID field in the mutation")
  48921. }
  48922. oldValue, err := m.oldValue(ctx)
  48923. if err != nil {
  48924. return v, fmt.Errorf("querying old value for OldName: %w", err)
  48925. }
  48926. return oldValue.Name, nil
  48927. }
  48928. // ResetName resets all changes to the "name" field.
  48929. func (m *WxCardMutation) ResetName() {
  48930. m.name = nil
  48931. }
  48932. // SetCompany sets the "company" field.
  48933. func (m *WxCardMutation) SetCompany(s string) {
  48934. m.company = &s
  48935. }
  48936. // Company returns the value of the "company" field in the mutation.
  48937. func (m *WxCardMutation) Company() (r string, exists bool) {
  48938. v := m.company
  48939. if v == nil {
  48940. return
  48941. }
  48942. return *v, true
  48943. }
  48944. // OldCompany returns the old "company" field's value of the WxCard entity.
  48945. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48947. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  48948. if !m.op.Is(OpUpdateOne) {
  48949. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  48950. }
  48951. if m.id == nil || m.oldValue == nil {
  48952. return v, errors.New("OldCompany requires an ID field in the mutation")
  48953. }
  48954. oldValue, err := m.oldValue(ctx)
  48955. if err != nil {
  48956. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  48957. }
  48958. return oldValue.Company, nil
  48959. }
  48960. // ResetCompany resets all changes to the "company" field.
  48961. func (m *WxCardMutation) ResetCompany() {
  48962. m.company = nil
  48963. }
  48964. // SetAddress sets the "address" field.
  48965. func (m *WxCardMutation) SetAddress(s string) {
  48966. m.address = &s
  48967. }
  48968. // Address returns the value of the "address" field in the mutation.
  48969. func (m *WxCardMutation) Address() (r string, exists bool) {
  48970. v := m.address
  48971. if v == nil {
  48972. return
  48973. }
  48974. return *v, true
  48975. }
  48976. // OldAddress returns the old "address" field's value of the WxCard entity.
  48977. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48979. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  48980. if !m.op.Is(OpUpdateOne) {
  48981. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  48982. }
  48983. if m.id == nil || m.oldValue == nil {
  48984. return v, errors.New("OldAddress requires an ID field in the mutation")
  48985. }
  48986. oldValue, err := m.oldValue(ctx)
  48987. if err != nil {
  48988. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  48989. }
  48990. return oldValue.Address, nil
  48991. }
  48992. // ResetAddress resets all changes to the "address" field.
  48993. func (m *WxCardMutation) ResetAddress() {
  48994. m.address = nil
  48995. }
  48996. // SetPhone sets the "phone" field.
  48997. func (m *WxCardMutation) SetPhone(s string) {
  48998. m.phone = &s
  48999. }
  49000. // Phone returns the value of the "phone" field in the mutation.
  49001. func (m *WxCardMutation) Phone() (r string, exists bool) {
  49002. v := m.phone
  49003. if v == nil {
  49004. return
  49005. }
  49006. return *v, true
  49007. }
  49008. // OldPhone returns the old "phone" field's value of the WxCard entity.
  49009. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49011. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  49012. if !m.op.Is(OpUpdateOne) {
  49013. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49014. }
  49015. if m.id == nil || m.oldValue == nil {
  49016. return v, errors.New("OldPhone requires an ID field in the mutation")
  49017. }
  49018. oldValue, err := m.oldValue(ctx)
  49019. if err != nil {
  49020. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49021. }
  49022. return oldValue.Phone, nil
  49023. }
  49024. // ResetPhone resets all changes to the "phone" field.
  49025. func (m *WxCardMutation) ResetPhone() {
  49026. m.phone = nil
  49027. }
  49028. // SetOfficialAccount sets the "official_account" field.
  49029. func (m *WxCardMutation) SetOfficialAccount(s string) {
  49030. m.official_account = &s
  49031. }
  49032. // OfficialAccount returns the value of the "official_account" field in the mutation.
  49033. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  49034. v := m.official_account
  49035. if v == nil {
  49036. return
  49037. }
  49038. return *v, true
  49039. }
  49040. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  49041. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49043. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  49044. if !m.op.Is(OpUpdateOne) {
  49045. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  49046. }
  49047. if m.id == nil || m.oldValue == nil {
  49048. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  49049. }
  49050. oldValue, err := m.oldValue(ctx)
  49051. if err != nil {
  49052. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  49053. }
  49054. return oldValue.OfficialAccount, nil
  49055. }
  49056. // ResetOfficialAccount resets all changes to the "official_account" field.
  49057. func (m *WxCardMutation) ResetOfficialAccount() {
  49058. m.official_account = nil
  49059. }
  49060. // SetWechatAccount sets the "wechat_account" field.
  49061. func (m *WxCardMutation) SetWechatAccount(s string) {
  49062. m.wechat_account = &s
  49063. }
  49064. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  49065. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  49066. v := m.wechat_account
  49067. if v == nil {
  49068. return
  49069. }
  49070. return *v, true
  49071. }
  49072. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  49073. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49075. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  49076. if !m.op.Is(OpUpdateOne) {
  49077. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  49078. }
  49079. if m.id == nil || m.oldValue == nil {
  49080. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  49081. }
  49082. oldValue, err := m.oldValue(ctx)
  49083. if err != nil {
  49084. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  49085. }
  49086. return oldValue.WechatAccount, nil
  49087. }
  49088. // ResetWechatAccount resets all changes to the "wechat_account" field.
  49089. func (m *WxCardMutation) ResetWechatAccount() {
  49090. m.wechat_account = nil
  49091. }
  49092. // SetEmail sets the "email" field.
  49093. func (m *WxCardMutation) SetEmail(s string) {
  49094. m.email = &s
  49095. }
  49096. // Email returns the value of the "email" field in the mutation.
  49097. func (m *WxCardMutation) Email() (r string, exists bool) {
  49098. v := m.email
  49099. if v == nil {
  49100. return
  49101. }
  49102. return *v, true
  49103. }
  49104. // OldEmail returns the old "email" field's value of the WxCard entity.
  49105. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49107. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  49108. if !m.op.Is(OpUpdateOne) {
  49109. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  49110. }
  49111. if m.id == nil || m.oldValue == nil {
  49112. return v, errors.New("OldEmail requires an ID field in the mutation")
  49113. }
  49114. oldValue, err := m.oldValue(ctx)
  49115. if err != nil {
  49116. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  49117. }
  49118. return oldValue.Email, nil
  49119. }
  49120. // ClearEmail clears the value of the "email" field.
  49121. func (m *WxCardMutation) ClearEmail() {
  49122. m.email = nil
  49123. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  49124. }
  49125. // EmailCleared returns if the "email" field was cleared in this mutation.
  49126. func (m *WxCardMutation) EmailCleared() bool {
  49127. _, ok := m.clearedFields[wxcard.FieldEmail]
  49128. return ok
  49129. }
  49130. // ResetEmail resets all changes to the "email" field.
  49131. func (m *WxCardMutation) ResetEmail() {
  49132. m.email = nil
  49133. delete(m.clearedFields, wxcard.FieldEmail)
  49134. }
  49135. // SetAPIBase sets the "api_base" field.
  49136. func (m *WxCardMutation) SetAPIBase(s string) {
  49137. m.api_base = &s
  49138. }
  49139. // APIBase returns the value of the "api_base" field in the mutation.
  49140. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49141. v := m.api_base
  49142. if v == nil {
  49143. return
  49144. }
  49145. return *v, true
  49146. }
  49147. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49148. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49150. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49151. if !m.op.Is(OpUpdateOne) {
  49152. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49153. }
  49154. if m.id == nil || m.oldValue == nil {
  49155. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49156. }
  49157. oldValue, err := m.oldValue(ctx)
  49158. if err != nil {
  49159. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49160. }
  49161. return oldValue.APIBase, nil
  49162. }
  49163. // ClearAPIBase clears the value of the "api_base" field.
  49164. func (m *WxCardMutation) ClearAPIBase() {
  49165. m.api_base = nil
  49166. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49167. }
  49168. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49169. func (m *WxCardMutation) APIBaseCleared() bool {
  49170. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49171. return ok
  49172. }
  49173. // ResetAPIBase resets all changes to the "api_base" field.
  49174. func (m *WxCardMutation) ResetAPIBase() {
  49175. m.api_base = nil
  49176. delete(m.clearedFields, wxcard.FieldAPIBase)
  49177. }
  49178. // SetAPIKey sets the "api_key" field.
  49179. func (m *WxCardMutation) SetAPIKey(s string) {
  49180. m.api_key = &s
  49181. }
  49182. // APIKey returns the value of the "api_key" field in the mutation.
  49183. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49184. v := m.api_key
  49185. if v == nil {
  49186. return
  49187. }
  49188. return *v, true
  49189. }
  49190. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49191. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49193. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49194. if !m.op.Is(OpUpdateOne) {
  49195. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49196. }
  49197. if m.id == nil || m.oldValue == nil {
  49198. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49199. }
  49200. oldValue, err := m.oldValue(ctx)
  49201. if err != nil {
  49202. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49203. }
  49204. return oldValue.APIKey, nil
  49205. }
  49206. // ClearAPIKey clears the value of the "api_key" field.
  49207. func (m *WxCardMutation) ClearAPIKey() {
  49208. m.api_key = nil
  49209. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49210. }
  49211. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49212. func (m *WxCardMutation) APIKeyCleared() bool {
  49213. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49214. return ok
  49215. }
  49216. // ResetAPIKey resets all changes to the "api_key" field.
  49217. func (m *WxCardMutation) ResetAPIKey() {
  49218. m.api_key = nil
  49219. delete(m.clearedFields, wxcard.FieldAPIKey)
  49220. }
  49221. // SetAiInfo sets the "ai_info" field.
  49222. func (m *WxCardMutation) SetAiInfo(s string) {
  49223. m.ai_info = &s
  49224. }
  49225. // AiInfo returns the value of the "ai_info" field in the mutation.
  49226. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49227. v := m.ai_info
  49228. if v == nil {
  49229. return
  49230. }
  49231. return *v, true
  49232. }
  49233. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49234. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49236. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49237. if !m.op.Is(OpUpdateOne) {
  49238. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49239. }
  49240. if m.id == nil || m.oldValue == nil {
  49241. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49242. }
  49243. oldValue, err := m.oldValue(ctx)
  49244. if err != nil {
  49245. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49246. }
  49247. return oldValue.AiInfo, nil
  49248. }
  49249. // ClearAiInfo clears the value of the "ai_info" field.
  49250. func (m *WxCardMutation) ClearAiInfo() {
  49251. m.ai_info = nil
  49252. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49253. }
  49254. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49255. func (m *WxCardMutation) AiInfoCleared() bool {
  49256. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49257. return ok
  49258. }
  49259. // ResetAiInfo resets all changes to the "ai_info" field.
  49260. func (m *WxCardMutation) ResetAiInfo() {
  49261. m.ai_info = nil
  49262. delete(m.clearedFields, wxcard.FieldAiInfo)
  49263. }
  49264. // SetIntro sets the "intro" field.
  49265. func (m *WxCardMutation) SetIntro(s string) {
  49266. m.intro = &s
  49267. }
  49268. // Intro returns the value of the "intro" field in the mutation.
  49269. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49270. v := m.intro
  49271. if v == nil {
  49272. return
  49273. }
  49274. return *v, true
  49275. }
  49276. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49277. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49279. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49280. if !m.op.Is(OpUpdateOne) {
  49281. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49282. }
  49283. if m.id == nil || m.oldValue == nil {
  49284. return v, errors.New("OldIntro requires an ID field in the mutation")
  49285. }
  49286. oldValue, err := m.oldValue(ctx)
  49287. if err != nil {
  49288. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49289. }
  49290. return oldValue.Intro, nil
  49291. }
  49292. // ClearIntro clears the value of the "intro" field.
  49293. func (m *WxCardMutation) ClearIntro() {
  49294. m.intro = nil
  49295. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49296. }
  49297. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49298. func (m *WxCardMutation) IntroCleared() bool {
  49299. _, ok := m.clearedFields[wxcard.FieldIntro]
  49300. return ok
  49301. }
  49302. // ResetIntro resets all changes to the "intro" field.
  49303. func (m *WxCardMutation) ResetIntro() {
  49304. m.intro = nil
  49305. delete(m.clearedFields, wxcard.FieldIntro)
  49306. }
  49307. // Where appends a list predicates to the WxCardMutation builder.
  49308. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49309. m.predicates = append(m.predicates, ps...)
  49310. }
  49311. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49312. // users can use type-assertion to append predicates that do not depend on any generated package.
  49313. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49314. p := make([]predicate.WxCard, len(ps))
  49315. for i := range ps {
  49316. p[i] = ps[i]
  49317. }
  49318. m.Where(p...)
  49319. }
  49320. // Op returns the operation name.
  49321. func (m *WxCardMutation) Op() Op {
  49322. return m.op
  49323. }
  49324. // SetOp allows setting the mutation operation.
  49325. func (m *WxCardMutation) SetOp(op Op) {
  49326. m.op = op
  49327. }
  49328. // Type returns the node type of this mutation (WxCard).
  49329. func (m *WxCardMutation) Type() string {
  49330. return m.typ
  49331. }
  49332. // Fields returns all fields that were changed during this mutation. Note that in
  49333. // order to get all numeric fields that were incremented/decremented, call
  49334. // AddedFields().
  49335. func (m *WxCardMutation) Fields() []string {
  49336. fields := make([]string, 0, 18)
  49337. if m.created_at != nil {
  49338. fields = append(fields, wxcard.FieldCreatedAt)
  49339. }
  49340. if m.updated_at != nil {
  49341. fields = append(fields, wxcard.FieldUpdatedAt)
  49342. }
  49343. if m.deleted_at != nil {
  49344. fields = append(fields, wxcard.FieldDeletedAt)
  49345. }
  49346. if m.user_id != nil {
  49347. fields = append(fields, wxcard.FieldUserID)
  49348. }
  49349. if m.wx_user_id != nil {
  49350. fields = append(fields, wxcard.FieldWxUserID)
  49351. }
  49352. if m.avatar != nil {
  49353. fields = append(fields, wxcard.FieldAvatar)
  49354. }
  49355. if m.logo != nil {
  49356. fields = append(fields, wxcard.FieldLogo)
  49357. }
  49358. if m.name != nil {
  49359. fields = append(fields, wxcard.FieldName)
  49360. }
  49361. if m.company != nil {
  49362. fields = append(fields, wxcard.FieldCompany)
  49363. }
  49364. if m.address != nil {
  49365. fields = append(fields, wxcard.FieldAddress)
  49366. }
  49367. if m.phone != nil {
  49368. fields = append(fields, wxcard.FieldPhone)
  49369. }
  49370. if m.official_account != nil {
  49371. fields = append(fields, wxcard.FieldOfficialAccount)
  49372. }
  49373. if m.wechat_account != nil {
  49374. fields = append(fields, wxcard.FieldWechatAccount)
  49375. }
  49376. if m.email != nil {
  49377. fields = append(fields, wxcard.FieldEmail)
  49378. }
  49379. if m.api_base != nil {
  49380. fields = append(fields, wxcard.FieldAPIBase)
  49381. }
  49382. if m.api_key != nil {
  49383. fields = append(fields, wxcard.FieldAPIKey)
  49384. }
  49385. if m.ai_info != nil {
  49386. fields = append(fields, wxcard.FieldAiInfo)
  49387. }
  49388. if m.intro != nil {
  49389. fields = append(fields, wxcard.FieldIntro)
  49390. }
  49391. return fields
  49392. }
  49393. // Field returns the value of a field with the given name. The second boolean
  49394. // return value indicates that this field was not set, or was not defined in the
  49395. // schema.
  49396. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49397. switch name {
  49398. case wxcard.FieldCreatedAt:
  49399. return m.CreatedAt()
  49400. case wxcard.FieldUpdatedAt:
  49401. return m.UpdatedAt()
  49402. case wxcard.FieldDeletedAt:
  49403. return m.DeletedAt()
  49404. case wxcard.FieldUserID:
  49405. return m.UserID()
  49406. case wxcard.FieldWxUserID:
  49407. return m.WxUserID()
  49408. case wxcard.FieldAvatar:
  49409. return m.Avatar()
  49410. case wxcard.FieldLogo:
  49411. return m.Logo()
  49412. case wxcard.FieldName:
  49413. return m.Name()
  49414. case wxcard.FieldCompany:
  49415. return m.Company()
  49416. case wxcard.FieldAddress:
  49417. return m.Address()
  49418. case wxcard.FieldPhone:
  49419. return m.Phone()
  49420. case wxcard.FieldOfficialAccount:
  49421. return m.OfficialAccount()
  49422. case wxcard.FieldWechatAccount:
  49423. return m.WechatAccount()
  49424. case wxcard.FieldEmail:
  49425. return m.Email()
  49426. case wxcard.FieldAPIBase:
  49427. return m.APIBase()
  49428. case wxcard.FieldAPIKey:
  49429. return m.APIKey()
  49430. case wxcard.FieldAiInfo:
  49431. return m.AiInfo()
  49432. case wxcard.FieldIntro:
  49433. return m.Intro()
  49434. }
  49435. return nil, false
  49436. }
  49437. // OldField returns the old value of the field from the database. An error is
  49438. // returned if the mutation operation is not UpdateOne, or the query to the
  49439. // database failed.
  49440. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49441. switch name {
  49442. case wxcard.FieldCreatedAt:
  49443. return m.OldCreatedAt(ctx)
  49444. case wxcard.FieldUpdatedAt:
  49445. return m.OldUpdatedAt(ctx)
  49446. case wxcard.FieldDeletedAt:
  49447. return m.OldDeletedAt(ctx)
  49448. case wxcard.FieldUserID:
  49449. return m.OldUserID(ctx)
  49450. case wxcard.FieldWxUserID:
  49451. return m.OldWxUserID(ctx)
  49452. case wxcard.FieldAvatar:
  49453. return m.OldAvatar(ctx)
  49454. case wxcard.FieldLogo:
  49455. return m.OldLogo(ctx)
  49456. case wxcard.FieldName:
  49457. return m.OldName(ctx)
  49458. case wxcard.FieldCompany:
  49459. return m.OldCompany(ctx)
  49460. case wxcard.FieldAddress:
  49461. return m.OldAddress(ctx)
  49462. case wxcard.FieldPhone:
  49463. return m.OldPhone(ctx)
  49464. case wxcard.FieldOfficialAccount:
  49465. return m.OldOfficialAccount(ctx)
  49466. case wxcard.FieldWechatAccount:
  49467. return m.OldWechatAccount(ctx)
  49468. case wxcard.FieldEmail:
  49469. return m.OldEmail(ctx)
  49470. case wxcard.FieldAPIBase:
  49471. return m.OldAPIBase(ctx)
  49472. case wxcard.FieldAPIKey:
  49473. return m.OldAPIKey(ctx)
  49474. case wxcard.FieldAiInfo:
  49475. return m.OldAiInfo(ctx)
  49476. case wxcard.FieldIntro:
  49477. return m.OldIntro(ctx)
  49478. }
  49479. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49480. }
  49481. // SetField sets the value of a field with the given name. It returns an error if
  49482. // the field is not defined in the schema, or if the type mismatched the field
  49483. // type.
  49484. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49485. switch name {
  49486. case wxcard.FieldCreatedAt:
  49487. v, ok := value.(time.Time)
  49488. if !ok {
  49489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49490. }
  49491. m.SetCreatedAt(v)
  49492. return nil
  49493. case wxcard.FieldUpdatedAt:
  49494. v, ok := value.(time.Time)
  49495. if !ok {
  49496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49497. }
  49498. m.SetUpdatedAt(v)
  49499. return nil
  49500. case wxcard.FieldDeletedAt:
  49501. v, ok := value.(time.Time)
  49502. if !ok {
  49503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49504. }
  49505. m.SetDeletedAt(v)
  49506. return nil
  49507. case wxcard.FieldUserID:
  49508. v, ok := value.(uint64)
  49509. if !ok {
  49510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49511. }
  49512. m.SetUserID(v)
  49513. return nil
  49514. case wxcard.FieldWxUserID:
  49515. v, ok := value.(uint64)
  49516. if !ok {
  49517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49518. }
  49519. m.SetWxUserID(v)
  49520. return nil
  49521. case wxcard.FieldAvatar:
  49522. v, ok := value.(string)
  49523. if !ok {
  49524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49525. }
  49526. m.SetAvatar(v)
  49527. return nil
  49528. case wxcard.FieldLogo:
  49529. v, ok := value.(string)
  49530. if !ok {
  49531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49532. }
  49533. m.SetLogo(v)
  49534. return nil
  49535. case wxcard.FieldName:
  49536. v, ok := value.(string)
  49537. if !ok {
  49538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49539. }
  49540. m.SetName(v)
  49541. return nil
  49542. case wxcard.FieldCompany:
  49543. v, ok := value.(string)
  49544. if !ok {
  49545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49546. }
  49547. m.SetCompany(v)
  49548. return nil
  49549. case wxcard.FieldAddress:
  49550. v, ok := value.(string)
  49551. if !ok {
  49552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49553. }
  49554. m.SetAddress(v)
  49555. return nil
  49556. case wxcard.FieldPhone:
  49557. v, ok := value.(string)
  49558. if !ok {
  49559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49560. }
  49561. m.SetPhone(v)
  49562. return nil
  49563. case wxcard.FieldOfficialAccount:
  49564. v, ok := value.(string)
  49565. if !ok {
  49566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49567. }
  49568. m.SetOfficialAccount(v)
  49569. return nil
  49570. case wxcard.FieldWechatAccount:
  49571. v, ok := value.(string)
  49572. if !ok {
  49573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49574. }
  49575. m.SetWechatAccount(v)
  49576. return nil
  49577. case wxcard.FieldEmail:
  49578. v, ok := value.(string)
  49579. if !ok {
  49580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49581. }
  49582. m.SetEmail(v)
  49583. return nil
  49584. case wxcard.FieldAPIBase:
  49585. v, ok := value.(string)
  49586. if !ok {
  49587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49588. }
  49589. m.SetAPIBase(v)
  49590. return nil
  49591. case wxcard.FieldAPIKey:
  49592. v, ok := value.(string)
  49593. if !ok {
  49594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49595. }
  49596. m.SetAPIKey(v)
  49597. return nil
  49598. case wxcard.FieldAiInfo:
  49599. v, ok := value.(string)
  49600. if !ok {
  49601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49602. }
  49603. m.SetAiInfo(v)
  49604. return nil
  49605. case wxcard.FieldIntro:
  49606. v, ok := value.(string)
  49607. if !ok {
  49608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49609. }
  49610. m.SetIntro(v)
  49611. return nil
  49612. }
  49613. return fmt.Errorf("unknown WxCard field %s", name)
  49614. }
  49615. // AddedFields returns all numeric fields that were incremented/decremented during
  49616. // this mutation.
  49617. func (m *WxCardMutation) AddedFields() []string {
  49618. var fields []string
  49619. if m.adduser_id != nil {
  49620. fields = append(fields, wxcard.FieldUserID)
  49621. }
  49622. if m.addwx_user_id != nil {
  49623. fields = append(fields, wxcard.FieldWxUserID)
  49624. }
  49625. return fields
  49626. }
  49627. // AddedField returns the numeric value that was incremented/decremented on a field
  49628. // with the given name. The second boolean return value indicates that this field
  49629. // was not set, or was not defined in the schema.
  49630. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49631. switch name {
  49632. case wxcard.FieldUserID:
  49633. return m.AddedUserID()
  49634. case wxcard.FieldWxUserID:
  49635. return m.AddedWxUserID()
  49636. }
  49637. return nil, false
  49638. }
  49639. // AddField adds the value to the field with the given name. It returns an error if
  49640. // the field is not defined in the schema, or if the type mismatched the field
  49641. // type.
  49642. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49643. switch name {
  49644. case wxcard.FieldUserID:
  49645. v, ok := value.(int64)
  49646. if !ok {
  49647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49648. }
  49649. m.AddUserID(v)
  49650. return nil
  49651. case wxcard.FieldWxUserID:
  49652. v, ok := value.(int64)
  49653. if !ok {
  49654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49655. }
  49656. m.AddWxUserID(v)
  49657. return nil
  49658. }
  49659. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49660. }
  49661. // ClearedFields returns all nullable fields that were cleared during this
  49662. // mutation.
  49663. func (m *WxCardMutation) ClearedFields() []string {
  49664. var fields []string
  49665. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49666. fields = append(fields, wxcard.FieldDeletedAt)
  49667. }
  49668. if m.FieldCleared(wxcard.FieldUserID) {
  49669. fields = append(fields, wxcard.FieldUserID)
  49670. }
  49671. if m.FieldCleared(wxcard.FieldWxUserID) {
  49672. fields = append(fields, wxcard.FieldWxUserID)
  49673. }
  49674. if m.FieldCleared(wxcard.FieldEmail) {
  49675. fields = append(fields, wxcard.FieldEmail)
  49676. }
  49677. if m.FieldCleared(wxcard.FieldAPIBase) {
  49678. fields = append(fields, wxcard.FieldAPIBase)
  49679. }
  49680. if m.FieldCleared(wxcard.FieldAPIKey) {
  49681. fields = append(fields, wxcard.FieldAPIKey)
  49682. }
  49683. if m.FieldCleared(wxcard.FieldAiInfo) {
  49684. fields = append(fields, wxcard.FieldAiInfo)
  49685. }
  49686. if m.FieldCleared(wxcard.FieldIntro) {
  49687. fields = append(fields, wxcard.FieldIntro)
  49688. }
  49689. return fields
  49690. }
  49691. // FieldCleared returns a boolean indicating if a field with the given name was
  49692. // cleared in this mutation.
  49693. func (m *WxCardMutation) FieldCleared(name string) bool {
  49694. _, ok := m.clearedFields[name]
  49695. return ok
  49696. }
  49697. // ClearField clears the value of the field with the given name. It returns an
  49698. // error if the field is not defined in the schema.
  49699. func (m *WxCardMutation) ClearField(name string) error {
  49700. switch name {
  49701. case wxcard.FieldDeletedAt:
  49702. m.ClearDeletedAt()
  49703. return nil
  49704. case wxcard.FieldUserID:
  49705. m.ClearUserID()
  49706. return nil
  49707. case wxcard.FieldWxUserID:
  49708. m.ClearWxUserID()
  49709. return nil
  49710. case wxcard.FieldEmail:
  49711. m.ClearEmail()
  49712. return nil
  49713. case wxcard.FieldAPIBase:
  49714. m.ClearAPIBase()
  49715. return nil
  49716. case wxcard.FieldAPIKey:
  49717. m.ClearAPIKey()
  49718. return nil
  49719. case wxcard.FieldAiInfo:
  49720. m.ClearAiInfo()
  49721. return nil
  49722. case wxcard.FieldIntro:
  49723. m.ClearIntro()
  49724. return nil
  49725. }
  49726. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49727. }
  49728. // ResetField resets all changes in the mutation for the field with the given name.
  49729. // It returns an error if the field is not defined in the schema.
  49730. func (m *WxCardMutation) ResetField(name string) error {
  49731. switch name {
  49732. case wxcard.FieldCreatedAt:
  49733. m.ResetCreatedAt()
  49734. return nil
  49735. case wxcard.FieldUpdatedAt:
  49736. m.ResetUpdatedAt()
  49737. return nil
  49738. case wxcard.FieldDeletedAt:
  49739. m.ResetDeletedAt()
  49740. return nil
  49741. case wxcard.FieldUserID:
  49742. m.ResetUserID()
  49743. return nil
  49744. case wxcard.FieldWxUserID:
  49745. m.ResetWxUserID()
  49746. return nil
  49747. case wxcard.FieldAvatar:
  49748. m.ResetAvatar()
  49749. return nil
  49750. case wxcard.FieldLogo:
  49751. m.ResetLogo()
  49752. return nil
  49753. case wxcard.FieldName:
  49754. m.ResetName()
  49755. return nil
  49756. case wxcard.FieldCompany:
  49757. m.ResetCompany()
  49758. return nil
  49759. case wxcard.FieldAddress:
  49760. m.ResetAddress()
  49761. return nil
  49762. case wxcard.FieldPhone:
  49763. m.ResetPhone()
  49764. return nil
  49765. case wxcard.FieldOfficialAccount:
  49766. m.ResetOfficialAccount()
  49767. return nil
  49768. case wxcard.FieldWechatAccount:
  49769. m.ResetWechatAccount()
  49770. return nil
  49771. case wxcard.FieldEmail:
  49772. m.ResetEmail()
  49773. return nil
  49774. case wxcard.FieldAPIBase:
  49775. m.ResetAPIBase()
  49776. return nil
  49777. case wxcard.FieldAPIKey:
  49778. m.ResetAPIKey()
  49779. return nil
  49780. case wxcard.FieldAiInfo:
  49781. m.ResetAiInfo()
  49782. return nil
  49783. case wxcard.FieldIntro:
  49784. m.ResetIntro()
  49785. return nil
  49786. }
  49787. return fmt.Errorf("unknown WxCard field %s", name)
  49788. }
  49789. // AddedEdges returns all edge names that were set/added in this mutation.
  49790. func (m *WxCardMutation) AddedEdges() []string {
  49791. edges := make([]string, 0, 0)
  49792. return edges
  49793. }
  49794. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49795. // name in this mutation.
  49796. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  49797. return nil
  49798. }
  49799. // RemovedEdges returns all edge names that were removed in this mutation.
  49800. func (m *WxCardMutation) RemovedEdges() []string {
  49801. edges := make([]string, 0, 0)
  49802. return edges
  49803. }
  49804. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49805. // the given name in this mutation.
  49806. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  49807. return nil
  49808. }
  49809. // ClearedEdges returns all edge names that were cleared in this mutation.
  49810. func (m *WxCardMutation) ClearedEdges() []string {
  49811. edges := make([]string, 0, 0)
  49812. return edges
  49813. }
  49814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49815. // was cleared in this mutation.
  49816. func (m *WxCardMutation) EdgeCleared(name string) bool {
  49817. return false
  49818. }
  49819. // ClearEdge clears the value of the edge with the given name. It returns an error
  49820. // if that edge is not defined in the schema.
  49821. func (m *WxCardMutation) ClearEdge(name string) error {
  49822. return fmt.Errorf("unknown WxCard unique edge %s", name)
  49823. }
  49824. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49825. // It returns an error if the edge is not defined in the schema.
  49826. func (m *WxCardMutation) ResetEdge(name string) error {
  49827. return fmt.Errorf("unknown WxCard edge %s", name)
  49828. }
  49829. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  49830. type WxCardUserMutation struct {
  49831. config
  49832. op Op
  49833. typ string
  49834. id *uint64
  49835. created_at *time.Time
  49836. updated_at *time.Time
  49837. deleted_at *time.Time
  49838. wxid *string
  49839. account *string
  49840. avatar *string
  49841. nickname *string
  49842. remark *string
  49843. phone *string
  49844. open_id *string
  49845. union_id *string
  49846. session_key *string
  49847. is_vip *int
  49848. addis_vip *int
  49849. clearedFields map[string]struct{}
  49850. done bool
  49851. oldValue func(context.Context) (*WxCardUser, error)
  49852. predicates []predicate.WxCardUser
  49853. }
  49854. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  49855. // wxcarduserOption allows management of the mutation configuration using functional options.
  49856. type wxcarduserOption func(*WxCardUserMutation)
  49857. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  49858. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  49859. m := &WxCardUserMutation{
  49860. config: c,
  49861. op: op,
  49862. typ: TypeWxCardUser,
  49863. clearedFields: make(map[string]struct{}),
  49864. }
  49865. for _, opt := range opts {
  49866. opt(m)
  49867. }
  49868. return m
  49869. }
  49870. // withWxCardUserID sets the ID field of the mutation.
  49871. func withWxCardUserID(id uint64) wxcarduserOption {
  49872. return func(m *WxCardUserMutation) {
  49873. var (
  49874. err error
  49875. once sync.Once
  49876. value *WxCardUser
  49877. )
  49878. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  49879. once.Do(func() {
  49880. if m.done {
  49881. err = errors.New("querying old values post mutation is not allowed")
  49882. } else {
  49883. value, err = m.Client().WxCardUser.Get(ctx, id)
  49884. }
  49885. })
  49886. return value, err
  49887. }
  49888. m.id = &id
  49889. }
  49890. }
  49891. // withWxCardUser sets the old WxCardUser of the mutation.
  49892. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  49893. return func(m *WxCardUserMutation) {
  49894. m.oldValue = func(context.Context) (*WxCardUser, error) {
  49895. return node, nil
  49896. }
  49897. m.id = &node.ID
  49898. }
  49899. }
  49900. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49901. // executed in a transaction (ent.Tx), a transactional client is returned.
  49902. func (m WxCardUserMutation) Client() *Client {
  49903. client := &Client{config: m.config}
  49904. client.init()
  49905. return client
  49906. }
  49907. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49908. // it returns an error otherwise.
  49909. func (m WxCardUserMutation) Tx() (*Tx, error) {
  49910. if _, ok := m.driver.(*txDriver); !ok {
  49911. return nil, errors.New("ent: mutation is not running in a transaction")
  49912. }
  49913. tx := &Tx{config: m.config}
  49914. tx.init()
  49915. return tx, nil
  49916. }
  49917. // SetID sets the value of the id field. Note that this
  49918. // operation is only accepted on creation of WxCardUser entities.
  49919. func (m *WxCardUserMutation) SetID(id uint64) {
  49920. m.id = &id
  49921. }
  49922. // ID returns the ID value in the mutation. Note that the ID is only available
  49923. // if it was provided to the builder or after it was returned from the database.
  49924. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  49925. if m.id == nil {
  49926. return
  49927. }
  49928. return *m.id, true
  49929. }
  49930. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49931. // That means, if the mutation is applied within a transaction with an isolation level such
  49932. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49933. // or updated by the mutation.
  49934. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  49935. switch {
  49936. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49937. id, exists := m.ID()
  49938. if exists {
  49939. return []uint64{id}, nil
  49940. }
  49941. fallthrough
  49942. case m.op.Is(OpUpdate | OpDelete):
  49943. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  49944. default:
  49945. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49946. }
  49947. }
  49948. // SetCreatedAt sets the "created_at" field.
  49949. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  49950. m.created_at = &t
  49951. }
  49952. // CreatedAt returns the value of the "created_at" field in the mutation.
  49953. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  49954. v := m.created_at
  49955. if v == nil {
  49956. return
  49957. }
  49958. return *v, true
  49959. }
  49960. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  49961. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49963. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49964. if !m.op.Is(OpUpdateOne) {
  49965. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49966. }
  49967. if m.id == nil || m.oldValue == nil {
  49968. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49969. }
  49970. oldValue, err := m.oldValue(ctx)
  49971. if err != nil {
  49972. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49973. }
  49974. return oldValue.CreatedAt, nil
  49975. }
  49976. // ResetCreatedAt resets all changes to the "created_at" field.
  49977. func (m *WxCardUserMutation) ResetCreatedAt() {
  49978. m.created_at = nil
  49979. }
  49980. // SetUpdatedAt sets the "updated_at" field.
  49981. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  49982. m.updated_at = &t
  49983. }
  49984. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49985. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  49986. v := m.updated_at
  49987. if v == nil {
  49988. return
  49989. }
  49990. return *v, true
  49991. }
  49992. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  49993. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49995. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49996. if !m.op.Is(OpUpdateOne) {
  49997. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49998. }
  49999. if m.id == nil || m.oldValue == nil {
  50000. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50001. }
  50002. oldValue, err := m.oldValue(ctx)
  50003. if err != nil {
  50004. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50005. }
  50006. return oldValue.UpdatedAt, nil
  50007. }
  50008. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50009. func (m *WxCardUserMutation) ResetUpdatedAt() {
  50010. m.updated_at = nil
  50011. }
  50012. // SetDeletedAt sets the "deleted_at" field.
  50013. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  50014. m.deleted_at = &t
  50015. }
  50016. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50017. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  50018. v := m.deleted_at
  50019. if v == nil {
  50020. return
  50021. }
  50022. return *v, true
  50023. }
  50024. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  50025. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50027. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50028. if !m.op.Is(OpUpdateOne) {
  50029. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50030. }
  50031. if m.id == nil || m.oldValue == nil {
  50032. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50033. }
  50034. oldValue, err := m.oldValue(ctx)
  50035. if err != nil {
  50036. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50037. }
  50038. return oldValue.DeletedAt, nil
  50039. }
  50040. // ClearDeletedAt clears the value of the "deleted_at" field.
  50041. func (m *WxCardUserMutation) ClearDeletedAt() {
  50042. m.deleted_at = nil
  50043. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  50044. }
  50045. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50046. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  50047. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  50048. return ok
  50049. }
  50050. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50051. func (m *WxCardUserMutation) ResetDeletedAt() {
  50052. m.deleted_at = nil
  50053. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  50054. }
  50055. // SetWxid sets the "wxid" field.
  50056. func (m *WxCardUserMutation) SetWxid(s string) {
  50057. m.wxid = &s
  50058. }
  50059. // Wxid returns the value of the "wxid" field in the mutation.
  50060. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  50061. v := m.wxid
  50062. if v == nil {
  50063. return
  50064. }
  50065. return *v, true
  50066. }
  50067. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  50068. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50070. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  50071. if !m.op.Is(OpUpdateOne) {
  50072. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50073. }
  50074. if m.id == nil || m.oldValue == nil {
  50075. return v, errors.New("OldWxid requires an ID field in the mutation")
  50076. }
  50077. oldValue, err := m.oldValue(ctx)
  50078. if err != nil {
  50079. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50080. }
  50081. return oldValue.Wxid, nil
  50082. }
  50083. // ResetWxid resets all changes to the "wxid" field.
  50084. func (m *WxCardUserMutation) ResetWxid() {
  50085. m.wxid = nil
  50086. }
  50087. // SetAccount sets the "account" field.
  50088. func (m *WxCardUserMutation) SetAccount(s string) {
  50089. m.account = &s
  50090. }
  50091. // Account returns the value of the "account" field in the mutation.
  50092. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  50093. v := m.account
  50094. if v == nil {
  50095. return
  50096. }
  50097. return *v, true
  50098. }
  50099. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  50100. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50102. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  50103. if !m.op.Is(OpUpdateOne) {
  50104. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  50105. }
  50106. if m.id == nil || m.oldValue == nil {
  50107. return v, errors.New("OldAccount requires an ID field in the mutation")
  50108. }
  50109. oldValue, err := m.oldValue(ctx)
  50110. if err != nil {
  50111. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  50112. }
  50113. return oldValue.Account, nil
  50114. }
  50115. // ResetAccount resets all changes to the "account" field.
  50116. func (m *WxCardUserMutation) ResetAccount() {
  50117. m.account = nil
  50118. }
  50119. // SetAvatar sets the "avatar" field.
  50120. func (m *WxCardUserMutation) SetAvatar(s string) {
  50121. m.avatar = &s
  50122. }
  50123. // Avatar returns the value of the "avatar" field in the mutation.
  50124. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  50125. v := m.avatar
  50126. if v == nil {
  50127. return
  50128. }
  50129. return *v, true
  50130. }
  50131. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50132. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50134. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50135. if !m.op.Is(OpUpdateOne) {
  50136. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50137. }
  50138. if m.id == nil || m.oldValue == nil {
  50139. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50140. }
  50141. oldValue, err := m.oldValue(ctx)
  50142. if err != nil {
  50143. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50144. }
  50145. return oldValue.Avatar, nil
  50146. }
  50147. // ResetAvatar resets all changes to the "avatar" field.
  50148. func (m *WxCardUserMutation) ResetAvatar() {
  50149. m.avatar = nil
  50150. }
  50151. // SetNickname sets the "nickname" field.
  50152. func (m *WxCardUserMutation) SetNickname(s string) {
  50153. m.nickname = &s
  50154. }
  50155. // Nickname returns the value of the "nickname" field in the mutation.
  50156. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50157. v := m.nickname
  50158. if v == nil {
  50159. return
  50160. }
  50161. return *v, true
  50162. }
  50163. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50164. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50166. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50167. if !m.op.Is(OpUpdateOne) {
  50168. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50169. }
  50170. if m.id == nil || m.oldValue == nil {
  50171. return v, errors.New("OldNickname requires an ID field in the mutation")
  50172. }
  50173. oldValue, err := m.oldValue(ctx)
  50174. if err != nil {
  50175. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50176. }
  50177. return oldValue.Nickname, nil
  50178. }
  50179. // ResetNickname resets all changes to the "nickname" field.
  50180. func (m *WxCardUserMutation) ResetNickname() {
  50181. m.nickname = nil
  50182. }
  50183. // SetRemark sets the "remark" field.
  50184. func (m *WxCardUserMutation) SetRemark(s string) {
  50185. m.remark = &s
  50186. }
  50187. // Remark returns the value of the "remark" field in the mutation.
  50188. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50189. v := m.remark
  50190. if v == nil {
  50191. return
  50192. }
  50193. return *v, true
  50194. }
  50195. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50196. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50198. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50199. if !m.op.Is(OpUpdateOne) {
  50200. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50201. }
  50202. if m.id == nil || m.oldValue == nil {
  50203. return v, errors.New("OldRemark requires an ID field in the mutation")
  50204. }
  50205. oldValue, err := m.oldValue(ctx)
  50206. if err != nil {
  50207. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50208. }
  50209. return oldValue.Remark, nil
  50210. }
  50211. // ResetRemark resets all changes to the "remark" field.
  50212. func (m *WxCardUserMutation) ResetRemark() {
  50213. m.remark = nil
  50214. }
  50215. // SetPhone sets the "phone" field.
  50216. func (m *WxCardUserMutation) SetPhone(s string) {
  50217. m.phone = &s
  50218. }
  50219. // Phone returns the value of the "phone" field in the mutation.
  50220. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50221. v := m.phone
  50222. if v == nil {
  50223. return
  50224. }
  50225. return *v, true
  50226. }
  50227. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50228. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50230. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50231. if !m.op.Is(OpUpdateOne) {
  50232. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50233. }
  50234. if m.id == nil || m.oldValue == nil {
  50235. return v, errors.New("OldPhone requires an ID field in the mutation")
  50236. }
  50237. oldValue, err := m.oldValue(ctx)
  50238. if err != nil {
  50239. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50240. }
  50241. return oldValue.Phone, nil
  50242. }
  50243. // ResetPhone resets all changes to the "phone" field.
  50244. func (m *WxCardUserMutation) ResetPhone() {
  50245. m.phone = nil
  50246. }
  50247. // SetOpenID sets the "open_id" field.
  50248. func (m *WxCardUserMutation) SetOpenID(s string) {
  50249. m.open_id = &s
  50250. }
  50251. // OpenID returns the value of the "open_id" field in the mutation.
  50252. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50253. v := m.open_id
  50254. if v == nil {
  50255. return
  50256. }
  50257. return *v, true
  50258. }
  50259. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50260. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50262. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50263. if !m.op.Is(OpUpdateOne) {
  50264. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50265. }
  50266. if m.id == nil || m.oldValue == nil {
  50267. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50268. }
  50269. oldValue, err := m.oldValue(ctx)
  50270. if err != nil {
  50271. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50272. }
  50273. return oldValue.OpenID, nil
  50274. }
  50275. // ResetOpenID resets all changes to the "open_id" field.
  50276. func (m *WxCardUserMutation) ResetOpenID() {
  50277. m.open_id = nil
  50278. }
  50279. // SetUnionID sets the "union_id" field.
  50280. func (m *WxCardUserMutation) SetUnionID(s string) {
  50281. m.union_id = &s
  50282. }
  50283. // UnionID returns the value of the "union_id" field in the mutation.
  50284. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50285. v := m.union_id
  50286. if v == nil {
  50287. return
  50288. }
  50289. return *v, true
  50290. }
  50291. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50292. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50294. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50295. if !m.op.Is(OpUpdateOne) {
  50296. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50297. }
  50298. if m.id == nil || m.oldValue == nil {
  50299. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50300. }
  50301. oldValue, err := m.oldValue(ctx)
  50302. if err != nil {
  50303. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50304. }
  50305. return oldValue.UnionID, nil
  50306. }
  50307. // ResetUnionID resets all changes to the "union_id" field.
  50308. func (m *WxCardUserMutation) ResetUnionID() {
  50309. m.union_id = nil
  50310. }
  50311. // SetSessionKey sets the "session_key" field.
  50312. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50313. m.session_key = &s
  50314. }
  50315. // SessionKey returns the value of the "session_key" field in the mutation.
  50316. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50317. v := m.session_key
  50318. if v == nil {
  50319. return
  50320. }
  50321. return *v, true
  50322. }
  50323. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50324. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50326. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50327. if !m.op.Is(OpUpdateOne) {
  50328. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50329. }
  50330. if m.id == nil || m.oldValue == nil {
  50331. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50332. }
  50333. oldValue, err := m.oldValue(ctx)
  50334. if err != nil {
  50335. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50336. }
  50337. return oldValue.SessionKey, nil
  50338. }
  50339. // ResetSessionKey resets all changes to the "session_key" field.
  50340. func (m *WxCardUserMutation) ResetSessionKey() {
  50341. m.session_key = nil
  50342. }
  50343. // SetIsVip sets the "is_vip" field.
  50344. func (m *WxCardUserMutation) SetIsVip(i int) {
  50345. m.is_vip = &i
  50346. m.addis_vip = nil
  50347. }
  50348. // IsVip returns the value of the "is_vip" field in the mutation.
  50349. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50350. v := m.is_vip
  50351. if v == nil {
  50352. return
  50353. }
  50354. return *v, true
  50355. }
  50356. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50357. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50359. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50360. if !m.op.Is(OpUpdateOne) {
  50361. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50362. }
  50363. if m.id == nil || m.oldValue == nil {
  50364. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50365. }
  50366. oldValue, err := m.oldValue(ctx)
  50367. if err != nil {
  50368. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50369. }
  50370. return oldValue.IsVip, nil
  50371. }
  50372. // AddIsVip adds i to the "is_vip" field.
  50373. func (m *WxCardUserMutation) AddIsVip(i int) {
  50374. if m.addis_vip != nil {
  50375. *m.addis_vip += i
  50376. } else {
  50377. m.addis_vip = &i
  50378. }
  50379. }
  50380. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50381. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50382. v := m.addis_vip
  50383. if v == nil {
  50384. return
  50385. }
  50386. return *v, true
  50387. }
  50388. // ResetIsVip resets all changes to the "is_vip" field.
  50389. func (m *WxCardUserMutation) ResetIsVip() {
  50390. m.is_vip = nil
  50391. m.addis_vip = nil
  50392. }
  50393. // Where appends a list predicates to the WxCardUserMutation builder.
  50394. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50395. m.predicates = append(m.predicates, ps...)
  50396. }
  50397. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50398. // users can use type-assertion to append predicates that do not depend on any generated package.
  50399. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50400. p := make([]predicate.WxCardUser, len(ps))
  50401. for i := range ps {
  50402. p[i] = ps[i]
  50403. }
  50404. m.Where(p...)
  50405. }
  50406. // Op returns the operation name.
  50407. func (m *WxCardUserMutation) Op() Op {
  50408. return m.op
  50409. }
  50410. // SetOp allows setting the mutation operation.
  50411. func (m *WxCardUserMutation) SetOp(op Op) {
  50412. m.op = op
  50413. }
  50414. // Type returns the node type of this mutation (WxCardUser).
  50415. func (m *WxCardUserMutation) Type() string {
  50416. return m.typ
  50417. }
  50418. // Fields returns all fields that were changed during this mutation. Note that in
  50419. // order to get all numeric fields that were incremented/decremented, call
  50420. // AddedFields().
  50421. func (m *WxCardUserMutation) Fields() []string {
  50422. fields := make([]string, 0, 13)
  50423. if m.created_at != nil {
  50424. fields = append(fields, wxcarduser.FieldCreatedAt)
  50425. }
  50426. if m.updated_at != nil {
  50427. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50428. }
  50429. if m.deleted_at != nil {
  50430. fields = append(fields, wxcarduser.FieldDeletedAt)
  50431. }
  50432. if m.wxid != nil {
  50433. fields = append(fields, wxcarduser.FieldWxid)
  50434. }
  50435. if m.account != nil {
  50436. fields = append(fields, wxcarduser.FieldAccount)
  50437. }
  50438. if m.avatar != nil {
  50439. fields = append(fields, wxcarduser.FieldAvatar)
  50440. }
  50441. if m.nickname != nil {
  50442. fields = append(fields, wxcarduser.FieldNickname)
  50443. }
  50444. if m.remark != nil {
  50445. fields = append(fields, wxcarduser.FieldRemark)
  50446. }
  50447. if m.phone != nil {
  50448. fields = append(fields, wxcarduser.FieldPhone)
  50449. }
  50450. if m.open_id != nil {
  50451. fields = append(fields, wxcarduser.FieldOpenID)
  50452. }
  50453. if m.union_id != nil {
  50454. fields = append(fields, wxcarduser.FieldUnionID)
  50455. }
  50456. if m.session_key != nil {
  50457. fields = append(fields, wxcarduser.FieldSessionKey)
  50458. }
  50459. if m.is_vip != nil {
  50460. fields = append(fields, wxcarduser.FieldIsVip)
  50461. }
  50462. return fields
  50463. }
  50464. // Field returns the value of a field with the given name. The second boolean
  50465. // return value indicates that this field was not set, or was not defined in the
  50466. // schema.
  50467. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50468. switch name {
  50469. case wxcarduser.FieldCreatedAt:
  50470. return m.CreatedAt()
  50471. case wxcarduser.FieldUpdatedAt:
  50472. return m.UpdatedAt()
  50473. case wxcarduser.FieldDeletedAt:
  50474. return m.DeletedAt()
  50475. case wxcarduser.FieldWxid:
  50476. return m.Wxid()
  50477. case wxcarduser.FieldAccount:
  50478. return m.Account()
  50479. case wxcarduser.FieldAvatar:
  50480. return m.Avatar()
  50481. case wxcarduser.FieldNickname:
  50482. return m.Nickname()
  50483. case wxcarduser.FieldRemark:
  50484. return m.Remark()
  50485. case wxcarduser.FieldPhone:
  50486. return m.Phone()
  50487. case wxcarduser.FieldOpenID:
  50488. return m.OpenID()
  50489. case wxcarduser.FieldUnionID:
  50490. return m.UnionID()
  50491. case wxcarduser.FieldSessionKey:
  50492. return m.SessionKey()
  50493. case wxcarduser.FieldIsVip:
  50494. return m.IsVip()
  50495. }
  50496. return nil, false
  50497. }
  50498. // OldField returns the old value of the field from the database. An error is
  50499. // returned if the mutation operation is not UpdateOne, or the query to the
  50500. // database failed.
  50501. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50502. switch name {
  50503. case wxcarduser.FieldCreatedAt:
  50504. return m.OldCreatedAt(ctx)
  50505. case wxcarduser.FieldUpdatedAt:
  50506. return m.OldUpdatedAt(ctx)
  50507. case wxcarduser.FieldDeletedAt:
  50508. return m.OldDeletedAt(ctx)
  50509. case wxcarduser.FieldWxid:
  50510. return m.OldWxid(ctx)
  50511. case wxcarduser.FieldAccount:
  50512. return m.OldAccount(ctx)
  50513. case wxcarduser.FieldAvatar:
  50514. return m.OldAvatar(ctx)
  50515. case wxcarduser.FieldNickname:
  50516. return m.OldNickname(ctx)
  50517. case wxcarduser.FieldRemark:
  50518. return m.OldRemark(ctx)
  50519. case wxcarduser.FieldPhone:
  50520. return m.OldPhone(ctx)
  50521. case wxcarduser.FieldOpenID:
  50522. return m.OldOpenID(ctx)
  50523. case wxcarduser.FieldUnionID:
  50524. return m.OldUnionID(ctx)
  50525. case wxcarduser.FieldSessionKey:
  50526. return m.OldSessionKey(ctx)
  50527. case wxcarduser.FieldIsVip:
  50528. return m.OldIsVip(ctx)
  50529. }
  50530. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50531. }
  50532. // SetField sets the value of a field with the given name. It returns an error if
  50533. // the field is not defined in the schema, or if the type mismatched the field
  50534. // type.
  50535. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50536. switch name {
  50537. case wxcarduser.FieldCreatedAt:
  50538. v, ok := value.(time.Time)
  50539. if !ok {
  50540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50541. }
  50542. m.SetCreatedAt(v)
  50543. return nil
  50544. case wxcarduser.FieldUpdatedAt:
  50545. v, ok := value.(time.Time)
  50546. if !ok {
  50547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50548. }
  50549. m.SetUpdatedAt(v)
  50550. return nil
  50551. case wxcarduser.FieldDeletedAt:
  50552. v, ok := value.(time.Time)
  50553. if !ok {
  50554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50555. }
  50556. m.SetDeletedAt(v)
  50557. return nil
  50558. case wxcarduser.FieldWxid:
  50559. v, ok := value.(string)
  50560. if !ok {
  50561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50562. }
  50563. m.SetWxid(v)
  50564. return nil
  50565. case wxcarduser.FieldAccount:
  50566. v, ok := value.(string)
  50567. if !ok {
  50568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50569. }
  50570. m.SetAccount(v)
  50571. return nil
  50572. case wxcarduser.FieldAvatar:
  50573. v, ok := value.(string)
  50574. if !ok {
  50575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50576. }
  50577. m.SetAvatar(v)
  50578. return nil
  50579. case wxcarduser.FieldNickname:
  50580. v, ok := value.(string)
  50581. if !ok {
  50582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50583. }
  50584. m.SetNickname(v)
  50585. return nil
  50586. case wxcarduser.FieldRemark:
  50587. v, ok := value.(string)
  50588. if !ok {
  50589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50590. }
  50591. m.SetRemark(v)
  50592. return nil
  50593. case wxcarduser.FieldPhone:
  50594. v, ok := value.(string)
  50595. if !ok {
  50596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50597. }
  50598. m.SetPhone(v)
  50599. return nil
  50600. case wxcarduser.FieldOpenID:
  50601. v, ok := value.(string)
  50602. if !ok {
  50603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50604. }
  50605. m.SetOpenID(v)
  50606. return nil
  50607. case wxcarduser.FieldUnionID:
  50608. v, ok := value.(string)
  50609. if !ok {
  50610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50611. }
  50612. m.SetUnionID(v)
  50613. return nil
  50614. case wxcarduser.FieldSessionKey:
  50615. v, ok := value.(string)
  50616. if !ok {
  50617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50618. }
  50619. m.SetSessionKey(v)
  50620. return nil
  50621. case wxcarduser.FieldIsVip:
  50622. v, ok := value.(int)
  50623. if !ok {
  50624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50625. }
  50626. m.SetIsVip(v)
  50627. return nil
  50628. }
  50629. return fmt.Errorf("unknown WxCardUser field %s", name)
  50630. }
  50631. // AddedFields returns all numeric fields that were incremented/decremented during
  50632. // this mutation.
  50633. func (m *WxCardUserMutation) AddedFields() []string {
  50634. var fields []string
  50635. if m.addis_vip != nil {
  50636. fields = append(fields, wxcarduser.FieldIsVip)
  50637. }
  50638. return fields
  50639. }
  50640. // AddedField returns the numeric value that was incremented/decremented on a field
  50641. // with the given name. The second boolean return value indicates that this field
  50642. // was not set, or was not defined in the schema.
  50643. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50644. switch name {
  50645. case wxcarduser.FieldIsVip:
  50646. return m.AddedIsVip()
  50647. }
  50648. return nil, false
  50649. }
  50650. // AddField adds the value to the field with the given name. It returns an error if
  50651. // the field is not defined in the schema, or if the type mismatched the field
  50652. // type.
  50653. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50654. switch name {
  50655. case wxcarduser.FieldIsVip:
  50656. v, ok := value.(int)
  50657. if !ok {
  50658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50659. }
  50660. m.AddIsVip(v)
  50661. return nil
  50662. }
  50663. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50664. }
  50665. // ClearedFields returns all nullable fields that were cleared during this
  50666. // mutation.
  50667. func (m *WxCardUserMutation) ClearedFields() []string {
  50668. var fields []string
  50669. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50670. fields = append(fields, wxcarduser.FieldDeletedAt)
  50671. }
  50672. return fields
  50673. }
  50674. // FieldCleared returns a boolean indicating if a field with the given name was
  50675. // cleared in this mutation.
  50676. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50677. _, ok := m.clearedFields[name]
  50678. return ok
  50679. }
  50680. // ClearField clears the value of the field with the given name. It returns an
  50681. // error if the field is not defined in the schema.
  50682. func (m *WxCardUserMutation) ClearField(name string) error {
  50683. switch name {
  50684. case wxcarduser.FieldDeletedAt:
  50685. m.ClearDeletedAt()
  50686. return nil
  50687. }
  50688. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50689. }
  50690. // ResetField resets all changes in the mutation for the field with the given name.
  50691. // It returns an error if the field is not defined in the schema.
  50692. func (m *WxCardUserMutation) ResetField(name string) error {
  50693. switch name {
  50694. case wxcarduser.FieldCreatedAt:
  50695. m.ResetCreatedAt()
  50696. return nil
  50697. case wxcarduser.FieldUpdatedAt:
  50698. m.ResetUpdatedAt()
  50699. return nil
  50700. case wxcarduser.FieldDeletedAt:
  50701. m.ResetDeletedAt()
  50702. return nil
  50703. case wxcarduser.FieldWxid:
  50704. m.ResetWxid()
  50705. return nil
  50706. case wxcarduser.FieldAccount:
  50707. m.ResetAccount()
  50708. return nil
  50709. case wxcarduser.FieldAvatar:
  50710. m.ResetAvatar()
  50711. return nil
  50712. case wxcarduser.FieldNickname:
  50713. m.ResetNickname()
  50714. return nil
  50715. case wxcarduser.FieldRemark:
  50716. m.ResetRemark()
  50717. return nil
  50718. case wxcarduser.FieldPhone:
  50719. m.ResetPhone()
  50720. return nil
  50721. case wxcarduser.FieldOpenID:
  50722. m.ResetOpenID()
  50723. return nil
  50724. case wxcarduser.FieldUnionID:
  50725. m.ResetUnionID()
  50726. return nil
  50727. case wxcarduser.FieldSessionKey:
  50728. m.ResetSessionKey()
  50729. return nil
  50730. case wxcarduser.FieldIsVip:
  50731. m.ResetIsVip()
  50732. return nil
  50733. }
  50734. return fmt.Errorf("unknown WxCardUser field %s", name)
  50735. }
  50736. // AddedEdges returns all edge names that were set/added in this mutation.
  50737. func (m *WxCardUserMutation) AddedEdges() []string {
  50738. edges := make([]string, 0, 0)
  50739. return edges
  50740. }
  50741. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50742. // name in this mutation.
  50743. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50744. return nil
  50745. }
  50746. // RemovedEdges returns all edge names that were removed in this mutation.
  50747. func (m *WxCardUserMutation) RemovedEdges() []string {
  50748. edges := make([]string, 0, 0)
  50749. return edges
  50750. }
  50751. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50752. // the given name in this mutation.
  50753. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50754. return nil
  50755. }
  50756. // ClearedEdges returns all edge names that were cleared in this mutation.
  50757. func (m *WxCardUserMutation) ClearedEdges() []string {
  50758. edges := make([]string, 0, 0)
  50759. return edges
  50760. }
  50761. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50762. // was cleared in this mutation.
  50763. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50764. return false
  50765. }
  50766. // ClearEdge clears the value of the edge with the given name. It returns an error
  50767. // if that edge is not defined in the schema.
  50768. func (m *WxCardUserMutation) ClearEdge(name string) error {
  50769. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  50770. }
  50771. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50772. // It returns an error if the edge is not defined in the schema.
  50773. func (m *WxCardUserMutation) ResetEdge(name string) error {
  50774. return fmt.Errorf("unknown WxCardUser edge %s", name)
  50775. }
  50776. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  50777. type WxCardVisitMutation struct {
  50778. config
  50779. op Op
  50780. typ string
  50781. id *uint64
  50782. created_at *time.Time
  50783. updated_at *time.Time
  50784. deleted_at *time.Time
  50785. user_id *uint64
  50786. adduser_id *int64
  50787. bot_id *uint64
  50788. addbot_id *int64
  50789. bot_type *uint8
  50790. addbot_type *int8
  50791. clearedFields map[string]struct{}
  50792. done bool
  50793. oldValue func(context.Context) (*WxCardVisit, error)
  50794. predicates []predicate.WxCardVisit
  50795. }
  50796. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  50797. // wxcardvisitOption allows management of the mutation configuration using functional options.
  50798. type wxcardvisitOption func(*WxCardVisitMutation)
  50799. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  50800. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  50801. m := &WxCardVisitMutation{
  50802. config: c,
  50803. op: op,
  50804. typ: TypeWxCardVisit,
  50805. clearedFields: make(map[string]struct{}),
  50806. }
  50807. for _, opt := range opts {
  50808. opt(m)
  50809. }
  50810. return m
  50811. }
  50812. // withWxCardVisitID sets the ID field of the mutation.
  50813. func withWxCardVisitID(id uint64) wxcardvisitOption {
  50814. return func(m *WxCardVisitMutation) {
  50815. var (
  50816. err error
  50817. once sync.Once
  50818. value *WxCardVisit
  50819. )
  50820. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  50821. once.Do(func() {
  50822. if m.done {
  50823. err = errors.New("querying old values post mutation is not allowed")
  50824. } else {
  50825. value, err = m.Client().WxCardVisit.Get(ctx, id)
  50826. }
  50827. })
  50828. return value, err
  50829. }
  50830. m.id = &id
  50831. }
  50832. }
  50833. // withWxCardVisit sets the old WxCardVisit of the mutation.
  50834. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  50835. return func(m *WxCardVisitMutation) {
  50836. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  50837. return node, nil
  50838. }
  50839. m.id = &node.ID
  50840. }
  50841. }
  50842. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50843. // executed in a transaction (ent.Tx), a transactional client is returned.
  50844. func (m WxCardVisitMutation) Client() *Client {
  50845. client := &Client{config: m.config}
  50846. client.init()
  50847. return client
  50848. }
  50849. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50850. // it returns an error otherwise.
  50851. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  50852. if _, ok := m.driver.(*txDriver); !ok {
  50853. return nil, errors.New("ent: mutation is not running in a transaction")
  50854. }
  50855. tx := &Tx{config: m.config}
  50856. tx.init()
  50857. return tx, nil
  50858. }
  50859. // SetID sets the value of the id field. Note that this
  50860. // operation is only accepted on creation of WxCardVisit entities.
  50861. func (m *WxCardVisitMutation) SetID(id uint64) {
  50862. m.id = &id
  50863. }
  50864. // ID returns the ID value in the mutation. Note that the ID is only available
  50865. // if it was provided to the builder or after it was returned from the database.
  50866. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  50867. if m.id == nil {
  50868. return
  50869. }
  50870. return *m.id, true
  50871. }
  50872. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50873. // That means, if the mutation is applied within a transaction with an isolation level such
  50874. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50875. // or updated by the mutation.
  50876. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  50877. switch {
  50878. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50879. id, exists := m.ID()
  50880. if exists {
  50881. return []uint64{id}, nil
  50882. }
  50883. fallthrough
  50884. case m.op.Is(OpUpdate | OpDelete):
  50885. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  50886. default:
  50887. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50888. }
  50889. }
  50890. // SetCreatedAt sets the "created_at" field.
  50891. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  50892. m.created_at = &t
  50893. }
  50894. // CreatedAt returns the value of the "created_at" field in the mutation.
  50895. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  50896. v := m.created_at
  50897. if v == nil {
  50898. return
  50899. }
  50900. return *v, true
  50901. }
  50902. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  50903. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50905. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50906. if !m.op.Is(OpUpdateOne) {
  50907. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50908. }
  50909. if m.id == nil || m.oldValue == nil {
  50910. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50911. }
  50912. oldValue, err := m.oldValue(ctx)
  50913. if err != nil {
  50914. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50915. }
  50916. return oldValue.CreatedAt, nil
  50917. }
  50918. // ResetCreatedAt resets all changes to the "created_at" field.
  50919. func (m *WxCardVisitMutation) ResetCreatedAt() {
  50920. m.created_at = nil
  50921. }
  50922. // SetUpdatedAt sets the "updated_at" field.
  50923. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  50924. m.updated_at = &t
  50925. }
  50926. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50927. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  50928. v := m.updated_at
  50929. if v == nil {
  50930. return
  50931. }
  50932. return *v, true
  50933. }
  50934. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  50935. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50937. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50938. if !m.op.Is(OpUpdateOne) {
  50939. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50940. }
  50941. if m.id == nil || m.oldValue == nil {
  50942. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50943. }
  50944. oldValue, err := m.oldValue(ctx)
  50945. if err != nil {
  50946. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50947. }
  50948. return oldValue.UpdatedAt, nil
  50949. }
  50950. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50951. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  50952. m.updated_at = nil
  50953. }
  50954. // SetDeletedAt sets the "deleted_at" field.
  50955. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  50956. m.deleted_at = &t
  50957. }
  50958. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50959. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  50960. v := m.deleted_at
  50961. if v == nil {
  50962. return
  50963. }
  50964. return *v, true
  50965. }
  50966. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  50967. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50969. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50970. if !m.op.Is(OpUpdateOne) {
  50971. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50972. }
  50973. if m.id == nil || m.oldValue == nil {
  50974. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50975. }
  50976. oldValue, err := m.oldValue(ctx)
  50977. if err != nil {
  50978. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50979. }
  50980. return oldValue.DeletedAt, nil
  50981. }
  50982. // ClearDeletedAt clears the value of the "deleted_at" field.
  50983. func (m *WxCardVisitMutation) ClearDeletedAt() {
  50984. m.deleted_at = nil
  50985. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  50986. }
  50987. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50988. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  50989. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  50990. return ok
  50991. }
  50992. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50993. func (m *WxCardVisitMutation) ResetDeletedAt() {
  50994. m.deleted_at = nil
  50995. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  50996. }
  50997. // SetUserID sets the "user_id" field.
  50998. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  50999. m.user_id = &u
  51000. m.adduser_id = nil
  51001. }
  51002. // UserID returns the value of the "user_id" field in the mutation.
  51003. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  51004. v := m.user_id
  51005. if v == nil {
  51006. return
  51007. }
  51008. return *v, true
  51009. }
  51010. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  51011. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51013. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  51014. if !m.op.Is(OpUpdateOne) {
  51015. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  51016. }
  51017. if m.id == nil || m.oldValue == nil {
  51018. return v, errors.New("OldUserID requires an ID field in the mutation")
  51019. }
  51020. oldValue, err := m.oldValue(ctx)
  51021. if err != nil {
  51022. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  51023. }
  51024. return oldValue.UserID, nil
  51025. }
  51026. // AddUserID adds u to the "user_id" field.
  51027. func (m *WxCardVisitMutation) AddUserID(u int64) {
  51028. if m.adduser_id != nil {
  51029. *m.adduser_id += u
  51030. } else {
  51031. m.adduser_id = &u
  51032. }
  51033. }
  51034. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  51035. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  51036. v := m.adduser_id
  51037. if v == nil {
  51038. return
  51039. }
  51040. return *v, true
  51041. }
  51042. // ClearUserID clears the value of the "user_id" field.
  51043. func (m *WxCardVisitMutation) ClearUserID() {
  51044. m.user_id = nil
  51045. m.adduser_id = nil
  51046. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  51047. }
  51048. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  51049. func (m *WxCardVisitMutation) UserIDCleared() bool {
  51050. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  51051. return ok
  51052. }
  51053. // ResetUserID resets all changes to the "user_id" field.
  51054. func (m *WxCardVisitMutation) ResetUserID() {
  51055. m.user_id = nil
  51056. m.adduser_id = nil
  51057. delete(m.clearedFields, wxcardvisit.FieldUserID)
  51058. }
  51059. // SetBotID sets the "bot_id" field.
  51060. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  51061. m.bot_id = &u
  51062. m.addbot_id = nil
  51063. }
  51064. // BotID returns the value of the "bot_id" field in the mutation.
  51065. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  51066. v := m.bot_id
  51067. if v == nil {
  51068. return
  51069. }
  51070. return *v, true
  51071. }
  51072. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  51073. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51075. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  51076. if !m.op.Is(OpUpdateOne) {
  51077. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  51078. }
  51079. if m.id == nil || m.oldValue == nil {
  51080. return v, errors.New("OldBotID requires an ID field in the mutation")
  51081. }
  51082. oldValue, err := m.oldValue(ctx)
  51083. if err != nil {
  51084. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  51085. }
  51086. return oldValue.BotID, nil
  51087. }
  51088. // AddBotID adds u to the "bot_id" field.
  51089. func (m *WxCardVisitMutation) AddBotID(u int64) {
  51090. if m.addbot_id != nil {
  51091. *m.addbot_id += u
  51092. } else {
  51093. m.addbot_id = &u
  51094. }
  51095. }
  51096. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  51097. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  51098. v := m.addbot_id
  51099. if v == nil {
  51100. return
  51101. }
  51102. return *v, true
  51103. }
  51104. // ResetBotID resets all changes to the "bot_id" field.
  51105. func (m *WxCardVisitMutation) ResetBotID() {
  51106. m.bot_id = nil
  51107. m.addbot_id = nil
  51108. }
  51109. // SetBotType sets the "bot_type" field.
  51110. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  51111. m.bot_type = &u
  51112. m.addbot_type = nil
  51113. }
  51114. // BotType returns the value of the "bot_type" field in the mutation.
  51115. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  51116. v := m.bot_type
  51117. if v == nil {
  51118. return
  51119. }
  51120. return *v, true
  51121. }
  51122. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  51123. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51125. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  51126. if !m.op.Is(OpUpdateOne) {
  51127. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  51128. }
  51129. if m.id == nil || m.oldValue == nil {
  51130. return v, errors.New("OldBotType requires an ID field in the mutation")
  51131. }
  51132. oldValue, err := m.oldValue(ctx)
  51133. if err != nil {
  51134. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51135. }
  51136. return oldValue.BotType, nil
  51137. }
  51138. // AddBotType adds u to the "bot_type" field.
  51139. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51140. if m.addbot_type != nil {
  51141. *m.addbot_type += u
  51142. } else {
  51143. m.addbot_type = &u
  51144. }
  51145. }
  51146. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51147. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51148. v := m.addbot_type
  51149. if v == nil {
  51150. return
  51151. }
  51152. return *v, true
  51153. }
  51154. // ResetBotType resets all changes to the "bot_type" field.
  51155. func (m *WxCardVisitMutation) ResetBotType() {
  51156. m.bot_type = nil
  51157. m.addbot_type = nil
  51158. }
  51159. // Where appends a list predicates to the WxCardVisitMutation builder.
  51160. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51161. m.predicates = append(m.predicates, ps...)
  51162. }
  51163. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51164. // users can use type-assertion to append predicates that do not depend on any generated package.
  51165. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51166. p := make([]predicate.WxCardVisit, len(ps))
  51167. for i := range ps {
  51168. p[i] = ps[i]
  51169. }
  51170. m.Where(p...)
  51171. }
  51172. // Op returns the operation name.
  51173. func (m *WxCardVisitMutation) Op() Op {
  51174. return m.op
  51175. }
  51176. // SetOp allows setting the mutation operation.
  51177. func (m *WxCardVisitMutation) SetOp(op Op) {
  51178. m.op = op
  51179. }
  51180. // Type returns the node type of this mutation (WxCardVisit).
  51181. func (m *WxCardVisitMutation) Type() string {
  51182. return m.typ
  51183. }
  51184. // Fields returns all fields that were changed during this mutation. Note that in
  51185. // order to get all numeric fields that were incremented/decremented, call
  51186. // AddedFields().
  51187. func (m *WxCardVisitMutation) Fields() []string {
  51188. fields := make([]string, 0, 6)
  51189. if m.created_at != nil {
  51190. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51191. }
  51192. if m.updated_at != nil {
  51193. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51194. }
  51195. if m.deleted_at != nil {
  51196. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51197. }
  51198. if m.user_id != nil {
  51199. fields = append(fields, wxcardvisit.FieldUserID)
  51200. }
  51201. if m.bot_id != nil {
  51202. fields = append(fields, wxcardvisit.FieldBotID)
  51203. }
  51204. if m.bot_type != nil {
  51205. fields = append(fields, wxcardvisit.FieldBotType)
  51206. }
  51207. return fields
  51208. }
  51209. // Field returns the value of a field with the given name. The second boolean
  51210. // return value indicates that this field was not set, or was not defined in the
  51211. // schema.
  51212. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51213. switch name {
  51214. case wxcardvisit.FieldCreatedAt:
  51215. return m.CreatedAt()
  51216. case wxcardvisit.FieldUpdatedAt:
  51217. return m.UpdatedAt()
  51218. case wxcardvisit.FieldDeletedAt:
  51219. return m.DeletedAt()
  51220. case wxcardvisit.FieldUserID:
  51221. return m.UserID()
  51222. case wxcardvisit.FieldBotID:
  51223. return m.BotID()
  51224. case wxcardvisit.FieldBotType:
  51225. return m.BotType()
  51226. }
  51227. return nil, false
  51228. }
  51229. // OldField returns the old value of the field from the database. An error is
  51230. // returned if the mutation operation is not UpdateOne, or the query to the
  51231. // database failed.
  51232. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51233. switch name {
  51234. case wxcardvisit.FieldCreatedAt:
  51235. return m.OldCreatedAt(ctx)
  51236. case wxcardvisit.FieldUpdatedAt:
  51237. return m.OldUpdatedAt(ctx)
  51238. case wxcardvisit.FieldDeletedAt:
  51239. return m.OldDeletedAt(ctx)
  51240. case wxcardvisit.FieldUserID:
  51241. return m.OldUserID(ctx)
  51242. case wxcardvisit.FieldBotID:
  51243. return m.OldBotID(ctx)
  51244. case wxcardvisit.FieldBotType:
  51245. return m.OldBotType(ctx)
  51246. }
  51247. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51248. }
  51249. // SetField sets the value of a field with the given name. It returns an error if
  51250. // the field is not defined in the schema, or if the type mismatched the field
  51251. // type.
  51252. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51253. switch name {
  51254. case wxcardvisit.FieldCreatedAt:
  51255. v, ok := value.(time.Time)
  51256. if !ok {
  51257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51258. }
  51259. m.SetCreatedAt(v)
  51260. return nil
  51261. case wxcardvisit.FieldUpdatedAt:
  51262. v, ok := value.(time.Time)
  51263. if !ok {
  51264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51265. }
  51266. m.SetUpdatedAt(v)
  51267. return nil
  51268. case wxcardvisit.FieldDeletedAt:
  51269. v, ok := value.(time.Time)
  51270. if !ok {
  51271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51272. }
  51273. m.SetDeletedAt(v)
  51274. return nil
  51275. case wxcardvisit.FieldUserID:
  51276. v, ok := value.(uint64)
  51277. if !ok {
  51278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51279. }
  51280. m.SetUserID(v)
  51281. return nil
  51282. case wxcardvisit.FieldBotID:
  51283. v, ok := value.(uint64)
  51284. if !ok {
  51285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51286. }
  51287. m.SetBotID(v)
  51288. return nil
  51289. case wxcardvisit.FieldBotType:
  51290. v, ok := value.(uint8)
  51291. if !ok {
  51292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51293. }
  51294. m.SetBotType(v)
  51295. return nil
  51296. }
  51297. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51298. }
  51299. // AddedFields returns all numeric fields that were incremented/decremented during
  51300. // this mutation.
  51301. func (m *WxCardVisitMutation) AddedFields() []string {
  51302. var fields []string
  51303. if m.adduser_id != nil {
  51304. fields = append(fields, wxcardvisit.FieldUserID)
  51305. }
  51306. if m.addbot_id != nil {
  51307. fields = append(fields, wxcardvisit.FieldBotID)
  51308. }
  51309. if m.addbot_type != nil {
  51310. fields = append(fields, wxcardvisit.FieldBotType)
  51311. }
  51312. return fields
  51313. }
  51314. // AddedField returns the numeric value that was incremented/decremented on a field
  51315. // with the given name. The second boolean return value indicates that this field
  51316. // was not set, or was not defined in the schema.
  51317. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51318. switch name {
  51319. case wxcardvisit.FieldUserID:
  51320. return m.AddedUserID()
  51321. case wxcardvisit.FieldBotID:
  51322. return m.AddedBotID()
  51323. case wxcardvisit.FieldBotType:
  51324. return m.AddedBotType()
  51325. }
  51326. return nil, false
  51327. }
  51328. // AddField adds the value to the field with the given name. It returns an error if
  51329. // the field is not defined in the schema, or if the type mismatched the field
  51330. // type.
  51331. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51332. switch name {
  51333. case wxcardvisit.FieldUserID:
  51334. v, ok := value.(int64)
  51335. if !ok {
  51336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51337. }
  51338. m.AddUserID(v)
  51339. return nil
  51340. case wxcardvisit.FieldBotID:
  51341. v, ok := value.(int64)
  51342. if !ok {
  51343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51344. }
  51345. m.AddBotID(v)
  51346. return nil
  51347. case wxcardvisit.FieldBotType:
  51348. v, ok := value.(int8)
  51349. if !ok {
  51350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51351. }
  51352. m.AddBotType(v)
  51353. return nil
  51354. }
  51355. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51356. }
  51357. // ClearedFields returns all nullable fields that were cleared during this
  51358. // mutation.
  51359. func (m *WxCardVisitMutation) ClearedFields() []string {
  51360. var fields []string
  51361. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51362. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51363. }
  51364. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51365. fields = append(fields, wxcardvisit.FieldUserID)
  51366. }
  51367. return fields
  51368. }
  51369. // FieldCleared returns a boolean indicating if a field with the given name was
  51370. // cleared in this mutation.
  51371. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51372. _, ok := m.clearedFields[name]
  51373. return ok
  51374. }
  51375. // ClearField clears the value of the field with the given name. It returns an
  51376. // error if the field is not defined in the schema.
  51377. func (m *WxCardVisitMutation) ClearField(name string) error {
  51378. switch name {
  51379. case wxcardvisit.FieldDeletedAt:
  51380. m.ClearDeletedAt()
  51381. return nil
  51382. case wxcardvisit.FieldUserID:
  51383. m.ClearUserID()
  51384. return nil
  51385. }
  51386. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51387. }
  51388. // ResetField resets all changes in the mutation for the field with the given name.
  51389. // It returns an error if the field is not defined in the schema.
  51390. func (m *WxCardVisitMutation) ResetField(name string) error {
  51391. switch name {
  51392. case wxcardvisit.FieldCreatedAt:
  51393. m.ResetCreatedAt()
  51394. return nil
  51395. case wxcardvisit.FieldUpdatedAt:
  51396. m.ResetUpdatedAt()
  51397. return nil
  51398. case wxcardvisit.FieldDeletedAt:
  51399. m.ResetDeletedAt()
  51400. return nil
  51401. case wxcardvisit.FieldUserID:
  51402. m.ResetUserID()
  51403. return nil
  51404. case wxcardvisit.FieldBotID:
  51405. m.ResetBotID()
  51406. return nil
  51407. case wxcardvisit.FieldBotType:
  51408. m.ResetBotType()
  51409. return nil
  51410. }
  51411. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51412. }
  51413. // AddedEdges returns all edge names that were set/added in this mutation.
  51414. func (m *WxCardVisitMutation) AddedEdges() []string {
  51415. edges := make([]string, 0, 0)
  51416. return edges
  51417. }
  51418. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51419. // name in this mutation.
  51420. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51421. return nil
  51422. }
  51423. // RemovedEdges returns all edge names that were removed in this mutation.
  51424. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51425. edges := make([]string, 0, 0)
  51426. return edges
  51427. }
  51428. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51429. // the given name in this mutation.
  51430. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51431. return nil
  51432. }
  51433. // ClearedEdges returns all edge names that were cleared in this mutation.
  51434. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51435. edges := make([]string, 0, 0)
  51436. return edges
  51437. }
  51438. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51439. // was cleared in this mutation.
  51440. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51441. return false
  51442. }
  51443. // ClearEdge clears the value of the edge with the given name. It returns an error
  51444. // if that edge is not defined in the schema.
  51445. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51446. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51447. }
  51448. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51449. // It returns an error if the edge is not defined in the schema.
  51450. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51451. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51452. }
  51453. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51454. type XunjiMutation struct {
  51455. config
  51456. op Op
  51457. typ string
  51458. id *uint64
  51459. created_at *time.Time
  51460. updated_at *time.Time
  51461. status *uint8
  51462. addstatus *int8
  51463. deleted_at *time.Time
  51464. app_key *string
  51465. app_secret *string
  51466. token *string
  51467. encoding_key *string
  51468. organization_id *uint64
  51469. addorganization_id *int64
  51470. clearedFields map[string]struct{}
  51471. done bool
  51472. oldValue func(context.Context) (*Xunji, error)
  51473. predicates []predicate.Xunji
  51474. }
  51475. var _ ent.Mutation = (*XunjiMutation)(nil)
  51476. // xunjiOption allows management of the mutation configuration using functional options.
  51477. type xunjiOption func(*XunjiMutation)
  51478. // newXunjiMutation creates new mutation for the Xunji entity.
  51479. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51480. m := &XunjiMutation{
  51481. config: c,
  51482. op: op,
  51483. typ: TypeXunji,
  51484. clearedFields: make(map[string]struct{}),
  51485. }
  51486. for _, opt := range opts {
  51487. opt(m)
  51488. }
  51489. return m
  51490. }
  51491. // withXunjiID sets the ID field of the mutation.
  51492. func withXunjiID(id uint64) xunjiOption {
  51493. return func(m *XunjiMutation) {
  51494. var (
  51495. err error
  51496. once sync.Once
  51497. value *Xunji
  51498. )
  51499. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51500. once.Do(func() {
  51501. if m.done {
  51502. err = errors.New("querying old values post mutation is not allowed")
  51503. } else {
  51504. value, err = m.Client().Xunji.Get(ctx, id)
  51505. }
  51506. })
  51507. return value, err
  51508. }
  51509. m.id = &id
  51510. }
  51511. }
  51512. // withXunji sets the old Xunji of the mutation.
  51513. func withXunji(node *Xunji) xunjiOption {
  51514. return func(m *XunjiMutation) {
  51515. m.oldValue = func(context.Context) (*Xunji, error) {
  51516. return node, nil
  51517. }
  51518. m.id = &node.ID
  51519. }
  51520. }
  51521. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51522. // executed in a transaction (ent.Tx), a transactional client is returned.
  51523. func (m XunjiMutation) Client() *Client {
  51524. client := &Client{config: m.config}
  51525. client.init()
  51526. return client
  51527. }
  51528. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51529. // it returns an error otherwise.
  51530. func (m XunjiMutation) Tx() (*Tx, error) {
  51531. if _, ok := m.driver.(*txDriver); !ok {
  51532. return nil, errors.New("ent: mutation is not running in a transaction")
  51533. }
  51534. tx := &Tx{config: m.config}
  51535. tx.init()
  51536. return tx, nil
  51537. }
  51538. // SetID sets the value of the id field. Note that this
  51539. // operation is only accepted on creation of Xunji entities.
  51540. func (m *XunjiMutation) SetID(id uint64) {
  51541. m.id = &id
  51542. }
  51543. // ID returns the ID value in the mutation. Note that the ID is only available
  51544. // if it was provided to the builder or after it was returned from the database.
  51545. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51546. if m.id == nil {
  51547. return
  51548. }
  51549. return *m.id, true
  51550. }
  51551. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51552. // That means, if the mutation is applied within a transaction with an isolation level such
  51553. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51554. // or updated by the mutation.
  51555. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51556. switch {
  51557. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51558. id, exists := m.ID()
  51559. if exists {
  51560. return []uint64{id}, nil
  51561. }
  51562. fallthrough
  51563. case m.op.Is(OpUpdate | OpDelete):
  51564. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51565. default:
  51566. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51567. }
  51568. }
  51569. // SetCreatedAt sets the "created_at" field.
  51570. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51571. m.created_at = &t
  51572. }
  51573. // CreatedAt returns the value of the "created_at" field in the mutation.
  51574. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51575. v := m.created_at
  51576. if v == nil {
  51577. return
  51578. }
  51579. return *v, true
  51580. }
  51581. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51582. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51584. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51585. if !m.op.Is(OpUpdateOne) {
  51586. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51587. }
  51588. if m.id == nil || m.oldValue == nil {
  51589. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51590. }
  51591. oldValue, err := m.oldValue(ctx)
  51592. if err != nil {
  51593. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51594. }
  51595. return oldValue.CreatedAt, nil
  51596. }
  51597. // ResetCreatedAt resets all changes to the "created_at" field.
  51598. func (m *XunjiMutation) ResetCreatedAt() {
  51599. m.created_at = nil
  51600. }
  51601. // SetUpdatedAt sets the "updated_at" field.
  51602. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51603. m.updated_at = &t
  51604. }
  51605. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51606. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51607. v := m.updated_at
  51608. if v == nil {
  51609. return
  51610. }
  51611. return *v, true
  51612. }
  51613. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51614. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51616. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51617. if !m.op.Is(OpUpdateOne) {
  51618. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51619. }
  51620. if m.id == nil || m.oldValue == nil {
  51621. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51622. }
  51623. oldValue, err := m.oldValue(ctx)
  51624. if err != nil {
  51625. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51626. }
  51627. return oldValue.UpdatedAt, nil
  51628. }
  51629. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51630. func (m *XunjiMutation) ResetUpdatedAt() {
  51631. m.updated_at = nil
  51632. }
  51633. // SetStatus sets the "status" field.
  51634. func (m *XunjiMutation) SetStatus(u uint8) {
  51635. m.status = &u
  51636. m.addstatus = nil
  51637. }
  51638. // Status returns the value of the "status" field in the mutation.
  51639. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51640. v := m.status
  51641. if v == nil {
  51642. return
  51643. }
  51644. return *v, true
  51645. }
  51646. // OldStatus returns the old "status" field's value of the Xunji entity.
  51647. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51649. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51650. if !m.op.Is(OpUpdateOne) {
  51651. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51652. }
  51653. if m.id == nil || m.oldValue == nil {
  51654. return v, errors.New("OldStatus requires an ID field in the mutation")
  51655. }
  51656. oldValue, err := m.oldValue(ctx)
  51657. if err != nil {
  51658. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51659. }
  51660. return oldValue.Status, nil
  51661. }
  51662. // AddStatus adds u to the "status" field.
  51663. func (m *XunjiMutation) AddStatus(u int8) {
  51664. if m.addstatus != nil {
  51665. *m.addstatus += u
  51666. } else {
  51667. m.addstatus = &u
  51668. }
  51669. }
  51670. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51671. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51672. v := m.addstatus
  51673. if v == nil {
  51674. return
  51675. }
  51676. return *v, true
  51677. }
  51678. // ClearStatus clears the value of the "status" field.
  51679. func (m *XunjiMutation) ClearStatus() {
  51680. m.status = nil
  51681. m.addstatus = nil
  51682. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51683. }
  51684. // StatusCleared returns if the "status" field was cleared in this mutation.
  51685. func (m *XunjiMutation) StatusCleared() bool {
  51686. _, ok := m.clearedFields[xunji.FieldStatus]
  51687. return ok
  51688. }
  51689. // ResetStatus resets all changes to the "status" field.
  51690. func (m *XunjiMutation) ResetStatus() {
  51691. m.status = nil
  51692. m.addstatus = nil
  51693. delete(m.clearedFields, xunji.FieldStatus)
  51694. }
  51695. // SetDeletedAt sets the "deleted_at" field.
  51696. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51697. m.deleted_at = &t
  51698. }
  51699. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51700. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51701. v := m.deleted_at
  51702. if v == nil {
  51703. return
  51704. }
  51705. return *v, true
  51706. }
  51707. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51708. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51710. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51711. if !m.op.Is(OpUpdateOne) {
  51712. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51713. }
  51714. if m.id == nil || m.oldValue == nil {
  51715. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51716. }
  51717. oldValue, err := m.oldValue(ctx)
  51718. if err != nil {
  51719. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51720. }
  51721. return oldValue.DeletedAt, nil
  51722. }
  51723. // ClearDeletedAt clears the value of the "deleted_at" field.
  51724. func (m *XunjiMutation) ClearDeletedAt() {
  51725. m.deleted_at = nil
  51726. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51727. }
  51728. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51729. func (m *XunjiMutation) DeletedAtCleared() bool {
  51730. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51731. return ok
  51732. }
  51733. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51734. func (m *XunjiMutation) ResetDeletedAt() {
  51735. m.deleted_at = nil
  51736. delete(m.clearedFields, xunji.FieldDeletedAt)
  51737. }
  51738. // SetAppKey sets the "app_key" field.
  51739. func (m *XunjiMutation) SetAppKey(s string) {
  51740. m.app_key = &s
  51741. }
  51742. // AppKey returns the value of the "app_key" field in the mutation.
  51743. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51744. v := m.app_key
  51745. if v == nil {
  51746. return
  51747. }
  51748. return *v, true
  51749. }
  51750. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51751. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51753. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51754. if !m.op.Is(OpUpdateOne) {
  51755. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51756. }
  51757. if m.id == nil || m.oldValue == nil {
  51758. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51759. }
  51760. oldValue, err := m.oldValue(ctx)
  51761. if err != nil {
  51762. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51763. }
  51764. return oldValue.AppKey, nil
  51765. }
  51766. // ClearAppKey clears the value of the "app_key" field.
  51767. func (m *XunjiMutation) ClearAppKey() {
  51768. m.app_key = nil
  51769. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  51770. }
  51771. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  51772. func (m *XunjiMutation) AppKeyCleared() bool {
  51773. _, ok := m.clearedFields[xunji.FieldAppKey]
  51774. return ok
  51775. }
  51776. // ResetAppKey resets all changes to the "app_key" field.
  51777. func (m *XunjiMutation) ResetAppKey() {
  51778. m.app_key = nil
  51779. delete(m.clearedFields, xunji.FieldAppKey)
  51780. }
  51781. // SetAppSecret sets the "app_secret" field.
  51782. func (m *XunjiMutation) SetAppSecret(s string) {
  51783. m.app_secret = &s
  51784. }
  51785. // AppSecret returns the value of the "app_secret" field in the mutation.
  51786. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  51787. v := m.app_secret
  51788. if v == nil {
  51789. return
  51790. }
  51791. return *v, true
  51792. }
  51793. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  51794. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51796. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  51797. if !m.op.Is(OpUpdateOne) {
  51798. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  51799. }
  51800. if m.id == nil || m.oldValue == nil {
  51801. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  51802. }
  51803. oldValue, err := m.oldValue(ctx)
  51804. if err != nil {
  51805. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  51806. }
  51807. return oldValue.AppSecret, nil
  51808. }
  51809. // ClearAppSecret clears the value of the "app_secret" field.
  51810. func (m *XunjiMutation) ClearAppSecret() {
  51811. m.app_secret = nil
  51812. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  51813. }
  51814. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  51815. func (m *XunjiMutation) AppSecretCleared() bool {
  51816. _, ok := m.clearedFields[xunji.FieldAppSecret]
  51817. return ok
  51818. }
  51819. // ResetAppSecret resets all changes to the "app_secret" field.
  51820. func (m *XunjiMutation) ResetAppSecret() {
  51821. m.app_secret = nil
  51822. delete(m.clearedFields, xunji.FieldAppSecret)
  51823. }
  51824. // SetToken sets the "token" field.
  51825. func (m *XunjiMutation) SetToken(s string) {
  51826. m.token = &s
  51827. }
  51828. // Token returns the value of the "token" field in the mutation.
  51829. func (m *XunjiMutation) Token() (r string, exists bool) {
  51830. v := m.token
  51831. if v == nil {
  51832. return
  51833. }
  51834. return *v, true
  51835. }
  51836. // OldToken returns the old "token" field's value of the Xunji entity.
  51837. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51839. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  51840. if !m.op.Is(OpUpdateOne) {
  51841. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  51842. }
  51843. if m.id == nil || m.oldValue == nil {
  51844. return v, errors.New("OldToken requires an ID field in the mutation")
  51845. }
  51846. oldValue, err := m.oldValue(ctx)
  51847. if err != nil {
  51848. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  51849. }
  51850. return oldValue.Token, nil
  51851. }
  51852. // ClearToken clears the value of the "token" field.
  51853. func (m *XunjiMutation) ClearToken() {
  51854. m.token = nil
  51855. m.clearedFields[xunji.FieldToken] = struct{}{}
  51856. }
  51857. // TokenCleared returns if the "token" field was cleared in this mutation.
  51858. func (m *XunjiMutation) TokenCleared() bool {
  51859. _, ok := m.clearedFields[xunji.FieldToken]
  51860. return ok
  51861. }
  51862. // ResetToken resets all changes to the "token" field.
  51863. func (m *XunjiMutation) ResetToken() {
  51864. m.token = nil
  51865. delete(m.clearedFields, xunji.FieldToken)
  51866. }
  51867. // SetEncodingKey sets the "encoding_key" field.
  51868. func (m *XunjiMutation) SetEncodingKey(s string) {
  51869. m.encoding_key = &s
  51870. }
  51871. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  51872. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  51873. v := m.encoding_key
  51874. if v == nil {
  51875. return
  51876. }
  51877. return *v, true
  51878. }
  51879. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  51880. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51882. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  51883. if !m.op.Is(OpUpdateOne) {
  51884. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  51885. }
  51886. if m.id == nil || m.oldValue == nil {
  51887. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  51888. }
  51889. oldValue, err := m.oldValue(ctx)
  51890. if err != nil {
  51891. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  51892. }
  51893. return oldValue.EncodingKey, nil
  51894. }
  51895. // ClearEncodingKey clears the value of the "encoding_key" field.
  51896. func (m *XunjiMutation) ClearEncodingKey() {
  51897. m.encoding_key = nil
  51898. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  51899. }
  51900. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  51901. func (m *XunjiMutation) EncodingKeyCleared() bool {
  51902. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  51903. return ok
  51904. }
  51905. // ResetEncodingKey resets all changes to the "encoding_key" field.
  51906. func (m *XunjiMutation) ResetEncodingKey() {
  51907. m.encoding_key = nil
  51908. delete(m.clearedFields, xunji.FieldEncodingKey)
  51909. }
  51910. // SetOrganizationID sets the "organization_id" field.
  51911. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  51912. m.organization_id = &u
  51913. m.addorganization_id = nil
  51914. }
  51915. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51916. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  51917. v := m.organization_id
  51918. if v == nil {
  51919. return
  51920. }
  51921. return *v, true
  51922. }
  51923. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  51924. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51926. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51927. if !m.op.Is(OpUpdateOne) {
  51928. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51929. }
  51930. if m.id == nil || m.oldValue == nil {
  51931. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51932. }
  51933. oldValue, err := m.oldValue(ctx)
  51934. if err != nil {
  51935. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51936. }
  51937. return oldValue.OrganizationID, nil
  51938. }
  51939. // AddOrganizationID adds u to the "organization_id" field.
  51940. func (m *XunjiMutation) AddOrganizationID(u int64) {
  51941. if m.addorganization_id != nil {
  51942. *m.addorganization_id += u
  51943. } else {
  51944. m.addorganization_id = &u
  51945. }
  51946. }
  51947. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51948. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  51949. v := m.addorganization_id
  51950. if v == nil {
  51951. return
  51952. }
  51953. return *v, true
  51954. }
  51955. // ResetOrganizationID resets all changes to the "organization_id" field.
  51956. func (m *XunjiMutation) ResetOrganizationID() {
  51957. m.organization_id = nil
  51958. m.addorganization_id = nil
  51959. }
  51960. // Where appends a list predicates to the XunjiMutation builder.
  51961. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  51962. m.predicates = append(m.predicates, ps...)
  51963. }
  51964. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  51965. // users can use type-assertion to append predicates that do not depend on any generated package.
  51966. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  51967. p := make([]predicate.Xunji, len(ps))
  51968. for i := range ps {
  51969. p[i] = ps[i]
  51970. }
  51971. m.Where(p...)
  51972. }
  51973. // Op returns the operation name.
  51974. func (m *XunjiMutation) Op() Op {
  51975. return m.op
  51976. }
  51977. // SetOp allows setting the mutation operation.
  51978. func (m *XunjiMutation) SetOp(op Op) {
  51979. m.op = op
  51980. }
  51981. // Type returns the node type of this mutation (Xunji).
  51982. func (m *XunjiMutation) Type() string {
  51983. return m.typ
  51984. }
  51985. // Fields returns all fields that were changed during this mutation. Note that in
  51986. // order to get all numeric fields that were incremented/decremented, call
  51987. // AddedFields().
  51988. func (m *XunjiMutation) Fields() []string {
  51989. fields := make([]string, 0, 9)
  51990. if m.created_at != nil {
  51991. fields = append(fields, xunji.FieldCreatedAt)
  51992. }
  51993. if m.updated_at != nil {
  51994. fields = append(fields, xunji.FieldUpdatedAt)
  51995. }
  51996. if m.status != nil {
  51997. fields = append(fields, xunji.FieldStatus)
  51998. }
  51999. if m.deleted_at != nil {
  52000. fields = append(fields, xunji.FieldDeletedAt)
  52001. }
  52002. if m.app_key != nil {
  52003. fields = append(fields, xunji.FieldAppKey)
  52004. }
  52005. if m.app_secret != nil {
  52006. fields = append(fields, xunji.FieldAppSecret)
  52007. }
  52008. if m.token != nil {
  52009. fields = append(fields, xunji.FieldToken)
  52010. }
  52011. if m.encoding_key != nil {
  52012. fields = append(fields, xunji.FieldEncodingKey)
  52013. }
  52014. if m.organization_id != nil {
  52015. fields = append(fields, xunji.FieldOrganizationID)
  52016. }
  52017. return fields
  52018. }
  52019. // Field returns the value of a field with the given name. The second boolean
  52020. // return value indicates that this field was not set, or was not defined in the
  52021. // schema.
  52022. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  52023. switch name {
  52024. case xunji.FieldCreatedAt:
  52025. return m.CreatedAt()
  52026. case xunji.FieldUpdatedAt:
  52027. return m.UpdatedAt()
  52028. case xunji.FieldStatus:
  52029. return m.Status()
  52030. case xunji.FieldDeletedAt:
  52031. return m.DeletedAt()
  52032. case xunji.FieldAppKey:
  52033. return m.AppKey()
  52034. case xunji.FieldAppSecret:
  52035. return m.AppSecret()
  52036. case xunji.FieldToken:
  52037. return m.Token()
  52038. case xunji.FieldEncodingKey:
  52039. return m.EncodingKey()
  52040. case xunji.FieldOrganizationID:
  52041. return m.OrganizationID()
  52042. }
  52043. return nil, false
  52044. }
  52045. // OldField returns the old value of the field from the database. An error is
  52046. // returned if the mutation operation is not UpdateOne, or the query to the
  52047. // database failed.
  52048. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52049. switch name {
  52050. case xunji.FieldCreatedAt:
  52051. return m.OldCreatedAt(ctx)
  52052. case xunji.FieldUpdatedAt:
  52053. return m.OldUpdatedAt(ctx)
  52054. case xunji.FieldStatus:
  52055. return m.OldStatus(ctx)
  52056. case xunji.FieldDeletedAt:
  52057. return m.OldDeletedAt(ctx)
  52058. case xunji.FieldAppKey:
  52059. return m.OldAppKey(ctx)
  52060. case xunji.FieldAppSecret:
  52061. return m.OldAppSecret(ctx)
  52062. case xunji.FieldToken:
  52063. return m.OldToken(ctx)
  52064. case xunji.FieldEncodingKey:
  52065. return m.OldEncodingKey(ctx)
  52066. case xunji.FieldOrganizationID:
  52067. return m.OldOrganizationID(ctx)
  52068. }
  52069. return nil, fmt.Errorf("unknown Xunji field %s", name)
  52070. }
  52071. // SetField sets the value of a field with the given name. It returns an error if
  52072. // the field is not defined in the schema, or if the type mismatched the field
  52073. // type.
  52074. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  52075. switch name {
  52076. case xunji.FieldCreatedAt:
  52077. v, ok := value.(time.Time)
  52078. if !ok {
  52079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52080. }
  52081. m.SetCreatedAt(v)
  52082. return nil
  52083. case xunji.FieldUpdatedAt:
  52084. v, ok := value.(time.Time)
  52085. if !ok {
  52086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52087. }
  52088. m.SetUpdatedAt(v)
  52089. return nil
  52090. case xunji.FieldStatus:
  52091. v, ok := value.(uint8)
  52092. if !ok {
  52093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52094. }
  52095. m.SetStatus(v)
  52096. return nil
  52097. case xunji.FieldDeletedAt:
  52098. v, ok := value.(time.Time)
  52099. if !ok {
  52100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52101. }
  52102. m.SetDeletedAt(v)
  52103. return nil
  52104. case xunji.FieldAppKey:
  52105. v, ok := value.(string)
  52106. if !ok {
  52107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52108. }
  52109. m.SetAppKey(v)
  52110. return nil
  52111. case xunji.FieldAppSecret:
  52112. v, ok := value.(string)
  52113. if !ok {
  52114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52115. }
  52116. m.SetAppSecret(v)
  52117. return nil
  52118. case xunji.FieldToken:
  52119. v, ok := value.(string)
  52120. if !ok {
  52121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52122. }
  52123. m.SetToken(v)
  52124. return nil
  52125. case xunji.FieldEncodingKey:
  52126. v, ok := value.(string)
  52127. if !ok {
  52128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52129. }
  52130. m.SetEncodingKey(v)
  52131. return nil
  52132. case xunji.FieldOrganizationID:
  52133. v, ok := value.(uint64)
  52134. if !ok {
  52135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52136. }
  52137. m.SetOrganizationID(v)
  52138. return nil
  52139. }
  52140. return fmt.Errorf("unknown Xunji field %s", name)
  52141. }
  52142. // AddedFields returns all numeric fields that were incremented/decremented during
  52143. // this mutation.
  52144. func (m *XunjiMutation) AddedFields() []string {
  52145. var fields []string
  52146. if m.addstatus != nil {
  52147. fields = append(fields, xunji.FieldStatus)
  52148. }
  52149. if m.addorganization_id != nil {
  52150. fields = append(fields, xunji.FieldOrganizationID)
  52151. }
  52152. return fields
  52153. }
  52154. // AddedField returns the numeric value that was incremented/decremented on a field
  52155. // with the given name. The second boolean return value indicates that this field
  52156. // was not set, or was not defined in the schema.
  52157. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52158. switch name {
  52159. case xunji.FieldStatus:
  52160. return m.AddedStatus()
  52161. case xunji.FieldOrganizationID:
  52162. return m.AddedOrganizationID()
  52163. }
  52164. return nil, false
  52165. }
  52166. // AddField adds the value to the field with the given name. It returns an error if
  52167. // the field is not defined in the schema, or if the type mismatched the field
  52168. // type.
  52169. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52170. switch name {
  52171. case xunji.FieldStatus:
  52172. v, ok := value.(int8)
  52173. if !ok {
  52174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52175. }
  52176. m.AddStatus(v)
  52177. return nil
  52178. case xunji.FieldOrganizationID:
  52179. v, ok := value.(int64)
  52180. if !ok {
  52181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52182. }
  52183. m.AddOrganizationID(v)
  52184. return nil
  52185. }
  52186. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52187. }
  52188. // ClearedFields returns all nullable fields that were cleared during this
  52189. // mutation.
  52190. func (m *XunjiMutation) ClearedFields() []string {
  52191. var fields []string
  52192. if m.FieldCleared(xunji.FieldStatus) {
  52193. fields = append(fields, xunji.FieldStatus)
  52194. }
  52195. if m.FieldCleared(xunji.FieldDeletedAt) {
  52196. fields = append(fields, xunji.FieldDeletedAt)
  52197. }
  52198. if m.FieldCleared(xunji.FieldAppKey) {
  52199. fields = append(fields, xunji.FieldAppKey)
  52200. }
  52201. if m.FieldCleared(xunji.FieldAppSecret) {
  52202. fields = append(fields, xunji.FieldAppSecret)
  52203. }
  52204. if m.FieldCleared(xunji.FieldToken) {
  52205. fields = append(fields, xunji.FieldToken)
  52206. }
  52207. if m.FieldCleared(xunji.FieldEncodingKey) {
  52208. fields = append(fields, xunji.FieldEncodingKey)
  52209. }
  52210. return fields
  52211. }
  52212. // FieldCleared returns a boolean indicating if a field with the given name was
  52213. // cleared in this mutation.
  52214. func (m *XunjiMutation) FieldCleared(name string) bool {
  52215. _, ok := m.clearedFields[name]
  52216. return ok
  52217. }
  52218. // ClearField clears the value of the field with the given name. It returns an
  52219. // error if the field is not defined in the schema.
  52220. func (m *XunjiMutation) ClearField(name string) error {
  52221. switch name {
  52222. case xunji.FieldStatus:
  52223. m.ClearStatus()
  52224. return nil
  52225. case xunji.FieldDeletedAt:
  52226. m.ClearDeletedAt()
  52227. return nil
  52228. case xunji.FieldAppKey:
  52229. m.ClearAppKey()
  52230. return nil
  52231. case xunji.FieldAppSecret:
  52232. m.ClearAppSecret()
  52233. return nil
  52234. case xunji.FieldToken:
  52235. m.ClearToken()
  52236. return nil
  52237. case xunji.FieldEncodingKey:
  52238. m.ClearEncodingKey()
  52239. return nil
  52240. }
  52241. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52242. }
  52243. // ResetField resets all changes in the mutation for the field with the given name.
  52244. // It returns an error if the field is not defined in the schema.
  52245. func (m *XunjiMutation) ResetField(name string) error {
  52246. switch name {
  52247. case xunji.FieldCreatedAt:
  52248. m.ResetCreatedAt()
  52249. return nil
  52250. case xunji.FieldUpdatedAt:
  52251. m.ResetUpdatedAt()
  52252. return nil
  52253. case xunji.FieldStatus:
  52254. m.ResetStatus()
  52255. return nil
  52256. case xunji.FieldDeletedAt:
  52257. m.ResetDeletedAt()
  52258. return nil
  52259. case xunji.FieldAppKey:
  52260. m.ResetAppKey()
  52261. return nil
  52262. case xunji.FieldAppSecret:
  52263. m.ResetAppSecret()
  52264. return nil
  52265. case xunji.FieldToken:
  52266. m.ResetToken()
  52267. return nil
  52268. case xunji.FieldEncodingKey:
  52269. m.ResetEncodingKey()
  52270. return nil
  52271. case xunji.FieldOrganizationID:
  52272. m.ResetOrganizationID()
  52273. return nil
  52274. }
  52275. return fmt.Errorf("unknown Xunji field %s", name)
  52276. }
  52277. // AddedEdges returns all edge names that were set/added in this mutation.
  52278. func (m *XunjiMutation) AddedEdges() []string {
  52279. edges := make([]string, 0, 0)
  52280. return edges
  52281. }
  52282. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52283. // name in this mutation.
  52284. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52285. return nil
  52286. }
  52287. // RemovedEdges returns all edge names that were removed in this mutation.
  52288. func (m *XunjiMutation) RemovedEdges() []string {
  52289. edges := make([]string, 0, 0)
  52290. return edges
  52291. }
  52292. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52293. // the given name in this mutation.
  52294. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52295. return nil
  52296. }
  52297. // ClearedEdges returns all edge names that were cleared in this mutation.
  52298. func (m *XunjiMutation) ClearedEdges() []string {
  52299. edges := make([]string, 0, 0)
  52300. return edges
  52301. }
  52302. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52303. // was cleared in this mutation.
  52304. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52305. return false
  52306. }
  52307. // ClearEdge clears the value of the edge with the given name. It returns an error
  52308. // if that edge is not defined in the schema.
  52309. func (m *XunjiMutation) ClearEdge(name string) error {
  52310. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52311. }
  52312. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52313. // It returns an error if the edge is not defined in the schema.
  52314. func (m *XunjiMutation) ResetEdge(name string) error {
  52315. return fmt.Errorf("unknown Xunji edge %s", name)
  52316. }
  52317. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52318. type XunjiServiceMutation struct {
  52319. config
  52320. op Op
  52321. typ string
  52322. id *uint64
  52323. created_at *time.Time
  52324. updated_at *time.Time
  52325. status *uint8
  52326. addstatus *int8
  52327. deleted_at *time.Time
  52328. xunji_id *uint64
  52329. addxunji_id *int64
  52330. organization_id *uint64
  52331. addorganization_id *int64
  52332. wxid *string
  52333. api_base *string
  52334. api_key *string
  52335. clearedFields map[string]struct{}
  52336. agent *uint64
  52337. clearedagent bool
  52338. done bool
  52339. oldValue func(context.Context) (*XunjiService, error)
  52340. predicates []predicate.XunjiService
  52341. }
  52342. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52343. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52344. type xunjiserviceOption func(*XunjiServiceMutation)
  52345. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52346. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52347. m := &XunjiServiceMutation{
  52348. config: c,
  52349. op: op,
  52350. typ: TypeXunjiService,
  52351. clearedFields: make(map[string]struct{}),
  52352. }
  52353. for _, opt := range opts {
  52354. opt(m)
  52355. }
  52356. return m
  52357. }
  52358. // withXunjiServiceID sets the ID field of the mutation.
  52359. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52360. return func(m *XunjiServiceMutation) {
  52361. var (
  52362. err error
  52363. once sync.Once
  52364. value *XunjiService
  52365. )
  52366. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52367. once.Do(func() {
  52368. if m.done {
  52369. err = errors.New("querying old values post mutation is not allowed")
  52370. } else {
  52371. value, err = m.Client().XunjiService.Get(ctx, id)
  52372. }
  52373. })
  52374. return value, err
  52375. }
  52376. m.id = &id
  52377. }
  52378. }
  52379. // withXunjiService sets the old XunjiService of the mutation.
  52380. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52381. return func(m *XunjiServiceMutation) {
  52382. m.oldValue = func(context.Context) (*XunjiService, error) {
  52383. return node, nil
  52384. }
  52385. m.id = &node.ID
  52386. }
  52387. }
  52388. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52389. // executed in a transaction (ent.Tx), a transactional client is returned.
  52390. func (m XunjiServiceMutation) Client() *Client {
  52391. client := &Client{config: m.config}
  52392. client.init()
  52393. return client
  52394. }
  52395. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52396. // it returns an error otherwise.
  52397. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52398. if _, ok := m.driver.(*txDriver); !ok {
  52399. return nil, errors.New("ent: mutation is not running in a transaction")
  52400. }
  52401. tx := &Tx{config: m.config}
  52402. tx.init()
  52403. return tx, nil
  52404. }
  52405. // SetID sets the value of the id field. Note that this
  52406. // operation is only accepted on creation of XunjiService entities.
  52407. func (m *XunjiServiceMutation) SetID(id uint64) {
  52408. m.id = &id
  52409. }
  52410. // ID returns the ID value in the mutation. Note that the ID is only available
  52411. // if it was provided to the builder or after it was returned from the database.
  52412. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52413. if m.id == nil {
  52414. return
  52415. }
  52416. return *m.id, true
  52417. }
  52418. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52419. // That means, if the mutation is applied within a transaction with an isolation level such
  52420. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52421. // or updated by the mutation.
  52422. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52423. switch {
  52424. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52425. id, exists := m.ID()
  52426. if exists {
  52427. return []uint64{id}, nil
  52428. }
  52429. fallthrough
  52430. case m.op.Is(OpUpdate | OpDelete):
  52431. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52432. default:
  52433. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52434. }
  52435. }
  52436. // SetCreatedAt sets the "created_at" field.
  52437. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52438. m.created_at = &t
  52439. }
  52440. // CreatedAt returns the value of the "created_at" field in the mutation.
  52441. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52442. v := m.created_at
  52443. if v == nil {
  52444. return
  52445. }
  52446. return *v, true
  52447. }
  52448. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52449. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52451. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52452. if !m.op.Is(OpUpdateOne) {
  52453. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52454. }
  52455. if m.id == nil || m.oldValue == nil {
  52456. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52457. }
  52458. oldValue, err := m.oldValue(ctx)
  52459. if err != nil {
  52460. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52461. }
  52462. return oldValue.CreatedAt, nil
  52463. }
  52464. // ResetCreatedAt resets all changes to the "created_at" field.
  52465. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52466. m.created_at = nil
  52467. }
  52468. // SetUpdatedAt sets the "updated_at" field.
  52469. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52470. m.updated_at = &t
  52471. }
  52472. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52473. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52474. v := m.updated_at
  52475. if v == nil {
  52476. return
  52477. }
  52478. return *v, true
  52479. }
  52480. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52481. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52483. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52484. if !m.op.Is(OpUpdateOne) {
  52485. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52486. }
  52487. if m.id == nil || m.oldValue == nil {
  52488. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52489. }
  52490. oldValue, err := m.oldValue(ctx)
  52491. if err != nil {
  52492. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52493. }
  52494. return oldValue.UpdatedAt, nil
  52495. }
  52496. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52497. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52498. m.updated_at = nil
  52499. }
  52500. // SetStatus sets the "status" field.
  52501. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52502. m.status = &u
  52503. m.addstatus = nil
  52504. }
  52505. // Status returns the value of the "status" field in the mutation.
  52506. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52507. v := m.status
  52508. if v == nil {
  52509. return
  52510. }
  52511. return *v, true
  52512. }
  52513. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52514. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52516. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52517. if !m.op.Is(OpUpdateOne) {
  52518. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52519. }
  52520. if m.id == nil || m.oldValue == nil {
  52521. return v, errors.New("OldStatus requires an ID field in the mutation")
  52522. }
  52523. oldValue, err := m.oldValue(ctx)
  52524. if err != nil {
  52525. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52526. }
  52527. return oldValue.Status, nil
  52528. }
  52529. // AddStatus adds u to the "status" field.
  52530. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52531. if m.addstatus != nil {
  52532. *m.addstatus += u
  52533. } else {
  52534. m.addstatus = &u
  52535. }
  52536. }
  52537. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52538. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52539. v := m.addstatus
  52540. if v == nil {
  52541. return
  52542. }
  52543. return *v, true
  52544. }
  52545. // ClearStatus clears the value of the "status" field.
  52546. func (m *XunjiServiceMutation) ClearStatus() {
  52547. m.status = nil
  52548. m.addstatus = nil
  52549. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52550. }
  52551. // StatusCleared returns if the "status" field was cleared in this mutation.
  52552. func (m *XunjiServiceMutation) StatusCleared() bool {
  52553. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52554. return ok
  52555. }
  52556. // ResetStatus resets all changes to the "status" field.
  52557. func (m *XunjiServiceMutation) ResetStatus() {
  52558. m.status = nil
  52559. m.addstatus = nil
  52560. delete(m.clearedFields, xunjiservice.FieldStatus)
  52561. }
  52562. // SetDeletedAt sets the "deleted_at" field.
  52563. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52564. m.deleted_at = &t
  52565. }
  52566. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52567. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52568. v := m.deleted_at
  52569. if v == nil {
  52570. return
  52571. }
  52572. return *v, true
  52573. }
  52574. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52575. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52577. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52578. if !m.op.Is(OpUpdateOne) {
  52579. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52580. }
  52581. if m.id == nil || m.oldValue == nil {
  52582. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52583. }
  52584. oldValue, err := m.oldValue(ctx)
  52585. if err != nil {
  52586. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52587. }
  52588. return oldValue.DeletedAt, nil
  52589. }
  52590. // ClearDeletedAt clears the value of the "deleted_at" field.
  52591. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52592. m.deleted_at = nil
  52593. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52594. }
  52595. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52596. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52597. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52598. return ok
  52599. }
  52600. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52601. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52602. m.deleted_at = nil
  52603. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52604. }
  52605. // SetXunjiID sets the "xunji_id" field.
  52606. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52607. m.xunji_id = &u
  52608. m.addxunji_id = nil
  52609. }
  52610. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52611. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52612. v := m.xunji_id
  52613. if v == nil {
  52614. return
  52615. }
  52616. return *v, true
  52617. }
  52618. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52619. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52621. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52622. if !m.op.Is(OpUpdateOne) {
  52623. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52624. }
  52625. if m.id == nil || m.oldValue == nil {
  52626. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52627. }
  52628. oldValue, err := m.oldValue(ctx)
  52629. if err != nil {
  52630. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52631. }
  52632. return oldValue.XunjiID, nil
  52633. }
  52634. // AddXunjiID adds u to the "xunji_id" field.
  52635. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52636. if m.addxunji_id != nil {
  52637. *m.addxunji_id += u
  52638. } else {
  52639. m.addxunji_id = &u
  52640. }
  52641. }
  52642. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52643. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52644. v := m.addxunji_id
  52645. if v == nil {
  52646. return
  52647. }
  52648. return *v, true
  52649. }
  52650. // ResetXunjiID resets all changes to the "xunji_id" field.
  52651. func (m *XunjiServiceMutation) ResetXunjiID() {
  52652. m.xunji_id = nil
  52653. m.addxunji_id = nil
  52654. }
  52655. // SetAgentID sets the "agent_id" field.
  52656. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52657. m.agent = &u
  52658. }
  52659. // AgentID returns the value of the "agent_id" field in the mutation.
  52660. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52661. v := m.agent
  52662. if v == nil {
  52663. return
  52664. }
  52665. return *v, true
  52666. }
  52667. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52668. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52670. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52671. if !m.op.Is(OpUpdateOne) {
  52672. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52673. }
  52674. if m.id == nil || m.oldValue == nil {
  52675. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52676. }
  52677. oldValue, err := m.oldValue(ctx)
  52678. if err != nil {
  52679. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52680. }
  52681. return oldValue.AgentID, nil
  52682. }
  52683. // ResetAgentID resets all changes to the "agent_id" field.
  52684. func (m *XunjiServiceMutation) ResetAgentID() {
  52685. m.agent = nil
  52686. }
  52687. // SetOrganizationID sets the "organization_id" field.
  52688. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52689. m.organization_id = &u
  52690. m.addorganization_id = nil
  52691. }
  52692. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52693. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52694. v := m.organization_id
  52695. if v == nil {
  52696. return
  52697. }
  52698. return *v, true
  52699. }
  52700. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52701. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52703. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52704. if !m.op.Is(OpUpdateOne) {
  52705. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52706. }
  52707. if m.id == nil || m.oldValue == nil {
  52708. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52709. }
  52710. oldValue, err := m.oldValue(ctx)
  52711. if err != nil {
  52712. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52713. }
  52714. return oldValue.OrganizationID, nil
  52715. }
  52716. // AddOrganizationID adds u to the "organization_id" field.
  52717. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52718. if m.addorganization_id != nil {
  52719. *m.addorganization_id += u
  52720. } else {
  52721. m.addorganization_id = &u
  52722. }
  52723. }
  52724. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52725. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52726. v := m.addorganization_id
  52727. if v == nil {
  52728. return
  52729. }
  52730. return *v, true
  52731. }
  52732. // ResetOrganizationID resets all changes to the "organization_id" field.
  52733. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52734. m.organization_id = nil
  52735. m.addorganization_id = nil
  52736. }
  52737. // SetWxid sets the "wxid" field.
  52738. func (m *XunjiServiceMutation) SetWxid(s string) {
  52739. m.wxid = &s
  52740. }
  52741. // Wxid returns the value of the "wxid" field in the mutation.
  52742. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52743. v := m.wxid
  52744. if v == nil {
  52745. return
  52746. }
  52747. return *v, true
  52748. }
  52749. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  52750. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52752. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  52753. if !m.op.Is(OpUpdateOne) {
  52754. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52755. }
  52756. if m.id == nil || m.oldValue == nil {
  52757. return v, errors.New("OldWxid requires an ID field in the mutation")
  52758. }
  52759. oldValue, err := m.oldValue(ctx)
  52760. if err != nil {
  52761. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  52762. }
  52763. return oldValue.Wxid, nil
  52764. }
  52765. // ResetWxid resets all changes to the "wxid" field.
  52766. func (m *XunjiServiceMutation) ResetWxid() {
  52767. m.wxid = nil
  52768. }
  52769. // SetAPIBase sets the "api_base" field.
  52770. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  52771. m.api_base = &s
  52772. }
  52773. // APIBase returns the value of the "api_base" field in the mutation.
  52774. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  52775. v := m.api_base
  52776. if v == nil {
  52777. return
  52778. }
  52779. return *v, true
  52780. }
  52781. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  52782. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52784. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  52785. if !m.op.Is(OpUpdateOne) {
  52786. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  52787. }
  52788. if m.id == nil || m.oldValue == nil {
  52789. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  52790. }
  52791. oldValue, err := m.oldValue(ctx)
  52792. if err != nil {
  52793. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  52794. }
  52795. return oldValue.APIBase, nil
  52796. }
  52797. // ClearAPIBase clears the value of the "api_base" field.
  52798. func (m *XunjiServiceMutation) ClearAPIBase() {
  52799. m.api_base = nil
  52800. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  52801. }
  52802. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  52803. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  52804. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  52805. return ok
  52806. }
  52807. // ResetAPIBase resets all changes to the "api_base" field.
  52808. func (m *XunjiServiceMutation) ResetAPIBase() {
  52809. m.api_base = nil
  52810. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  52811. }
  52812. // SetAPIKey sets the "api_key" field.
  52813. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  52814. m.api_key = &s
  52815. }
  52816. // APIKey returns the value of the "api_key" field in the mutation.
  52817. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  52818. v := m.api_key
  52819. if v == nil {
  52820. return
  52821. }
  52822. return *v, true
  52823. }
  52824. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  52825. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52827. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  52828. if !m.op.Is(OpUpdateOne) {
  52829. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  52830. }
  52831. if m.id == nil || m.oldValue == nil {
  52832. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  52833. }
  52834. oldValue, err := m.oldValue(ctx)
  52835. if err != nil {
  52836. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  52837. }
  52838. return oldValue.APIKey, nil
  52839. }
  52840. // ClearAPIKey clears the value of the "api_key" field.
  52841. func (m *XunjiServiceMutation) ClearAPIKey() {
  52842. m.api_key = nil
  52843. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  52844. }
  52845. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  52846. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  52847. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  52848. return ok
  52849. }
  52850. // ResetAPIKey resets all changes to the "api_key" field.
  52851. func (m *XunjiServiceMutation) ResetAPIKey() {
  52852. m.api_key = nil
  52853. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  52854. }
  52855. // ClearAgent clears the "agent" edge to the Agent entity.
  52856. func (m *XunjiServiceMutation) ClearAgent() {
  52857. m.clearedagent = true
  52858. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  52859. }
  52860. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  52861. func (m *XunjiServiceMutation) AgentCleared() bool {
  52862. return m.clearedagent
  52863. }
  52864. // AgentIDs returns the "agent" edge IDs in the mutation.
  52865. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52866. // AgentID instead. It exists only for internal usage by the builders.
  52867. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  52868. if id := m.agent; id != nil {
  52869. ids = append(ids, *id)
  52870. }
  52871. return
  52872. }
  52873. // ResetAgent resets all changes to the "agent" edge.
  52874. func (m *XunjiServiceMutation) ResetAgent() {
  52875. m.agent = nil
  52876. m.clearedagent = false
  52877. }
  52878. // Where appends a list predicates to the XunjiServiceMutation builder.
  52879. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  52880. m.predicates = append(m.predicates, ps...)
  52881. }
  52882. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  52883. // users can use type-assertion to append predicates that do not depend on any generated package.
  52884. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  52885. p := make([]predicate.XunjiService, len(ps))
  52886. for i := range ps {
  52887. p[i] = ps[i]
  52888. }
  52889. m.Where(p...)
  52890. }
  52891. // Op returns the operation name.
  52892. func (m *XunjiServiceMutation) Op() Op {
  52893. return m.op
  52894. }
  52895. // SetOp allows setting the mutation operation.
  52896. func (m *XunjiServiceMutation) SetOp(op Op) {
  52897. m.op = op
  52898. }
  52899. // Type returns the node type of this mutation (XunjiService).
  52900. func (m *XunjiServiceMutation) Type() string {
  52901. return m.typ
  52902. }
  52903. // Fields returns all fields that were changed during this mutation. Note that in
  52904. // order to get all numeric fields that were incremented/decremented, call
  52905. // AddedFields().
  52906. func (m *XunjiServiceMutation) Fields() []string {
  52907. fields := make([]string, 0, 10)
  52908. if m.created_at != nil {
  52909. fields = append(fields, xunjiservice.FieldCreatedAt)
  52910. }
  52911. if m.updated_at != nil {
  52912. fields = append(fields, xunjiservice.FieldUpdatedAt)
  52913. }
  52914. if m.status != nil {
  52915. fields = append(fields, xunjiservice.FieldStatus)
  52916. }
  52917. if m.deleted_at != nil {
  52918. fields = append(fields, xunjiservice.FieldDeletedAt)
  52919. }
  52920. if m.xunji_id != nil {
  52921. fields = append(fields, xunjiservice.FieldXunjiID)
  52922. }
  52923. if m.agent != nil {
  52924. fields = append(fields, xunjiservice.FieldAgentID)
  52925. }
  52926. if m.organization_id != nil {
  52927. fields = append(fields, xunjiservice.FieldOrganizationID)
  52928. }
  52929. if m.wxid != nil {
  52930. fields = append(fields, xunjiservice.FieldWxid)
  52931. }
  52932. if m.api_base != nil {
  52933. fields = append(fields, xunjiservice.FieldAPIBase)
  52934. }
  52935. if m.api_key != nil {
  52936. fields = append(fields, xunjiservice.FieldAPIKey)
  52937. }
  52938. return fields
  52939. }
  52940. // Field returns the value of a field with the given name. The second boolean
  52941. // return value indicates that this field was not set, or was not defined in the
  52942. // schema.
  52943. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  52944. switch name {
  52945. case xunjiservice.FieldCreatedAt:
  52946. return m.CreatedAt()
  52947. case xunjiservice.FieldUpdatedAt:
  52948. return m.UpdatedAt()
  52949. case xunjiservice.FieldStatus:
  52950. return m.Status()
  52951. case xunjiservice.FieldDeletedAt:
  52952. return m.DeletedAt()
  52953. case xunjiservice.FieldXunjiID:
  52954. return m.XunjiID()
  52955. case xunjiservice.FieldAgentID:
  52956. return m.AgentID()
  52957. case xunjiservice.FieldOrganizationID:
  52958. return m.OrganizationID()
  52959. case xunjiservice.FieldWxid:
  52960. return m.Wxid()
  52961. case xunjiservice.FieldAPIBase:
  52962. return m.APIBase()
  52963. case xunjiservice.FieldAPIKey:
  52964. return m.APIKey()
  52965. }
  52966. return nil, false
  52967. }
  52968. // OldField returns the old value of the field from the database. An error is
  52969. // returned if the mutation operation is not UpdateOne, or the query to the
  52970. // database failed.
  52971. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52972. switch name {
  52973. case xunjiservice.FieldCreatedAt:
  52974. return m.OldCreatedAt(ctx)
  52975. case xunjiservice.FieldUpdatedAt:
  52976. return m.OldUpdatedAt(ctx)
  52977. case xunjiservice.FieldStatus:
  52978. return m.OldStatus(ctx)
  52979. case xunjiservice.FieldDeletedAt:
  52980. return m.OldDeletedAt(ctx)
  52981. case xunjiservice.FieldXunjiID:
  52982. return m.OldXunjiID(ctx)
  52983. case xunjiservice.FieldAgentID:
  52984. return m.OldAgentID(ctx)
  52985. case xunjiservice.FieldOrganizationID:
  52986. return m.OldOrganizationID(ctx)
  52987. case xunjiservice.FieldWxid:
  52988. return m.OldWxid(ctx)
  52989. case xunjiservice.FieldAPIBase:
  52990. return m.OldAPIBase(ctx)
  52991. case xunjiservice.FieldAPIKey:
  52992. return m.OldAPIKey(ctx)
  52993. }
  52994. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  52995. }
  52996. // SetField sets the value of a field with the given name. It returns an error if
  52997. // the field is not defined in the schema, or if the type mismatched the field
  52998. // type.
  52999. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  53000. switch name {
  53001. case xunjiservice.FieldCreatedAt:
  53002. v, ok := value.(time.Time)
  53003. if !ok {
  53004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53005. }
  53006. m.SetCreatedAt(v)
  53007. return nil
  53008. case xunjiservice.FieldUpdatedAt:
  53009. v, ok := value.(time.Time)
  53010. if !ok {
  53011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53012. }
  53013. m.SetUpdatedAt(v)
  53014. return nil
  53015. case xunjiservice.FieldStatus:
  53016. v, ok := value.(uint8)
  53017. if !ok {
  53018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53019. }
  53020. m.SetStatus(v)
  53021. return nil
  53022. case xunjiservice.FieldDeletedAt:
  53023. v, ok := value.(time.Time)
  53024. if !ok {
  53025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53026. }
  53027. m.SetDeletedAt(v)
  53028. return nil
  53029. case xunjiservice.FieldXunjiID:
  53030. v, ok := value.(uint64)
  53031. if !ok {
  53032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53033. }
  53034. m.SetXunjiID(v)
  53035. return nil
  53036. case xunjiservice.FieldAgentID:
  53037. v, ok := value.(uint64)
  53038. if !ok {
  53039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53040. }
  53041. m.SetAgentID(v)
  53042. return nil
  53043. case xunjiservice.FieldOrganizationID:
  53044. v, ok := value.(uint64)
  53045. if !ok {
  53046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53047. }
  53048. m.SetOrganizationID(v)
  53049. return nil
  53050. case xunjiservice.FieldWxid:
  53051. v, ok := value.(string)
  53052. if !ok {
  53053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53054. }
  53055. m.SetWxid(v)
  53056. return nil
  53057. case xunjiservice.FieldAPIBase:
  53058. v, ok := value.(string)
  53059. if !ok {
  53060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53061. }
  53062. m.SetAPIBase(v)
  53063. return nil
  53064. case xunjiservice.FieldAPIKey:
  53065. v, ok := value.(string)
  53066. if !ok {
  53067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53068. }
  53069. m.SetAPIKey(v)
  53070. return nil
  53071. }
  53072. return fmt.Errorf("unknown XunjiService field %s", name)
  53073. }
  53074. // AddedFields returns all numeric fields that were incremented/decremented during
  53075. // this mutation.
  53076. func (m *XunjiServiceMutation) AddedFields() []string {
  53077. var fields []string
  53078. if m.addstatus != nil {
  53079. fields = append(fields, xunjiservice.FieldStatus)
  53080. }
  53081. if m.addxunji_id != nil {
  53082. fields = append(fields, xunjiservice.FieldXunjiID)
  53083. }
  53084. if m.addorganization_id != nil {
  53085. fields = append(fields, xunjiservice.FieldOrganizationID)
  53086. }
  53087. return fields
  53088. }
  53089. // AddedField returns the numeric value that was incremented/decremented on a field
  53090. // with the given name. The second boolean return value indicates that this field
  53091. // was not set, or was not defined in the schema.
  53092. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  53093. switch name {
  53094. case xunjiservice.FieldStatus:
  53095. return m.AddedStatus()
  53096. case xunjiservice.FieldXunjiID:
  53097. return m.AddedXunjiID()
  53098. case xunjiservice.FieldOrganizationID:
  53099. return m.AddedOrganizationID()
  53100. }
  53101. return nil, false
  53102. }
  53103. // AddField adds the value to the field with the given name. It returns an error if
  53104. // the field is not defined in the schema, or if the type mismatched the field
  53105. // type.
  53106. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  53107. switch name {
  53108. case xunjiservice.FieldStatus:
  53109. v, ok := value.(int8)
  53110. if !ok {
  53111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53112. }
  53113. m.AddStatus(v)
  53114. return nil
  53115. case xunjiservice.FieldXunjiID:
  53116. v, ok := value.(int64)
  53117. if !ok {
  53118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53119. }
  53120. m.AddXunjiID(v)
  53121. return nil
  53122. case xunjiservice.FieldOrganizationID:
  53123. v, ok := value.(int64)
  53124. if !ok {
  53125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53126. }
  53127. m.AddOrganizationID(v)
  53128. return nil
  53129. }
  53130. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53131. }
  53132. // ClearedFields returns all nullable fields that were cleared during this
  53133. // mutation.
  53134. func (m *XunjiServiceMutation) ClearedFields() []string {
  53135. var fields []string
  53136. if m.FieldCleared(xunjiservice.FieldStatus) {
  53137. fields = append(fields, xunjiservice.FieldStatus)
  53138. }
  53139. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53140. fields = append(fields, xunjiservice.FieldDeletedAt)
  53141. }
  53142. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53143. fields = append(fields, xunjiservice.FieldAPIBase)
  53144. }
  53145. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53146. fields = append(fields, xunjiservice.FieldAPIKey)
  53147. }
  53148. return fields
  53149. }
  53150. // FieldCleared returns a boolean indicating if a field with the given name was
  53151. // cleared in this mutation.
  53152. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53153. _, ok := m.clearedFields[name]
  53154. return ok
  53155. }
  53156. // ClearField clears the value of the field with the given name. It returns an
  53157. // error if the field is not defined in the schema.
  53158. func (m *XunjiServiceMutation) ClearField(name string) error {
  53159. switch name {
  53160. case xunjiservice.FieldStatus:
  53161. m.ClearStatus()
  53162. return nil
  53163. case xunjiservice.FieldDeletedAt:
  53164. m.ClearDeletedAt()
  53165. return nil
  53166. case xunjiservice.FieldAPIBase:
  53167. m.ClearAPIBase()
  53168. return nil
  53169. case xunjiservice.FieldAPIKey:
  53170. m.ClearAPIKey()
  53171. return nil
  53172. }
  53173. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53174. }
  53175. // ResetField resets all changes in the mutation for the field with the given name.
  53176. // It returns an error if the field is not defined in the schema.
  53177. func (m *XunjiServiceMutation) ResetField(name string) error {
  53178. switch name {
  53179. case xunjiservice.FieldCreatedAt:
  53180. m.ResetCreatedAt()
  53181. return nil
  53182. case xunjiservice.FieldUpdatedAt:
  53183. m.ResetUpdatedAt()
  53184. return nil
  53185. case xunjiservice.FieldStatus:
  53186. m.ResetStatus()
  53187. return nil
  53188. case xunjiservice.FieldDeletedAt:
  53189. m.ResetDeletedAt()
  53190. return nil
  53191. case xunjiservice.FieldXunjiID:
  53192. m.ResetXunjiID()
  53193. return nil
  53194. case xunjiservice.FieldAgentID:
  53195. m.ResetAgentID()
  53196. return nil
  53197. case xunjiservice.FieldOrganizationID:
  53198. m.ResetOrganizationID()
  53199. return nil
  53200. case xunjiservice.FieldWxid:
  53201. m.ResetWxid()
  53202. return nil
  53203. case xunjiservice.FieldAPIBase:
  53204. m.ResetAPIBase()
  53205. return nil
  53206. case xunjiservice.FieldAPIKey:
  53207. m.ResetAPIKey()
  53208. return nil
  53209. }
  53210. return fmt.Errorf("unknown XunjiService field %s", name)
  53211. }
  53212. // AddedEdges returns all edge names that were set/added in this mutation.
  53213. func (m *XunjiServiceMutation) AddedEdges() []string {
  53214. edges := make([]string, 0, 1)
  53215. if m.agent != nil {
  53216. edges = append(edges, xunjiservice.EdgeAgent)
  53217. }
  53218. return edges
  53219. }
  53220. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53221. // name in this mutation.
  53222. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53223. switch name {
  53224. case xunjiservice.EdgeAgent:
  53225. if id := m.agent; id != nil {
  53226. return []ent.Value{*id}
  53227. }
  53228. }
  53229. return nil
  53230. }
  53231. // RemovedEdges returns all edge names that were removed in this mutation.
  53232. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53233. edges := make([]string, 0, 1)
  53234. return edges
  53235. }
  53236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53237. // the given name in this mutation.
  53238. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53239. return nil
  53240. }
  53241. // ClearedEdges returns all edge names that were cleared in this mutation.
  53242. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53243. edges := make([]string, 0, 1)
  53244. if m.clearedagent {
  53245. edges = append(edges, xunjiservice.EdgeAgent)
  53246. }
  53247. return edges
  53248. }
  53249. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53250. // was cleared in this mutation.
  53251. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53252. switch name {
  53253. case xunjiservice.EdgeAgent:
  53254. return m.clearedagent
  53255. }
  53256. return false
  53257. }
  53258. // ClearEdge clears the value of the edge with the given name. It returns an error
  53259. // if that edge is not defined in the schema.
  53260. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53261. switch name {
  53262. case xunjiservice.EdgeAgent:
  53263. m.ClearAgent()
  53264. return nil
  53265. }
  53266. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53267. }
  53268. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53269. // It returns an error if the edge is not defined in the schema.
  53270. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53271. switch name {
  53272. case xunjiservice.EdgeAgent:
  53273. m.ResetAgent()
  53274. return nil
  53275. }
  53276. return fmt.Errorf("unknown XunjiService edge %s", name)
  53277. }