mutation.go 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219
  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. find_request *map[string]interface{}
  130. find_result *map[string]interface{}
  131. is_can_add *int
  132. addis_can_add *int
  133. task_id *int64
  134. addtask_id *int64
  135. add_request *map[string]interface{}
  136. add_result *map[string]interface{}
  137. created_at *int64
  138. addcreated_at *int64
  139. updated_at *int64
  140. addupdated_at *int64
  141. clearedFields map[string]struct{}
  142. done bool
  143. oldValue func(context.Context) (*AddWechatFriendLog, error)
  144. predicates []predicate.AddWechatFriendLog
  145. }
  146. var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
  147. // addwechatfriendlogOption allows management of the mutation configuration using functional options.
  148. type addwechatfriendlogOption func(*AddWechatFriendLogMutation)
  149. // newAddWechatFriendLogMutation creates new mutation for the AddWechatFriendLog entity.
  150. func newAddWechatFriendLogMutation(c config, op Op, opts ...addwechatfriendlogOption) *AddWechatFriendLogMutation {
  151. m := &AddWechatFriendLogMutation{
  152. config: c,
  153. op: op,
  154. typ: TypeAddWechatFriendLog,
  155. clearedFields: make(map[string]struct{}),
  156. }
  157. for _, opt := range opts {
  158. opt(m)
  159. }
  160. return m
  161. }
  162. // withAddWechatFriendLogID sets the ID field of the mutation.
  163. func withAddWechatFriendLogID(id int64) addwechatfriendlogOption {
  164. return func(m *AddWechatFriendLogMutation) {
  165. var (
  166. err error
  167. once sync.Once
  168. value *AddWechatFriendLog
  169. )
  170. m.oldValue = func(ctx context.Context) (*AddWechatFriendLog, error) {
  171. once.Do(func() {
  172. if m.done {
  173. err = errors.New("querying old values post mutation is not allowed")
  174. } else {
  175. value, err = m.Client().AddWechatFriendLog.Get(ctx, id)
  176. }
  177. })
  178. return value, err
  179. }
  180. m.id = &id
  181. }
  182. }
  183. // withAddWechatFriendLog sets the old AddWechatFriendLog of the mutation.
  184. func withAddWechatFriendLog(node *AddWechatFriendLog) addwechatfriendlogOption {
  185. return func(m *AddWechatFriendLogMutation) {
  186. m.oldValue = func(context.Context) (*AddWechatFriendLog, error) {
  187. return node, nil
  188. }
  189. m.id = &node.ID
  190. }
  191. }
  192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  193. // executed in a transaction (ent.Tx), a transactional client is returned.
  194. func (m AddWechatFriendLogMutation) Client() *Client {
  195. client := &Client{config: m.config}
  196. client.init()
  197. return client
  198. }
  199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  200. // it returns an error otherwise.
  201. func (m AddWechatFriendLogMutation) Tx() (*Tx, error) {
  202. if _, ok := m.driver.(*txDriver); !ok {
  203. return nil, errors.New("ent: mutation is not running in a transaction")
  204. }
  205. tx := &Tx{config: m.config}
  206. tx.init()
  207. return tx, nil
  208. }
  209. // SetID sets the value of the id field. Note that this
  210. // operation is only accepted on creation of AddWechatFriendLog entities.
  211. func (m *AddWechatFriendLogMutation) SetID(id int64) {
  212. m.id = &id
  213. }
  214. // ID returns the ID value in the mutation. Note that the ID is only available
  215. // if it was provided to the builder or after it was returned from the database.
  216. func (m *AddWechatFriendLogMutation) ID() (id int64, exists bool) {
  217. if m.id == nil {
  218. return
  219. }
  220. return *m.id, true
  221. }
  222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  223. // That means, if the mutation is applied within a transaction with an isolation level such
  224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  225. // or updated by the mutation.
  226. func (m *AddWechatFriendLogMutation) IDs(ctx context.Context) ([]int64, error) {
  227. switch {
  228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  229. id, exists := m.ID()
  230. if exists {
  231. return []int64{id}, nil
  232. }
  233. fallthrough
  234. case m.op.Is(OpUpdate | OpDelete):
  235. return m.Client().AddWechatFriendLog.Query().Where(m.predicates...).IDs(ctx)
  236. default:
  237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  238. }
  239. }
  240. // SetOwnerWxID sets the "owner_wx_id" field.
  241. func (m *AddWechatFriendLogMutation) SetOwnerWxID(s string) {
  242. m.owner_wx_id = &s
  243. }
  244. // OwnerWxID returns the value of the "owner_wx_id" field in the mutation.
  245. func (m *AddWechatFriendLogMutation) OwnerWxID() (r string, exists bool) {
  246. v := m.owner_wx_id
  247. if v == nil {
  248. return
  249. }
  250. return *v, true
  251. }
  252. // OldOwnerWxID returns the old "owner_wx_id" field's value of the AddWechatFriendLog entity.
  253. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  255. func (m *AddWechatFriendLogMutation) OldOwnerWxID(ctx context.Context) (v string, err error) {
  256. if !m.op.Is(OpUpdateOne) {
  257. return v, errors.New("OldOwnerWxID is only allowed on UpdateOne operations")
  258. }
  259. if m.id == nil || m.oldValue == nil {
  260. return v, errors.New("OldOwnerWxID requires an ID field in the mutation")
  261. }
  262. oldValue, err := m.oldValue(ctx)
  263. if err != nil {
  264. return v, fmt.Errorf("querying old value for OldOwnerWxID: %w", err)
  265. }
  266. return oldValue.OwnerWxID, nil
  267. }
  268. // ResetOwnerWxID resets all changes to the "owner_wx_id" field.
  269. func (m *AddWechatFriendLogMutation) ResetOwnerWxID() {
  270. m.owner_wx_id = nil
  271. }
  272. // SetOwnerWxType sets the "owner_wx_type" field.
  273. func (m *AddWechatFriendLogMutation) SetOwnerWxType(i int) {
  274. m.owner_wx_type = &i
  275. m.addowner_wx_type = nil
  276. }
  277. // OwnerWxType returns the value of the "owner_wx_type" field in the mutation.
  278. func (m *AddWechatFriendLogMutation) OwnerWxType() (r int, exists bool) {
  279. v := m.owner_wx_type
  280. if v == nil {
  281. return
  282. }
  283. return *v, true
  284. }
  285. // OldOwnerWxType returns the old "owner_wx_type" field's value of the AddWechatFriendLog entity.
  286. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  288. func (m *AddWechatFriendLogMutation) OldOwnerWxType(ctx context.Context) (v int, err error) {
  289. if !m.op.Is(OpUpdateOne) {
  290. return v, errors.New("OldOwnerWxType is only allowed on UpdateOne operations")
  291. }
  292. if m.id == nil || m.oldValue == nil {
  293. return v, errors.New("OldOwnerWxType requires an ID field in the mutation")
  294. }
  295. oldValue, err := m.oldValue(ctx)
  296. if err != nil {
  297. return v, fmt.Errorf("querying old value for OldOwnerWxType: %w", err)
  298. }
  299. return oldValue.OwnerWxType, nil
  300. }
  301. // AddOwnerWxType adds i to the "owner_wx_type" field.
  302. func (m *AddWechatFriendLogMutation) AddOwnerWxType(i int) {
  303. if m.addowner_wx_type != nil {
  304. *m.addowner_wx_type += i
  305. } else {
  306. m.addowner_wx_type = &i
  307. }
  308. }
  309. // AddedOwnerWxType returns the value that was added to the "owner_wx_type" field in this mutation.
  310. func (m *AddWechatFriendLogMutation) AddedOwnerWxType() (r int, exists bool) {
  311. v := m.addowner_wx_type
  312. if v == nil {
  313. return
  314. }
  315. return *v, true
  316. }
  317. // ResetOwnerWxType resets all changes to the "owner_wx_type" field.
  318. func (m *AddWechatFriendLogMutation) ResetOwnerWxType() {
  319. m.owner_wx_type = nil
  320. m.addowner_wx_type = nil
  321. }
  322. // SetFindContent sets the "find_content" field.
  323. func (m *AddWechatFriendLogMutation) SetFindContent(s string) {
  324. m.find_content = &s
  325. }
  326. // FindContent returns the value of the "find_content" field in the mutation.
  327. func (m *AddWechatFriendLogMutation) FindContent() (r string, exists bool) {
  328. v := m.find_content
  329. if v == nil {
  330. return
  331. }
  332. return *v, true
  333. }
  334. // OldFindContent returns the old "find_content" field's value of the AddWechatFriendLog entity.
  335. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  337. func (m *AddWechatFriendLogMutation) OldFindContent(ctx context.Context) (v string, err error) {
  338. if !m.op.Is(OpUpdateOne) {
  339. return v, errors.New("OldFindContent is only allowed on UpdateOne operations")
  340. }
  341. if m.id == nil || m.oldValue == nil {
  342. return v, errors.New("OldFindContent requires an ID field in the mutation")
  343. }
  344. oldValue, err := m.oldValue(ctx)
  345. if err != nil {
  346. return v, fmt.Errorf("querying old value for OldFindContent: %w", err)
  347. }
  348. return oldValue.FindContent, nil
  349. }
  350. // ResetFindContent resets all changes to the "find_content" field.
  351. func (m *AddWechatFriendLogMutation) ResetFindContent() {
  352. m.find_content = nil
  353. }
  354. // SetFindRequest sets the "find_request" field.
  355. func (m *AddWechatFriendLogMutation) SetFindRequest(value map[string]interface{}) {
  356. m.find_request = &value
  357. }
  358. // FindRequest returns the value of the "find_request" field in the mutation.
  359. func (m *AddWechatFriendLogMutation) FindRequest() (r map[string]interface{}, exists bool) {
  360. v := m.find_request
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldFindRequest returns the old "find_request" field's value of the AddWechatFriendLog entity.
  367. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AddWechatFriendLogMutation) OldFindRequest(ctx context.Context) (v map[string]interface{}, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldFindRequest is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldFindRequest requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldFindRequest: %w", err)
  379. }
  380. return oldValue.FindRequest, nil
  381. }
  382. // ClearFindRequest clears the value of the "find_request" field.
  383. func (m *AddWechatFriendLogMutation) ClearFindRequest() {
  384. m.find_request = nil
  385. m.clearedFields[addwechatfriendlog.FieldFindRequest] = struct{}{}
  386. }
  387. // FindRequestCleared returns if the "find_request" field was cleared in this mutation.
  388. func (m *AddWechatFriendLogMutation) FindRequestCleared() bool {
  389. _, ok := m.clearedFields[addwechatfriendlog.FieldFindRequest]
  390. return ok
  391. }
  392. // ResetFindRequest resets all changes to the "find_request" field.
  393. func (m *AddWechatFriendLogMutation) ResetFindRequest() {
  394. m.find_request = nil
  395. delete(m.clearedFields, addwechatfriendlog.FieldFindRequest)
  396. }
  397. // SetFindResult sets the "find_result" field.
  398. func (m *AddWechatFriendLogMutation) SetFindResult(value map[string]interface{}) {
  399. m.find_result = &value
  400. }
  401. // FindResult returns the value of the "find_result" field in the mutation.
  402. func (m *AddWechatFriendLogMutation) FindResult() (r map[string]interface{}, exists bool) {
  403. v := m.find_result
  404. if v == nil {
  405. return
  406. }
  407. return *v, true
  408. }
  409. // OldFindResult returns the old "find_result" field's value of the AddWechatFriendLog entity.
  410. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  412. func (m *AddWechatFriendLogMutation) OldFindResult(ctx context.Context) (v map[string]interface{}, err error) {
  413. if !m.op.Is(OpUpdateOne) {
  414. return v, errors.New("OldFindResult is only allowed on UpdateOne operations")
  415. }
  416. if m.id == nil || m.oldValue == nil {
  417. return v, errors.New("OldFindResult requires an ID field in the mutation")
  418. }
  419. oldValue, err := m.oldValue(ctx)
  420. if err != nil {
  421. return v, fmt.Errorf("querying old value for OldFindResult: %w", err)
  422. }
  423. return oldValue.FindResult, nil
  424. }
  425. // ClearFindResult clears the value of the "find_result" field.
  426. func (m *AddWechatFriendLogMutation) ClearFindResult() {
  427. m.find_result = nil
  428. m.clearedFields[addwechatfriendlog.FieldFindResult] = struct{}{}
  429. }
  430. // FindResultCleared returns if the "find_result" field was cleared in this mutation.
  431. func (m *AddWechatFriendLogMutation) FindResultCleared() bool {
  432. _, ok := m.clearedFields[addwechatfriendlog.FieldFindResult]
  433. return ok
  434. }
  435. // ResetFindResult resets all changes to the "find_result" field.
  436. func (m *AddWechatFriendLogMutation) ResetFindResult() {
  437. m.find_result = nil
  438. delete(m.clearedFields, addwechatfriendlog.FieldFindResult)
  439. }
  440. // SetIsCanAdd sets the "is_can_add" field.
  441. func (m *AddWechatFriendLogMutation) SetIsCanAdd(i int) {
  442. m.is_can_add = &i
  443. m.addis_can_add = nil
  444. }
  445. // IsCanAdd returns the value of the "is_can_add" field in the mutation.
  446. func (m *AddWechatFriendLogMutation) IsCanAdd() (r int, exists bool) {
  447. v := m.is_can_add
  448. if v == nil {
  449. return
  450. }
  451. return *v, true
  452. }
  453. // OldIsCanAdd returns the old "is_can_add" field's value of the AddWechatFriendLog entity.
  454. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  456. func (m *AddWechatFriendLogMutation) OldIsCanAdd(ctx context.Context) (v int, err error) {
  457. if !m.op.Is(OpUpdateOne) {
  458. return v, errors.New("OldIsCanAdd is only allowed on UpdateOne operations")
  459. }
  460. if m.id == nil || m.oldValue == nil {
  461. return v, errors.New("OldIsCanAdd requires an ID field in the mutation")
  462. }
  463. oldValue, err := m.oldValue(ctx)
  464. if err != nil {
  465. return v, fmt.Errorf("querying old value for OldIsCanAdd: %w", err)
  466. }
  467. return oldValue.IsCanAdd, nil
  468. }
  469. // AddIsCanAdd adds i to the "is_can_add" field.
  470. func (m *AddWechatFriendLogMutation) AddIsCanAdd(i int) {
  471. if m.addis_can_add != nil {
  472. *m.addis_can_add += i
  473. } else {
  474. m.addis_can_add = &i
  475. }
  476. }
  477. // AddedIsCanAdd returns the value that was added to the "is_can_add" field in this mutation.
  478. func (m *AddWechatFriendLogMutation) AddedIsCanAdd() (r int, exists bool) {
  479. v := m.addis_can_add
  480. if v == nil {
  481. return
  482. }
  483. return *v, true
  484. }
  485. // ResetIsCanAdd resets all changes to the "is_can_add" field.
  486. func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
  487. m.is_can_add = nil
  488. m.addis_can_add = nil
  489. }
  490. // SetTaskID sets the "task_id" field.
  491. func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
  492. m.task_id = &i
  493. m.addtask_id = nil
  494. }
  495. // TaskID returns the value of the "task_id" field in the mutation.
  496. func (m *AddWechatFriendLogMutation) TaskID() (r int64, exists bool) {
  497. v := m.task_id
  498. if v == nil {
  499. return
  500. }
  501. return *v, true
  502. }
  503. // OldTaskID returns the old "task_id" field's value of the AddWechatFriendLog entity.
  504. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  506. func (m *AddWechatFriendLogMutation) OldTaskID(ctx context.Context) (v int64, err error) {
  507. if !m.op.Is(OpUpdateOne) {
  508. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  509. }
  510. if m.id == nil || m.oldValue == nil {
  511. return v, errors.New("OldTaskID requires an ID field in the mutation")
  512. }
  513. oldValue, err := m.oldValue(ctx)
  514. if err != nil {
  515. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  516. }
  517. return oldValue.TaskID, nil
  518. }
  519. // AddTaskID adds i to the "task_id" field.
  520. func (m *AddWechatFriendLogMutation) AddTaskID(i int64) {
  521. if m.addtask_id != nil {
  522. *m.addtask_id += i
  523. } else {
  524. m.addtask_id = &i
  525. }
  526. }
  527. // AddedTaskID returns the value that was added to the "task_id" field in this mutation.
  528. func (m *AddWechatFriendLogMutation) AddedTaskID() (r int64, exists bool) {
  529. v := m.addtask_id
  530. if v == nil {
  531. return
  532. }
  533. return *v, true
  534. }
  535. // ResetTaskID resets all changes to the "task_id" field.
  536. func (m *AddWechatFriendLogMutation) ResetTaskID() {
  537. m.task_id = nil
  538. m.addtask_id = nil
  539. }
  540. // SetAddRequest sets the "add_request" field.
  541. func (m *AddWechatFriendLogMutation) SetAddRequest(value map[string]interface{}) {
  542. m.add_request = &value
  543. }
  544. // AddRequest returns the value of the "add_request" field in the mutation.
  545. func (m *AddWechatFriendLogMutation) AddRequest() (r map[string]interface{}, exists bool) {
  546. v := m.add_request
  547. if v == nil {
  548. return
  549. }
  550. return *v, true
  551. }
  552. // OldAddRequest returns the old "add_request" field's value of the AddWechatFriendLog entity.
  553. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  555. func (m *AddWechatFriendLogMutation) OldAddRequest(ctx context.Context) (v map[string]interface{}, err error) {
  556. if !m.op.Is(OpUpdateOne) {
  557. return v, errors.New("OldAddRequest is only allowed on UpdateOne operations")
  558. }
  559. if m.id == nil || m.oldValue == nil {
  560. return v, errors.New("OldAddRequest requires an ID field in the mutation")
  561. }
  562. oldValue, err := m.oldValue(ctx)
  563. if err != nil {
  564. return v, fmt.Errorf("querying old value for OldAddRequest: %w", err)
  565. }
  566. return oldValue.AddRequest, nil
  567. }
  568. // ClearAddRequest clears the value of the "add_request" field.
  569. func (m *AddWechatFriendLogMutation) ClearAddRequest() {
  570. m.add_request = nil
  571. m.clearedFields[addwechatfriendlog.FieldAddRequest] = struct{}{}
  572. }
  573. // AddRequestCleared returns if the "add_request" field was cleared in this mutation.
  574. func (m *AddWechatFriendLogMutation) AddRequestCleared() bool {
  575. _, ok := m.clearedFields[addwechatfriendlog.FieldAddRequest]
  576. return ok
  577. }
  578. // ResetAddRequest resets all changes to the "add_request" field.
  579. func (m *AddWechatFriendLogMutation) ResetAddRequest() {
  580. m.add_request = nil
  581. delete(m.clearedFields, addwechatfriendlog.FieldAddRequest)
  582. }
  583. // SetAddResult sets the "add_result" field.
  584. func (m *AddWechatFriendLogMutation) SetAddResult(value map[string]interface{}) {
  585. m.add_result = &value
  586. }
  587. // AddResult returns the value of the "add_result" field in the mutation.
  588. func (m *AddWechatFriendLogMutation) AddResult() (r map[string]interface{}, exists bool) {
  589. v := m.add_result
  590. if v == nil {
  591. return
  592. }
  593. return *v, true
  594. }
  595. // OldAddResult returns the old "add_result" field's value of the AddWechatFriendLog entity.
  596. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  598. func (m *AddWechatFriendLogMutation) OldAddResult(ctx context.Context) (v map[string]interface{}, err error) {
  599. if !m.op.Is(OpUpdateOne) {
  600. return v, errors.New("OldAddResult is only allowed on UpdateOne operations")
  601. }
  602. if m.id == nil || m.oldValue == nil {
  603. return v, errors.New("OldAddResult requires an ID field in the mutation")
  604. }
  605. oldValue, err := m.oldValue(ctx)
  606. if err != nil {
  607. return v, fmt.Errorf("querying old value for OldAddResult: %w", err)
  608. }
  609. return oldValue.AddResult, nil
  610. }
  611. // ClearAddResult clears the value of the "add_result" field.
  612. func (m *AddWechatFriendLogMutation) ClearAddResult() {
  613. m.add_result = nil
  614. m.clearedFields[addwechatfriendlog.FieldAddResult] = struct{}{}
  615. }
  616. // AddResultCleared returns if the "add_result" field was cleared in this mutation.
  617. func (m *AddWechatFriendLogMutation) AddResultCleared() bool {
  618. _, ok := m.clearedFields[addwechatfriendlog.FieldAddResult]
  619. return ok
  620. }
  621. // ResetAddResult resets all changes to the "add_result" field.
  622. func (m *AddWechatFriendLogMutation) ResetAddResult() {
  623. m.add_result = nil
  624. delete(m.clearedFields, addwechatfriendlog.FieldAddResult)
  625. }
  626. // SetCreatedAt sets the "created_at" field.
  627. func (m *AddWechatFriendLogMutation) SetCreatedAt(i int64) {
  628. m.created_at = &i
  629. m.addcreated_at = nil
  630. }
  631. // CreatedAt returns the value of the "created_at" field in the mutation.
  632. func (m *AddWechatFriendLogMutation) CreatedAt() (r int64, exists bool) {
  633. v := m.created_at
  634. if v == nil {
  635. return
  636. }
  637. return *v, true
  638. }
  639. // OldCreatedAt returns the old "created_at" field's value of the AddWechatFriendLog entity.
  640. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  642. func (m *AddWechatFriendLogMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
  643. if !m.op.Is(OpUpdateOne) {
  644. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  645. }
  646. if m.id == nil || m.oldValue == nil {
  647. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  648. }
  649. oldValue, err := m.oldValue(ctx)
  650. if err != nil {
  651. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  652. }
  653. return oldValue.CreatedAt, nil
  654. }
  655. // AddCreatedAt adds i to the "created_at" field.
  656. func (m *AddWechatFriendLogMutation) AddCreatedAt(i int64) {
  657. if m.addcreated_at != nil {
  658. *m.addcreated_at += i
  659. } else {
  660. m.addcreated_at = &i
  661. }
  662. }
  663. // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
  664. func (m *AddWechatFriendLogMutation) AddedCreatedAt() (r int64, exists bool) {
  665. v := m.addcreated_at
  666. if v == nil {
  667. return
  668. }
  669. return *v, true
  670. }
  671. // ResetCreatedAt resets all changes to the "created_at" field.
  672. func (m *AddWechatFriendLogMutation) ResetCreatedAt() {
  673. m.created_at = nil
  674. m.addcreated_at = nil
  675. }
  676. // SetUpdatedAt sets the "updated_at" field.
  677. func (m *AddWechatFriendLogMutation) SetUpdatedAt(i int64) {
  678. m.updated_at = &i
  679. m.addupdated_at = nil
  680. }
  681. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  682. func (m *AddWechatFriendLogMutation) UpdatedAt() (r int64, exists bool) {
  683. v := m.updated_at
  684. if v == nil {
  685. return
  686. }
  687. return *v, true
  688. }
  689. // OldUpdatedAt returns the old "updated_at" field's value of the AddWechatFriendLog entity.
  690. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  692. func (m *AddWechatFriendLogMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) {
  693. if !m.op.Is(OpUpdateOne) {
  694. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  695. }
  696. if m.id == nil || m.oldValue == nil {
  697. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  698. }
  699. oldValue, err := m.oldValue(ctx)
  700. if err != nil {
  701. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  702. }
  703. return oldValue.UpdatedAt, nil
  704. }
  705. // AddUpdatedAt adds i to the "updated_at" field.
  706. func (m *AddWechatFriendLogMutation) AddUpdatedAt(i int64) {
  707. if m.addupdated_at != nil {
  708. *m.addupdated_at += i
  709. } else {
  710. m.addupdated_at = &i
  711. }
  712. }
  713. // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation.
  714. func (m *AddWechatFriendLogMutation) AddedUpdatedAt() (r int64, exists bool) {
  715. v := m.addupdated_at
  716. if v == nil {
  717. return
  718. }
  719. return *v, true
  720. }
  721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  722. func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
  723. m.updated_at = nil
  724. m.addupdated_at = nil
  725. }
  726. // Where appends a list predicates to the AddWechatFriendLogMutation builder.
  727. func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
  728. m.predicates = append(m.predicates, ps...)
  729. }
  730. // WhereP appends storage-level predicates to the AddWechatFriendLogMutation builder. Using this method,
  731. // users can use type-assertion to append predicates that do not depend on any generated package.
  732. func (m *AddWechatFriendLogMutation) WhereP(ps ...func(*sql.Selector)) {
  733. p := make([]predicate.AddWechatFriendLog, len(ps))
  734. for i := range ps {
  735. p[i] = ps[i]
  736. }
  737. m.Where(p...)
  738. }
  739. // Op returns the operation name.
  740. func (m *AddWechatFriendLogMutation) Op() Op {
  741. return m.op
  742. }
  743. // SetOp allows setting the mutation operation.
  744. func (m *AddWechatFriendLogMutation) SetOp(op Op) {
  745. m.op = op
  746. }
  747. // Type returns the node type of this mutation (AddWechatFriendLog).
  748. func (m *AddWechatFriendLogMutation) Type() string {
  749. return m.typ
  750. }
  751. // Fields returns all fields that were changed during this mutation. Note that in
  752. // order to get all numeric fields that were incremented/decremented, call
  753. // AddedFields().
  754. func (m *AddWechatFriendLogMutation) Fields() []string {
  755. fields := make([]string, 0, 11)
  756. if m.owner_wx_id != nil {
  757. fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
  758. }
  759. if m.owner_wx_type != nil {
  760. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  761. }
  762. if m.find_content != nil {
  763. fields = append(fields, addwechatfriendlog.FieldFindContent)
  764. }
  765. if m.find_request != nil {
  766. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  767. }
  768. if m.find_result != nil {
  769. fields = append(fields, addwechatfriendlog.FieldFindResult)
  770. }
  771. if m.is_can_add != nil {
  772. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  773. }
  774. if m.task_id != nil {
  775. fields = append(fields, addwechatfriendlog.FieldTaskID)
  776. }
  777. if m.add_request != nil {
  778. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  779. }
  780. if m.add_result != nil {
  781. fields = append(fields, addwechatfriendlog.FieldAddResult)
  782. }
  783. if m.created_at != nil {
  784. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  785. }
  786. if m.updated_at != nil {
  787. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  788. }
  789. return fields
  790. }
  791. // Field returns the value of a field with the given name. The second boolean
  792. // return value indicates that this field was not set, or was not defined in the
  793. // schema.
  794. func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
  795. switch name {
  796. case addwechatfriendlog.FieldOwnerWxID:
  797. return m.OwnerWxID()
  798. case addwechatfriendlog.FieldOwnerWxType:
  799. return m.OwnerWxType()
  800. case addwechatfriendlog.FieldFindContent:
  801. return m.FindContent()
  802. case addwechatfriendlog.FieldFindRequest:
  803. return m.FindRequest()
  804. case addwechatfriendlog.FieldFindResult:
  805. return m.FindResult()
  806. case addwechatfriendlog.FieldIsCanAdd:
  807. return m.IsCanAdd()
  808. case addwechatfriendlog.FieldTaskID:
  809. return m.TaskID()
  810. case addwechatfriendlog.FieldAddRequest:
  811. return m.AddRequest()
  812. case addwechatfriendlog.FieldAddResult:
  813. return m.AddResult()
  814. case addwechatfriendlog.FieldCreatedAt:
  815. return m.CreatedAt()
  816. case addwechatfriendlog.FieldUpdatedAt:
  817. return m.UpdatedAt()
  818. }
  819. return nil, false
  820. }
  821. // OldField returns the old value of the field from the database. An error is
  822. // returned if the mutation operation is not UpdateOne, or the query to the
  823. // database failed.
  824. func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  825. switch name {
  826. case addwechatfriendlog.FieldOwnerWxID:
  827. return m.OldOwnerWxID(ctx)
  828. case addwechatfriendlog.FieldOwnerWxType:
  829. return m.OldOwnerWxType(ctx)
  830. case addwechatfriendlog.FieldFindContent:
  831. return m.OldFindContent(ctx)
  832. case addwechatfriendlog.FieldFindRequest:
  833. return m.OldFindRequest(ctx)
  834. case addwechatfriendlog.FieldFindResult:
  835. return m.OldFindResult(ctx)
  836. case addwechatfriendlog.FieldIsCanAdd:
  837. return m.OldIsCanAdd(ctx)
  838. case addwechatfriendlog.FieldTaskID:
  839. return m.OldTaskID(ctx)
  840. case addwechatfriendlog.FieldAddRequest:
  841. return m.OldAddRequest(ctx)
  842. case addwechatfriendlog.FieldAddResult:
  843. return m.OldAddResult(ctx)
  844. case addwechatfriendlog.FieldCreatedAt:
  845. return m.OldCreatedAt(ctx)
  846. case addwechatfriendlog.FieldUpdatedAt:
  847. return m.OldUpdatedAt(ctx)
  848. }
  849. return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  850. }
  851. // SetField sets the value of a field with the given name. It returns an error if
  852. // the field is not defined in the schema, or if the type mismatched the field
  853. // type.
  854. func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) error {
  855. switch name {
  856. case addwechatfriendlog.FieldOwnerWxID:
  857. v, ok := value.(string)
  858. if !ok {
  859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  860. }
  861. m.SetOwnerWxID(v)
  862. return nil
  863. case addwechatfriendlog.FieldOwnerWxType:
  864. v, ok := value.(int)
  865. if !ok {
  866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  867. }
  868. m.SetOwnerWxType(v)
  869. return nil
  870. case addwechatfriendlog.FieldFindContent:
  871. v, ok := value.(string)
  872. if !ok {
  873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  874. }
  875. m.SetFindContent(v)
  876. return nil
  877. case addwechatfriendlog.FieldFindRequest:
  878. v, ok := value.(map[string]interface{})
  879. if !ok {
  880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  881. }
  882. m.SetFindRequest(v)
  883. return nil
  884. case addwechatfriendlog.FieldFindResult:
  885. v, ok := value.(map[string]interface{})
  886. if !ok {
  887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  888. }
  889. m.SetFindResult(v)
  890. return nil
  891. case addwechatfriendlog.FieldIsCanAdd:
  892. v, ok := value.(int)
  893. if !ok {
  894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  895. }
  896. m.SetIsCanAdd(v)
  897. return nil
  898. case addwechatfriendlog.FieldTaskID:
  899. v, ok := value.(int64)
  900. if !ok {
  901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  902. }
  903. m.SetTaskID(v)
  904. return nil
  905. case addwechatfriendlog.FieldAddRequest:
  906. v, ok := value.(map[string]interface{})
  907. if !ok {
  908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  909. }
  910. m.SetAddRequest(v)
  911. return nil
  912. case addwechatfriendlog.FieldAddResult:
  913. v, ok := value.(map[string]interface{})
  914. if !ok {
  915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  916. }
  917. m.SetAddResult(v)
  918. return nil
  919. case addwechatfriendlog.FieldCreatedAt:
  920. v, ok := value.(int64)
  921. if !ok {
  922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  923. }
  924. m.SetCreatedAt(v)
  925. return nil
  926. case addwechatfriendlog.FieldUpdatedAt:
  927. v, ok := value.(int64)
  928. if !ok {
  929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  930. }
  931. m.SetUpdatedAt(v)
  932. return nil
  933. }
  934. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  935. }
  936. // AddedFields returns all numeric fields that were incremented/decremented during
  937. // this mutation.
  938. func (m *AddWechatFriendLogMutation) AddedFields() []string {
  939. var fields []string
  940. if m.addowner_wx_type != nil {
  941. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  942. }
  943. if m.addis_can_add != nil {
  944. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  945. }
  946. if m.addtask_id != nil {
  947. fields = append(fields, addwechatfriendlog.FieldTaskID)
  948. }
  949. if m.addcreated_at != nil {
  950. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  951. }
  952. if m.addupdated_at != nil {
  953. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  954. }
  955. return fields
  956. }
  957. // AddedField returns the numeric value that was incremented/decremented on a field
  958. // with the given name. The second boolean return value indicates that this field
  959. // was not set, or was not defined in the schema.
  960. func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
  961. switch name {
  962. case addwechatfriendlog.FieldOwnerWxType:
  963. return m.AddedOwnerWxType()
  964. case addwechatfriendlog.FieldIsCanAdd:
  965. return m.AddedIsCanAdd()
  966. case addwechatfriendlog.FieldTaskID:
  967. return m.AddedTaskID()
  968. case addwechatfriendlog.FieldCreatedAt:
  969. return m.AddedCreatedAt()
  970. case addwechatfriendlog.FieldUpdatedAt:
  971. return m.AddedUpdatedAt()
  972. }
  973. return nil, false
  974. }
  975. // AddField adds the value to the field with the given name. It returns an error if
  976. // the field is not defined in the schema, or if the type mismatched the field
  977. // type.
  978. func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) error {
  979. switch name {
  980. case addwechatfriendlog.FieldOwnerWxType:
  981. v, ok := value.(int)
  982. if !ok {
  983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  984. }
  985. m.AddOwnerWxType(v)
  986. return nil
  987. case addwechatfriendlog.FieldIsCanAdd:
  988. v, ok := value.(int)
  989. if !ok {
  990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  991. }
  992. m.AddIsCanAdd(v)
  993. return nil
  994. case addwechatfriendlog.FieldTaskID:
  995. v, ok := value.(int64)
  996. if !ok {
  997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  998. }
  999. m.AddTaskID(v)
  1000. return nil
  1001. case addwechatfriendlog.FieldCreatedAt:
  1002. v, ok := value.(int64)
  1003. if !ok {
  1004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1005. }
  1006. m.AddCreatedAt(v)
  1007. return nil
  1008. case addwechatfriendlog.FieldUpdatedAt:
  1009. v, ok := value.(int64)
  1010. if !ok {
  1011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1012. }
  1013. m.AddUpdatedAt(v)
  1014. return nil
  1015. }
  1016. return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
  1017. }
  1018. // ClearedFields returns all nullable fields that were cleared during this
  1019. // mutation.
  1020. func (m *AddWechatFriendLogMutation) ClearedFields() []string {
  1021. var fields []string
  1022. if m.FieldCleared(addwechatfriendlog.FieldFindRequest) {
  1023. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  1024. }
  1025. if m.FieldCleared(addwechatfriendlog.FieldFindResult) {
  1026. fields = append(fields, addwechatfriendlog.FieldFindResult)
  1027. }
  1028. if m.FieldCleared(addwechatfriendlog.FieldAddRequest) {
  1029. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  1030. }
  1031. if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
  1032. fields = append(fields, addwechatfriendlog.FieldAddResult)
  1033. }
  1034. return fields
  1035. }
  1036. // FieldCleared returns a boolean indicating if a field with the given name was
  1037. // cleared in this mutation.
  1038. func (m *AddWechatFriendLogMutation) FieldCleared(name string) bool {
  1039. _, ok := m.clearedFields[name]
  1040. return ok
  1041. }
  1042. // ClearField clears the value of the field with the given name. It returns an
  1043. // error if the field is not defined in the schema.
  1044. func (m *AddWechatFriendLogMutation) ClearField(name string) error {
  1045. switch name {
  1046. case addwechatfriendlog.FieldFindRequest:
  1047. m.ClearFindRequest()
  1048. return nil
  1049. case addwechatfriendlog.FieldFindResult:
  1050. m.ClearFindResult()
  1051. return nil
  1052. case addwechatfriendlog.FieldAddRequest:
  1053. m.ClearAddRequest()
  1054. return nil
  1055. case addwechatfriendlog.FieldAddResult:
  1056. m.ClearAddResult()
  1057. return nil
  1058. }
  1059. return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
  1060. }
  1061. // ResetField resets all changes in the mutation for the field with the given name.
  1062. // It returns an error if the field is not defined in the schema.
  1063. func (m *AddWechatFriendLogMutation) ResetField(name string) error {
  1064. switch name {
  1065. case addwechatfriendlog.FieldOwnerWxID:
  1066. m.ResetOwnerWxID()
  1067. return nil
  1068. case addwechatfriendlog.FieldOwnerWxType:
  1069. m.ResetOwnerWxType()
  1070. return nil
  1071. case addwechatfriendlog.FieldFindContent:
  1072. m.ResetFindContent()
  1073. return nil
  1074. case addwechatfriendlog.FieldFindRequest:
  1075. m.ResetFindRequest()
  1076. return nil
  1077. case addwechatfriendlog.FieldFindResult:
  1078. m.ResetFindResult()
  1079. return nil
  1080. case addwechatfriendlog.FieldIsCanAdd:
  1081. m.ResetIsCanAdd()
  1082. return nil
  1083. case addwechatfriendlog.FieldTaskID:
  1084. m.ResetTaskID()
  1085. return nil
  1086. case addwechatfriendlog.FieldAddRequest:
  1087. m.ResetAddRequest()
  1088. return nil
  1089. case addwechatfriendlog.FieldAddResult:
  1090. m.ResetAddResult()
  1091. return nil
  1092. case addwechatfriendlog.FieldCreatedAt:
  1093. m.ResetCreatedAt()
  1094. return nil
  1095. case addwechatfriendlog.FieldUpdatedAt:
  1096. m.ResetUpdatedAt()
  1097. return nil
  1098. }
  1099. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1100. }
  1101. // AddedEdges returns all edge names that were set/added in this mutation.
  1102. func (m *AddWechatFriendLogMutation) AddedEdges() []string {
  1103. edges := make([]string, 0, 0)
  1104. return edges
  1105. }
  1106. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1107. // name in this mutation.
  1108. func (m *AddWechatFriendLogMutation) AddedIDs(name string) []ent.Value {
  1109. return nil
  1110. }
  1111. // RemovedEdges returns all edge names that were removed in this mutation.
  1112. func (m *AddWechatFriendLogMutation) RemovedEdges() []string {
  1113. edges := make([]string, 0, 0)
  1114. return edges
  1115. }
  1116. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1117. // the given name in this mutation.
  1118. func (m *AddWechatFriendLogMutation) RemovedIDs(name string) []ent.Value {
  1119. return nil
  1120. }
  1121. // ClearedEdges returns all edge names that were cleared in this mutation.
  1122. func (m *AddWechatFriendLogMutation) ClearedEdges() []string {
  1123. edges := make([]string, 0, 0)
  1124. return edges
  1125. }
  1126. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1127. // was cleared in this mutation.
  1128. func (m *AddWechatFriendLogMutation) EdgeCleared(name string) bool {
  1129. return false
  1130. }
  1131. // ClearEdge clears the value of the edge with the given name. It returns an error
  1132. // if that edge is not defined in the schema.
  1133. func (m *AddWechatFriendLogMutation) ClearEdge(name string) error {
  1134. return fmt.Errorf("unknown AddWechatFriendLog unique edge %s", name)
  1135. }
  1136. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1137. // It returns an error if the edge is not defined in the schema.
  1138. func (m *AddWechatFriendLogMutation) ResetEdge(name string) error {
  1139. return fmt.Errorf("unknown AddWechatFriendLog edge %s", name)
  1140. }
  1141. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  1142. type AgentMutation struct {
  1143. config
  1144. op Op
  1145. typ string
  1146. id *uint64
  1147. created_at *time.Time
  1148. updated_at *time.Time
  1149. deleted_at *time.Time
  1150. name *string
  1151. role *string
  1152. status *int
  1153. addstatus *int
  1154. background *string
  1155. examples *string
  1156. organization_id *uint64
  1157. addorganization_id *int64
  1158. dataset_id *string
  1159. collection_id *string
  1160. model *string
  1161. api_base *string
  1162. api_key *string
  1163. _type *int
  1164. add_type *int
  1165. clearedFields map[string]struct{}
  1166. wx_agent map[uint64]struct{}
  1167. removedwx_agent map[uint64]struct{}
  1168. clearedwx_agent bool
  1169. token_agent map[uint64]struct{}
  1170. removedtoken_agent map[uint64]struct{}
  1171. clearedtoken_agent bool
  1172. wa_agent map[uint64]struct{}
  1173. removedwa_agent map[uint64]struct{}
  1174. clearedwa_agent bool
  1175. xjs_agent map[uint64]struct{}
  1176. removedxjs_agent map[uint64]struct{}
  1177. clearedxjs_agent bool
  1178. key_agent map[uint64]struct{}
  1179. removedkey_agent map[uint64]struct{}
  1180. clearedkey_agent bool
  1181. done bool
  1182. oldValue func(context.Context) (*Agent, error)
  1183. predicates []predicate.Agent
  1184. }
  1185. var _ ent.Mutation = (*AgentMutation)(nil)
  1186. // agentOption allows management of the mutation configuration using functional options.
  1187. type agentOption func(*AgentMutation)
  1188. // newAgentMutation creates new mutation for the Agent entity.
  1189. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  1190. m := &AgentMutation{
  1191. config: c,
  1192. op: op,
  1193. typ: TypeAgent,
  1194. clearedFields: make(map[string]struct{}),
  1195. }
  1196. for _, opt := range opts {
  1197. opt(m)
  1198. }
  1199. return m
  1200. }
  1201. // withAgentID sets the ID field of the mutation.
  1202. func withAgentID(id uint64) agentOption {
  1203. return func(m *AgentMutation) {
  1204. var (
  1205. err error
  1206. once sync.Once
  1207. value *Agent
  1208. )
  1209. m.oldValue = func(ctx context.Context) (*Agent, error) {
  1210. once.Do(func() {
  1211. if m.done {
  1212. err = errors.New("querying old values post mutation is not allowed")
  1213. } else {
  1214. value, err = m.Client().Agent.Get(ctx, id)
  1215. }
  1216. })
  1217. return value, err
  1218. }
  1219. m.id = &id
  1220. }
  1221. }
  1222. // withAgent sets the old Agent of the mutation.
  1223. func withAgent(node *Agent) agentOption {
  1224. return func(m *AgentMutation) {
  1225. m.oldValue = func(context.Context) (*Agent, error) {
  1226. return node, nil
  1227. }
  1228. m.id = &node.ID
  1229. }
  1230. }
  1231. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1232. // executed in a transaction (ent.Tx), a transactional client is returned.
  1233. func (m AgentMutation) Client() *Client {
  1234. client := &Client{config: m.config}
  1235. client.init()
  1236. return client
  1237. }
  1238. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1239. // it returns an error otherwise.
  1240. func (m AgentMutation) Tx() (*Tx, error) {
  1241. if _, ok := m.driver.(*txDriver); !ok {
  1242. return nil, errors.New("ent: mutation is not running in a transaction")
  1243. }
  1244. tx := &Tx{config: m.config}
  1245. tx.init()
  1246. return tx, nil
  1247. }
  1248. // SetID sets the value of the id field. Note that this
  1249. // operation is only accepted on creation of Agent entities.
  1250. func (m *AgentMutation) SetID(id uint64) {
  1251. m.id = &id
  1252. }
  1253. // ID returns the ID value in the mutation. Note that the ID is only available
  1254. // if it was provided to the builder or after it was returned from the database.
  1255. func (m *AgentMutation) ID() (id uint64, exists bool) {
  1256. if m.id == nil {
  1257. return
  1258. }
  1259. return *m.id, true
  1260. }
  1261. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1262. // That means, if the mutation is applied within a transaction with an isolation level such
  1263. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1264. // or updated by the mutation.
  1265. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  1266. switch {
  1267. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1268. id, exists := m.ID()
  1269. if exists {
  1270. return []uint64{id}, nil
  1271. }
  1272. fallthrough
  1273. case m.op.Is(OpUpdate | OpDelete):
  1274. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  1275. default:
  1276. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1277. }
  1278. }
  1279. // SetCreatedAt sets the "created_at" field.
  1280. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  1281. m.created_at = &t
  1282. }
  1283. // CreatedAt returns the value of the "created_at" field in the mutation.
  1284. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  1285. v := m.created_at
  1286. if v == nil {
  1287. return
  1288. }
  1289. return *v, true
  1290. }
  1291. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  1292. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1294. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1295. if !m.op.Is(OpUpdateOne) {
  1296. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1297. }
  1298. if m.id == nil || m.oldValue == nil {
  1299. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1300. }
  1301. oldValue, err := m.oldValue(ctx)
  1302. if err != nil {
  1303. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1304. }
  1305. return oldValue.CreatedAt, nil
  1306. }
  1307. // ResetCreatedAt resets all changes to the "created_at" field.
  1308. func (m *AgentMutation) ResetCreatedAt() {
  1309. m.created_at = nil
  1310. }
  1311. // SetUpdatedAt sets the "updated_at" field.
  1312. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  1313. m.updated_at = &t
  1314. }
  1315. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1316. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  1317. v := m.updated_at
  1318. if v == nil {
  1319. return
  1320. }
  1321. return *v, true
  1322. }
  1323. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  1324. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1326. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1327. if !m.op.Is(OpUpdateOne) {
  1328. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1329. }
  1330. if m.id == nil || m.oldValue == nil {
  1331. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1332. }
  1333. oldValue, err := m.oldValue(ctx)
  1334. if err != nil {
  1335. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1336. }
  1337. return oldValue.UpdatedAt, nil
  1338. }
  1339. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1340. func (m *AgentMutation) ResetUpdatedAt() {
  1341. m.updated_at = nil
  1342. }
  1343. // SetDeletedAt sets the "deleted_at" field.
  1344. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  1345. m.deleted_at = &t
  1346. }
  1347. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1348. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  1349. v := m.deleted_at
  1350. if v == nil {
  1351. return
  1352. }
  1353. return *v, true
  1354. }
  1355. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  1356. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1358. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1359. if !m.op.Is(OpUpdateOne) {
  1360. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1361. }
  1362. if m.id == nil || m.oldValue == nil {
  1363. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1364. }
  1365. oldValue, err := m.oldValue(ctx)
  1366. if err != nil {
  1367. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1368. }
  1369. return oldValue.DeletedAt, nil
  1370. }
  1371. // ClearDeletedAt clears the value of the "deleted_at" field.
  1372. func (m *AgentMutation) ClearDeletedAt() {
  1373. m.deleted_at = nil
  1374. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  1375. }
  1376. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1377. func (m *AgentMutation) DeletedAtCleared() bool {
  1378. _, ok := m.clearedFields[agent.FieldDeletedAt]
  1379. return ok
  1380. }
  1381. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1382. func (m *AgentMutation) ResetDeletedAt() {
  1383. m.deleted_at = nil
  1384. delete(m.clearedFields, agent.FieldDeletedAt)
  1385. }
  1386. // SetName sets the "name" field.
  1387. func (m *AgentMutation) SetName(s string) {
  1388. m.name = &s
  1389. }
  1390. // Name returns the value of the "name" field in the mutation.
  1391. func (m *AgentMutation) Name() (r string, exists bool) {
  1392. v := m.name
  1393. if v == nil {
  1394. return
  1395. }
  1396. return *v, true
  1397. }
  1398. // OldName returns the old "name" field's value of the Agent entity.
  1399. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1401. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  1402. if !m.op.Is(OpUpdateOne) {
  1403. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1404. }
  1405. if m.id == nil || m.oldValue == nil {
  1406. return v, errors.New("OldName requires an ID field in the mutation")
  1407. }
  1408. oldValue, err := m.oldValue(ctx)
  1409. if err != nil {
  1410. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1411. }
  1412. return oldValue.Name, nil
  1413. }
  1414. // ResetName resets all changes to the "name" field.
  1415. func (m *AgentMutation) ResetName() {
  1416. m.name = nil
  1417. }
  1418. // SetRole sets the "role" field.
  1419. func (m *AgentMutation) SetRole(s string) {
  1420. m.role = &s
  1421. }
  1422. // Role returns the value of the "role" field in the mutation.
  1423. func (m *AgentMutation) Role() (r string, exists bool) {
  1424. v := m.role
  1425. if v == nil {
  1426. return
  1427. }
  1428. return *v, true
  1429. }
  1430. // OldRole returns the old "role" field's value of the Agent entity.
  1431. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1433. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  1434. if !m.op.Is(OpUpdateOne) {
  1435. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  1436. }
  1437. if m.id == nil || m.oldValue == nil {
  1438. return v, errors.New("OldRole requires an ID field in the mutation")
  1439. }
  1440. oldValue, err := m.oldValue(ctx)
  1441. if err != nil {
  1442. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  1443. }
  1444. return oldValue.Role, nil
  1445. }
  1446. // ClearRole clears the value of the "role" field.
  1447. func (m *AgentMutation) ClearRole() {
  1448. m.role = nil
  1449. m.clearedFields[agent.FieldRole] = struct{}{}
  1450. }
  1451. // RoleCleared returns if the "role" field was cleared in this mutation.
  1452. func (m *AgentMutation) RoleCleared() bool {
  1453. _, ok := m.clearedFields[agent.FieldRole]
  1454. return ok
  1455. }
  1456. // ResetRole resets all changes to the "role" field.
  1457. func (m *AgentMutation) ResetRole() {
  1458. m.role = nil
  1459. delete(m.clearedFields, agent.FieldRole)
  1460. }
  1461. // SetStatus sets the "status" field.
  1462. func (m *AgentMutation) SetStatus(i int) {
  1463. m.status = &i
  1464. m.addstatus = nil
  1465. }
  1466. // Status returns the value of the "status" field in the mutation.
  1467. func (m *AgentMutation) Status() (r int, exists bool) {
  1468. v := m.status
  1469. if v == nil {
  1470. return
  1471. }
  1472. return *v, true
  1473. }
  1474. // OldStatus returns the old "status" field's value of the Agent entity.
  1475. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1477. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  1478. if !m.op.Is(OpUpdateOne) {
  1479. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1480. }
  1481. if m.id == nil || m.oldValue == nil {
  1482. return v, errors.New("OldStatus requires an ID field in the mutation")
  1483. }
  1484. oldValue, err := m.oldValue(ctx)
  1485. if err != nil {
  1486. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1487. }
  1488. return oldValue.Status, nil
  1489. }
  1490. // AddStatus adds i to the "status" field.
  1491. func (m *AgentMutation) AddStatus(i int) {
  1492. if m.addstatus != nil {
  1493. *m.addstatus += i
  1494. } else {
  1495. m.addstatus = &i
  1496. }
  1497. }
  1498. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1499. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  1500. v := m.addstatus
  1501. if v == nil {
  1502. return
  1503. }
  1504. return *v, true
  1505. }
  1506. // ClearStatus clears the value of the "status" field.
  1507. func (m *AgentMutation) ClearStatus() {
  1508. m.status = nil
  1509. m.addstatus = nil
  1510. m.clearedFields[agent.FieldStatus] = struct{}{}
  1511. }
  1512. // StatusCleared returns if the "status" field was cleared in this mutation.
  1513. func (m *AgentMutation) StatusCleared() bool {
  1514. _, ok := m.clearedFields[agent.FieldStatus]
  1515. return ok
  1516. }
  1517. // ResetStatus resets all changes to the "status" field.
  1518. func (m *AgentMutation) ResetStatus() {
  1519. m.status = nil
  1520. m.addstatus = nil
  1521. delete(m.clearedFields, agent.FieldStatus)
  1522. }
  1523. // SetBackground sets the "background" field.
  1524. func (m *AgentMutation) SetBackground(s string) {
  1525. m.background = &s
  1526. }
  1527. // Background returns the value of the "background" field in the mutation.
  1528. func (m *AgentMutation) Background() (r string, exists bool) {
  1529. v := m.background
  1530. if v == nil {
  1531. return
  1532. }
  1533. return *v, true
  1534. }
  1535. // OldBackground returns the old "background" field's value of the Agent entity.
  1536. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1538. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  1539. if !m.op.Is(OpUpdateOne) {
  1540. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  1541. }
  1542. if m.id == nil || m.oldValue == nil {
  1543. return v, errors.New("OldBackground requires an ID field in the mutation")
  1544. }
  1545. oldValue, err := m.oldValue(ctx)
  1546. if err != nil {
  1547. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  1548. }
  1549. return oldValue.Background, nil
  1550. }
  1551. // ClearBackground clears the value of the "background" field.
  1552. func (m *AgentMutation) ClearBackground() {
  1553. m.background = nil
  1554. m.clearedFields[agent.FieldBackground] = struct{}{}
  1555. }
  1556. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  1557. func (m *AgentMutation) BackgroundCleared() bool {
  1558. _, ok := m.clearedFields[agent.FieldBackground]
  1559. return ok
  1560. }
  1561. // ResetBackground resets all changes to the "background" field.
  1562. func (m *AgentMutation) ResetBackground() {
  1563. m.background = nil
  1564. delete(m.clearedFields, agent.FieldBackground)
  1565. }
  1566. // SetExamples sets the "examples" field.
  1567. func (m *AgentMutation) SetExamples(s string) {
  1568. m.examples = &s
  1569. }
  1570. // Examples returns the value of the "examples" field in the mutation.
  1571. func (m *AgentMutation) Examples() (r string, exists bool) {
  1572. v := m.examples
  1573. if v == nil {
  1574. return
  1575. }
  1576. return *v, true
  1577. }
  1578. // OldExamples returns the old "examples" field's value of the Agent entity.
  1579. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1581. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  1582. if !m.op.Is(OpUpdateOne) {
  1583. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  1584. }
  1585. if m.id == nil || m.oldValue == nil {
  1586. return v, errors.New("OldExamples requires an ID field in the mutation")
  1587. }
  1588. oldValue, err := m.oldValue(ctx)
  1589. if err != nil {
  1590. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  1591. }
  1592. return oldValue.Examples, nil
  1593. }
  1594. // ClearExamples clears the value of the "examples" field.
  1595. func (m *AgentMutation) ClearExamples() {
  1596. m.examples = nil
  1597. m.clearedFields[agent.FieldExamples] = struct{}{}
  1598. }
  1599. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  1600. func (m *AgentMutation) ExamplesCleared() bool {
  1601. _, ok := m.clearedFields[agent.FieldExamples]
  1602. return ok
  1603. }
  1604. // ResetExamples resets all changes to the "examples" field.
  1605. func (m *AgentMutation) ResetExamples() {
  1606. m.examples = nil
  1607. delete(m.clearedFields, agent.FieldExamples)
  1608. }
  1609. // SetOrganizationID sets the "organization_id" field.
  1610. func (m *AgentMutation) SetOrganizationID(u uint64) {
  1611. m.organization_id = &u
  1612. m.addorganization_id = nil
  1613. }
  1614. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1615. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  1616. v := m.organization_id
  1617. if v == nil {
  1618. return
  1619. }
  1620. return *v, true
  1621. }
  1622. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  1623. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1625. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1626. if !m.op.Is(OpUpdateOne) {
  1627. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1628. }
  1629. if m.id == nil || m.oldValue == nil {
  1630. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1631. }
  1632. oldValue, err := m.oldValue(ctx)
  1633. if err != nil {
  1634. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1635. }
  1636. return oldValue.OrganizationID, nil
  1637. }
  1638. // AddOrganizationID adds u to the "organization_id" field.
  1639. func (m *AgentMutation) AddOrganizationID(u int64) {
  1640. if m.addorganization_id != nil {
  1641. *m.addorganization_id += u
  1642. } else {
  1643. m.addorganization_id = &u
  1644. }
  1645. }
  1646. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1647. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  1648. v := m.addorganization_id
  1649. if v == nil {
  1650. return
  1651. }
  1652. return *v, true
  1653. }
  1654. // ResetOrganizationID resets all changes to the "organization_id" field.
  1655. func (m *AgentMutation) ResetOrganizationID() {
  1656. m.organization_id = nil
  1657. m.addorganization_id = nil
  1658. }
  1659. // SetDatasetID sets the "dataset_id" field.
  1660. func (m *AgentMutation) SetDatasetID(s string) {
  1661. m.dataset_id = &s
  1662. }
  1663. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1664. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  1665. v := m.dataset_id
  1666. if v == nil {
  1667. return
  1668. }
  1669. return *v, true
  1670. }
  1671. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  1672. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1674. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1675. if !m.op.Is(OpUpdateOne) {
  1676. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1677. }
  1678. if m.id == nil || m.oldValue == nil {
  1679. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1680. }
  1681. oldValue, err := m.oldValue(ctx)
  1682. if err != nil {
  1683. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1684. }
  1685. return oldValue.DatasetID, nil
  1686. }
  1687. // ResetDatasetID resets all changes to the "dataset_id" field.
  1688. func (m *AgentMutation) ResetDatasetID() {
  1689. m.dataset_id = nil
  1690. }
  1691. // SetCollectionID sets the "collection_id" field.
  1692. func (m *AgentMutation) SetCollectionID(s string) {
  1693. m.collection_id = &s
  1694. }
  1695. // CollectionID returns the value of the "collection_id" field in the mutation.
  1696. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  1697. v := m.collection_id
  1698. if v == nil {
  1699. return
  1700. }
  1701. return *v, true
  1702. }
  1703. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  1704. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1706. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1707. if !m.op.Is(OpUpdateOne) {
  1708. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1709. }
  1710. if m.id == nil || m.oldValue == nil {
  1711. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1712. }
  1713. oldValue, err := m.oldValue(ctx)
  1714. if err != nil {
  1715. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1716. }
  1717. return oldValue.CollectionID, nil
  1718. }
  1719. // ResetCollectionID resets all changes to the "collection_id" field.
  1720. func (m *AgentMutation) ResetCollectionID() {
  1721. m.collection_id = nil
  1722. }
  1723. // SetModel sets the "model" field.
  1724. func (m *AgentMutation) SetModel(s string) {
  1725. m.model = &s
  1726. }
  1727. // Model returns the value of the "model" field in the mutation.
  1728. func (m *AgentMutation) Model() (r string, exists bool) {
  1729. v := m.model
  1730. if v == nil {
  1731. return
  1732. }
  1733. return *v, true
  1734. }
  1735. // OldModel returns the old "model" field's value of the Agent entity.
  1736. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1738. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  1739. if !m.op.Is(OpUpdateOne) {
  1740. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  1741. }
  1742. if m.id == nil || m.oldValue == nil {
  1743. return v, errors.New("OldModel requires an ID field in the mutation")
  1744. }
  1745. oldValue, err := m.oldValue(ctx)
  1746. if err != nil {
  1747. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  1748. }
  1749. return oldValue.Model, nil
  1750. }
  1751. // ClearModel clears the value of the "model" field.
  1752. func (m *AgentMutation) ClearModel() {
  1753. m.model = nil
  1754. m.clearedFields[agent.FieldModel] = struct{}{}
  1755. }
  1756. // ModelCleared returns if the "model" field was cleared in this mutation.
  1757. func (m *AgentMutation) ModelCleared() bool {
  1758. _, ok := m.clearedFields[agent.FieldModel]
  1759. return ok
  1760. }
  1761. // ResetModel resets all changes to the "model" field.
  1762. func (m *AgentMutation) ResetModel() {
  1763. m.model = nil
  1764. delete(m.clearedFields, agent.FieldModel)
  1765. }
  1766. // SetAPIBase sets the "api_base" field.
  1767. func (m *AgentMutation) SetAPIBase(s string) {
  1768. m.api_base = &s
  1769. }
  1770. // APIBase returns the value of the "api_base" field in the mutation.
  1771. func (m *AgentMutation) APIBase() (r string, exists bool) {
  1772. v := m.api_base
  1773. if v == nil {
  1774. return
  1775. }
  1776. return *v, true
  1777. }
  1778. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  1779. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1781. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  1782. if !m.op.Is(OpUpdateOne) {
  1783. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  1784. }
  1785. if m.id == nil || m.oldValue == nil {
  1786. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  1787. }
  1788. oldValue, err := m.oldValue(ctx)
  1789. if err != nil {
  1790. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  1791. }
  1792. return oldValue.APIBase, nil
  1793. }
  1794. // ClearAPIBase clears the value of the "api_base" field.
  1795. func (m *AgentMutation) ClearAPIBase() {
  1796. m.api_base = nil
  1797. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  1798. }
  1799. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  1800. func (m *AgentMutation) APIBaseCleared() bool {
  1801. _, ok := m.clearedFields[agent.FieldAPIBase]
  1802. return ok
  1803. }
  1804. // ResetAPIBase resets all changes to the "api_base" field.
  1805. func (m *AgentMutation) ResetAPIBase() {
  1806. m.api_base = nil
  1807. delete(m.clearedFields, agent.FieldAPIBase)
  1808. }
  1809. // SetAPIKey sets the "api_key" field.
  1810. func (m *AgentMutation) SetAPIKey(s string) {
  1811. m.api_key = &s
  1812. }
  1813. // APIKey returns the value of the "api_key" field in the mutation.
  1814. func (m *AgentMutation) APIKey() (r string, exists bool) {
  1815. v := m.api_key
  1816. if v == nil {
  1817. return
  1818. }
  1819. return *v, true
  1820. }
  1821. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  1822. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1824. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  1825. if !m.op.Is(OpUpdateOne) {
  1826. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  1827. }
  1828. if m.id == nil || m.oldValue == nil {
  1829. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  1830. }
  1831. oldValue, err := m.oldValue(ctx)
  1832. if err != nil {
  1833. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  1834. }
  1835. return oldValue.APIKey, nil
  1836. }
  1837. // ClearAPIKey clears the value of the "api_key" field.
  1838. func (m *AgentMutation) ClearAPIKey() {
  1839. m.api_key = nil
  1840. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  1841. }
  1842. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  1843. func (m *AgentMutation) APIKeyCleared() bool {
  1844. _, ok := m.clearedFields[agent.FieldAPIKey]
  1845. return ok
  1846. }
  1847. // ResetAPIKey resets all changes to the "api_key" field.
  1848. func (m *AgentMutation) ResetAPIKey() {
  1849. m.api_key = nil
  1850. delete(m.clearedFields, agent.FieldAPIKey)
  1851. }
  1852. // SetType sets the "type" field.
  1853. func (m *AgentMutation) SetType(i int) {
  1854. m._type = &i
  1855. m.add_type = nil
  1856. }
  1857. // GetType returns the value of the "type" field in the mutation.
  1858. func (m *AgentMutation) GetType() (r int, exists bool) {
  1859. v := m._type
  1860. if v == nil {
  1861. return
  1862. }
  1863. return *v, true
  1864. }
  1865. // OldType returns the old "type" field's value of the Agent entity.
  1866. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1868. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  1869. if !m.op.Is(OpUpdateOne) {
  1870. return v, errors.New("OldType is only allowed on UpdateOne operations")
  1871. }
  1872. if m.id == nil || m.oldValue == nil {
  1873. return v, errors.New("OldType requires an ID field in the mutation")
  1874. }
  1875. oldValue, err := m.oldValue(ctx)
  1876. if err != nil {
  1877. return v, fmt.Errorf("querying old value for OldType: %w", err)
  1878. }
  1879. return oldValue.Type, nil
  1880. }
  1881. // AddType adds i to the "type" field.
  1882. func (m *AgentMutation) AddType(i int) {
  1883. if m.add_type != nil {
  1884. *m.add_type += i
  1885. } else {
  1886. m.add_type = &i
  1887. }
  1888. }
  1889. // AddedType returns the value that was added to the "type" field in this mutation.
  1890. func (m *AgentMutation) AddedType() (r int, exists bool) {
  1891. v := m.add_type
  1892. if v == nil {
  1893. return
  1894. }
  1895. return *v, true
  1896. }
  1897. // ClearType clears the value of the "type" field.
  1898. func (m *AgentMutation) ClearType() {
  1899. m._type = nil
  1900. m.add_type = nil
  1901. m.clearedFields[agent.FieldType] = struct{}{}
  1902. }
  1903. // TypeCleared returns if the "type" field was cleared in this mutation.
  1904. func (m *AgentMutation) TypeCleared() bool {
  1905. _, ok := m.clearedFields[agent.FieldType]
  1906. return ok
  1907. }
  1908. // ResetType resets all changes to the "type" field.
  1909. func (m *AgentMutation) ResetType() {
  1910. m._type = nil
  1911. m.add_type = nil
  1912. delete(m.clearedFields, agent.FieldType)
  1913. }
  1914. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1915. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  1916. if m.wx_agent == nil {
  1917. m.wx_agent = make(map[uint64]struct{})
  1918. }
  1919. for i := range ids {
  1920. m.wx_agent[ids[i]] = struct{}{}
  1921. }
  1922. }
  1923. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1924. func (m *AgentMutation) ClearWxAgent() {
  1925. m.clearedwx_agent = true
  1926. }
  1927. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1928. func (m *AgentMutation) WxAgentCleared() bool {
  1929. return m.clearedwx_agent
  1930. }
  1931. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1932. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  1933. if m.removedwx_agent == nil {
  1934. m.removedwx_agent = make(map[uint64]struct{})
  1935. }
  1936. for i := range ids {
  1937. delete(m.wx_agent, ids[i])
  1938. m.removedwx_agent[ids[i]] = struct{}{}
  1939. }
  1940. }
  1941. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1942. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  1943. for id := range m.removedwx_agent {
  1944. ids = append(ids, id)
  1945. }
  1946. return
  1947. }
  1948. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1949. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  1950. for id := range m.wx_agent {
  1951. ids = append(ids, id)
  1952. }
  1953. return
  1954. }
  1955. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1956. func (m *AgentMutation) ResetWxAgent() {
  1957. m.wx_agent = nil
  1958. m.clearedwx_agent = false
  1959. m.removedwx_agent = nil
  1960. }
  1961. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  1962. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  1963. if m.token_agent == nil {
  1964. m.token_agent = make(map[uint64]struct{})
  1965. }
  1966. for i := range ids {
  1967. m.token_agent[ids[i]] = struct{}{}
  1968. }
  1969. }
  1970. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  1971. func (m *AgentMutation) ClearTokenAgent() {
  1972. m.clearedtoken_agent = true
  1973. }
  1974. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  1975. func (m *AgentMutation) TokenAgentCleared() bool {
  1976. return m.clearedtoken_agent
  1977. }
  1978. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  1979. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  1980. if m.removedtoken_agent == nil {
  1981. m.removedtoken_agent = make(map[uint64]struct{})
  1982. }
  1983. for i := range ids {
  1984. delete(m.token_agent, ids[i])
  1985. m.removedtoken_agent[ids[i]] = struct{}{}
  1986. }
  1987. }
  1988. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  1989. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  1990. for id := range m.removedtoken_agent {
  1991. ids = append(ids, id)
  1992. }
  1993. return
  1994. }
  1995. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  1996. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  1997. for id := range m.token_agent {
  1998. ids = append(ids, id)
  1999. }
  2000. return
  2001. }
  2002. // ResetTokenAgent resets all changes to the "token_agent" edge.
  2003. func (m *AgentMutation) ResetTokenAgent() {
  2004. m.token_agent = nil
  2005. m.clearedtoken_agent = false
  2006. m.removedtoken_agent = nil
  2007. }
  2008. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  2009. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  2010. if m.wa_agent == nil {
  2011. m.wa_agent = make(map[uint64]struct{})
  2012. }
  2013. for i := range ids {
  2014. m.wa_agent[ids[i]] = struct{}{}
  2015. }
  2016. }
  2017. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  2018. func (m *AgentMutation) ClearWaAgent() {
  2019. m.clearedwa_agent = true
  2020. }
  2021. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  2022. func (m *AgentMutation) WaAgentCleared() bool {
  2023. return m.clearedwa_agent
  2024. }
  2025. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  2026. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  2027. if m.removedwa_agent == nil {
  2028. m.removedwa_agent = make(map[uint64]struct{})
  2029. }
  2030. for i := range ids {
  2031. delete(m.wa_agent, ids[i])
  2032. m.removedwa_agent[ids[i]] = struct{}{}
  2033. }
  2034. }
  2035. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  2036. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  2037. for id := range m.removedwa_agent {
  2038. ids = append(ids, id)
  2039. }
  2040. return
  2041. }
  2042. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  2043. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  2044. for id := range m.wa_agent {
  2045. ids = append(ids, id)
  2046. }
  2047. return
  2048. }
  2049. // ResetWaAgent resets all changes to the "wa_agent" edge.
  2050. func (m *AgentMutation) ResetWaAgent() {
  2051. m.wa_agent = nil
  2052. m.clearedwa_agent = false
  2053. m.removedwa_agent = nil
  2054. }
  2055. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  2056. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  2057. if m.xjs_agent == nil {
  2058. m.xjs_agent = make(map[uint64]struct{})
  2059. }
  2060. for i := range ids {
  2061. m.xjs_agent[ids[i]] = struct{}{}
  2062. }
  2063. }
  2064. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  2065. func (m *AgentMutation) ClearXjsAgent() {
  2066. m.clearedxjs_agent = true
  2067. }
  2068. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  2069. func (m *AgentMutation) XjsAgentCleared() bool {
  2070. return m.clearedxjs_agent
  2071. }
  2072. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  2073. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  2074. if m.removedxjs_agent == nil {
  2075. m.removedxjs_agent = make(map[uint64]struct{})
  2076. }
  2077. for i := range ids {
  2078. delete(m.xjs_agent, ids[i])
  2079. m.removedxjs_agent[ids[i]] = struct{}{}
  2080. }
  2081. }
  2082. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  2083. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  2084. for id := range m.removedxjs_agent {
  2085. ids = append(ids, id)
  2086. }
  2087. return
  2088. }
  2089. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  2090. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  2091. for id := range m.xjs_agent {
  2092. ids = append(ids, id)
  2093. }
  2094. return
  2095. }
  2096. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  2097. func (m *AgentMutation) ResetXjsAgent() {
  2098. m.xjs_agent = nil
  2099. m.clearedxjs_agent = false
  2100. m.removedxjs_agent = nil
  2101. }
  2102. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  2103. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  2104. if m.key_agent == nil {
  2105. m.key_agent = make(map[uint64]struct{})
  2106. }
  2107. for i := range ids {
  2108. m.key_agent[ids[i]] = struct{}{}
  2109. }
  2110. }
  2111. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  2112. func (m *AgentMutation) ClearKeyAgent() {
  2113. m.clearedkey_agent = true
  2114. }
  2115. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  2116. func (m *AgentMutation) KeyAgentCleared() bool {
  2117. return m.clearedkey_agent
  2118. }
  2119. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  2120. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  2121. if m.removedkey_agent == nil {
  2122. m.removedkey_agent = make(map[uint64]struct{})
  2123. }
  2124. for i := range ids {
  2125. delete(m.key_agent, ids[i])
  2126. m.removedkey_agent[ids[i]] = struct{}{}
  2127. }
  2128. }
  2129. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  2130. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  2131. for id := range m.removedkey_agent {
  2132. ids = append(ids, id)
  2133. }
  2134. return
  2135. }
  2136. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  2137. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  2138. for id := range m.key_agent {
  2139. ids = append(ids, id)
  2140. }
  2141. return
  2142. }
  2143. // ResetKeyAgent resets all changes to the "key_agent" edge.
  2144. func (m *AgentMutation) ResetKeyAgent() {
  2145. m.key_agent = nil
  2146. m.clearedkey_agent = false
  2147. m.removedkey_agent = nil
  2148. }
  2149. // Where appends a list predicates to the AgentMutation builder.
  2150. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  2151. m.predicates = append(m.predicates, ps...)
  2152. }
  2153. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  2154. // users can use type-assertion to append predicates that do not depend on any generated package.
  2155. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  2156. p := make([]predicate.Agent, len(ps))
  2157. for i := range ps {
  2158. p[i] = ps[i]
  2159. }
  2160. m.Where(p...)
  2161. }
  2162. // Op returns the operation name.
  2163. func (m *AgentMutation) Op() Op {
  2164. return m.op
  2165. }
  2166. // SetOp allows setting the mutation operation.
  2167. func (m *AgentMutation) SetOp(op Op) {
  2168. m.op = op
  2169. }
  2170. // Type returns the node type of this mutation (Agent).
  2171. func (m *AgentMutation) Type() string {
  2172. return m.typ
  2173. }
  2174. // Fields returns all fields that were changed during this mutation. Note that in
  2175. // order to get all numeric fields that were incremented/decremented, call
  2176. // AddedFields().
  2177. func (m *AgentMutation) Fields() []string {
  2178. fields := make([]string, 0, 15)
  2179. if m.created_at != nil {
  2180. fields = append(fields, agent.FieldCreatedAt)
  2181. }
  2182. if m.updated_at != nil {
  2183. fields = append(fields, agent.FieldUpdatedAt)
  2184. }
  2185. if m.deleted_at != nil {
  2186. fields = append(fields, agent.FieldDeletedAt)
  2187. }
  2188. if m.name != nil {
  2189. fields = append(fields, agent.FieldName)
  2190. }
  2191. if m.role != nil {
  2192. fields = append(fields, agent.FieldRole)
  2193. }
  2194. if m.status != nil {
  2195. fields = append(fields, agent.FieldStatus)
  2196. }
  2197. if m.background != nil {
  2198. fields = append(fields, agent.FieldBackground)
  2199. }
  2200. if m.examples != nil {
  2201. fields = append(fields, agent.FieldExamples)
  2202. }
  2203. if m.organization_id != nil {
  2204. fields = append(fields, agent.FieldOrganizationID)
  2205. }
  2206. if m.dataset_id != nil {
  2207. fields = append(fields, agent.FieldDatasetID)
  2208. }
  2209. if m.collection_id != nil {
  2210. fields = append(fields, agent.FieldCollectionID)
  2211. }
  2212. if m.model != nil {
  2213. fields = append(fields, agent.FieldModel)
  2214. }
  2215. if m.api_base != nil {
  2216. fields = append(fields, agent.FieldAPIBase)
  2217. }
  2218. if m.api_key != nil {
  2219. fields = append(fields, agent.FieldAPIKey)
  2220. }
  2221. if m._type != nil {
  2222. fields = append(fields, agent.FieldType)
  2223. }
  2224. return fields
  2225. }
  2226. // Field returns the value of a field with the given name. The second boolean
  2227. // return value indicates that this field was not set, or was not defined in the
  2228. // schema.
  2229. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  2230. switch name {
  2231. case agent.FieldCreatedAt:
  2232. return m.CreatedAt()
  2233. case agent.FieldUpdatedAt:
  2234. return m.UpdatedAt()
  2235. case agent.FieldDeletedAt:
  2236. return m.DeletedAt()
  2237. case agent.FieldName:
  2238. return m.Name()
  2239. case agent.FieldRole:
  2240. return m.Role()
  2241. case agent.FieldStatus:
  2242. return m.Status()
  2243. case agent.FieldBackground:
  2244. return m.Background()
  2245. case agent.FieldExamples:
  2246. return m.Examples()
  2247. case agent.FieldOrganizationID:
  2248. return m.OrganizationID()
  2249. case agent.FieldDatasetID:
  2250. return m.DatasetID()
  2251. case agent.FieldCollectionID:
  2252. return m.CollectionID()
  2253. case agent.FieldModel:
  2254. return m.Model()
  2255. case agent.FieldAPIBase:
  2256. return m.APIBase()
  2257. case agent.FieldAPIKey:
  2258. return m.APIKey()
  2259. case agent.FieldType:
  2260. return m.GetType()
  2261. }
  2262. return nil, false
  2263. }
  2264. // OldField returns the old value of the field from the database. An error is
  2265. // returned if the mutation operation is not UpdateOne, or the query to the
  2266. // database failed.
  2267. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2268. switch name {
  2269. case agent.FieldCreatedAt:
  2270. return m.OldCreatedAt(ctx)
  2271. case agent.FieldUpdatedAt:
  2272. return m.OldUpdatedAt(ctx)
  2273. case agent.FieldDeletedAt:
  2274. return m.OldDeletedAt(ctx)
  2275. case agent.FieldName:
  2276. return m.OldName(ctx)
  2277. case agent.FieldRole:
  2278. return m.OldRole(ctx)
  2279. case agent.FieldStatus:
  2280. return m.OldStatus(ctx)
  2281. case agent.FieldBackground:
  2282. return m.OldBackground(ctx)
  2283. case agent.FieldExamples:
  2284. return m.OldExamples(ctx)
  2285. case agent.FieldOrganizationID:
  2286. return m.OldOrganizationID(ctx)
  2287. case agent.FieldDatasetID:
  2288. return m.OldDatasetID(ctx)
  2289. case agent.FieldCollectionID:
  2290. return m.OldCollectionID(ctx)
  2291. case agent.FieldModel:
  2292. return m.OldModel(ctx)
  2293. case agent.FieldAPIBase:
  2294. return m.OldAPIBase(ctx)
  2295. case agent.FieldAPIKey:
  2296. return m.OldAPIKey(ctx)
  2297. case agent.FieldType:
  2298. return m.OldType(ctx)
  2299. }
  2300. return nil, fmt.Errorf("unknown Agent field %s", name)
  2301. }
  2302. // SetField sets the value of a field with the given name. It returns an error if
  2303. // the field is not defined in the schema, or if the type mismatched the field
  2304. // type.
  2305. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  2306. switch name {
  2307. case agent.FieldCreatedAt:
  2308. v, ok := value.(time.Time)
  2309. if !ok {
  2310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2311. }
  2312. m.SetCreatedAt(v)
  2313. return nil
  2314. case agent.FieldUpdatedAt:
  2315. v, ok := value.(time.Time)
  2316. if !ok {
  2317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2318. }
  2319. m.SetUpdatedAt(v)
  2320. return nil
  2321. case agent.FieldDeletedAt:
  2322. v, ok := value.(time.Time)
  2323. if !ok {
  2324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2325. }
  2326. m.SetDeletedAt(v)
  2327. return nil
  2328. case agent.FieldName:
  2329. v, ok := value.(string)
  2330. if !ok {
  2331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2332. }
  2333. m.SetName(v)
  2334. return nil
  2335. case agent.FieldRole:
  2336. v, ok := value.(string)
  2337. if !ok {
  2338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2339. }
  2340. m.SetRole(v)
  2341. return nil
  2342. case agent.FieldStatus:
  2343. v, ok := value.(int)
  2344. if !ok {
  2345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2346. }
  2347. m.SetStatus(v)
  2348. return nil
  2349. case agent.FieldBackground:
  2350. v, ok := value.(string)
  2351. if !ok {
  2352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2353. }
  2354. m.SetBackground(v)
  2355. return nil
  2356. case agent.FieldExamples:
  2357. v, ok := value.(string)
  2358. if !ok {
  2359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2360. }
  2361. m.SetExamples(v)
  2362. return nil
  2363. case agent.FieldOrganizationID:
  2364. v, ok := value.(uint64)
  2365. if !ok {
  2366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2367. }
  2368. m.SetOrganizationID(v)
  2369. return nil
  2370. case agent.FieldDatasetID:
  2371. v, ok := value.(string)
  2372. if !ok {
  2373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2374. }
  2375. m.SetDatasetID(v)
  2376. return nil
  2377. case agent.FieldCollectionID:
  2378. v, ok := value.(string)
  2379. if !ok {
  2380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2381. }
  2382. m.SetCollectionID(v)
  2383. return nil
  2384. case agent.FieldModel:
  2385. v, ok := value.(string)
  2386. if !ok {
  2387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2388. }
  2389. m.SetModel(v)
  2390. return nil
  2391. case agent.FieldAPIBase:
  2392. v, ok := value.(string)
  2393. if !ok {
  2394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2395. }
  2396. m.SetAPIBase(v)
  2397. return nil
  2398. case agent.FieldAPIKey:
  2399. v, ok := value.(string)
  2400. if !ok {
  2401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2402. }
  2403. m.SetAPIKey(v)
  2404. return nil
  2405. case agent.FieldType:
  2406. v, ok := value.(int)
  2407. if !ok {
  2408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2409. }
  2410. m.SetType(v)
  2411. return nil
  2412. }
  2413. return fmt.Errorf("unknown Agent field %s", name)
  2414. }
  2415. // AddedFields returns all numeric fields that were incremented/decremented during
  2416. // this mutation.
  2417. func (m *AgentMutation) AddedFields() []string {
  2418. var fields []string
  2419. if m.addstatus != nil {
  2420. fields = append(fields, agent.FieldStatus)
  2421. }
  2422. if m.addorganization_id != nil {
  2423. fields = append(fields, agent.FieldOrganizationID)
  2424. }
  2425. if m.add_type != nil {
  2426. fields = append(fields, agent.FieldType)
  2427. }
  2428. return fields
  2429. }
  2430. // AddedField returns the numeric value that was incremented/decremented on a field
  2431. // with the given name. The second boolean return value indicates that this field
  2432. // was not set, or was not defined in the schema.
  2433. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  2434. switch name {
  2435. case agent.FieldStatus:
  2436. return m.AddedStatus()
  2437. case agent.FieldOrganizationID:
  2438. return m.AddedOrganizationID()
  2439. case agent.FieldType:
  2440. return m.AddedType()
  2441. }
  2442. return nil, false
  2443. }
  2444. // AddField adds the value to the field with the given name. It returns an error if
  2445. // the field is not defined in the schema, or if the type mismatched the field
  2446. // type.
  2447. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  2448. switch name {
  2449. case agent.FieldStatus:
  2450. v, ok := value.(int)
  2451. if !ok {
  2452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2453. }
  2454. m.AddStatus(v)
  2455. return nil
  2456. case agent.FieldOrganizationID:
  2457. v, ok := value.(int64)
  2458. if !ok {
  2459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2460. }
  2461. m.AddOrganizationID(v)
  2462. return nil
  2463. case agent.FieldType:
  2464. v, ok := value.(int)
  2465. if !ok {
  2466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2467. }
  2468. m.AddType(v)
  2469. return nil
  2470. }
  2471. return fmt.Errorf("unknown Agent numeric field %s", name)
  2472. }
  2473. // ClearedFields returns all nullable fields that were cleared during this
  2474. // mutation.
  2475. func (m *AgentMutation) ClearedFields() []string {
  2476. var fields []string
  2477. if m.FieldCleared(agent.FieldDeletedAt) {
  2478. fields = append(fields, agent.FieldDeletedAt)
  2479. }
  2480. if m.FieldCleared(agent.FieldRole) {
  2481. fields = append(fields, agent.FieldRole)
  2482. }
  2483. if m.FieldCleared(agent.FieldStatus) {
  2484. fields = append(fields, agent.FieldStatus)
  2485. }
  2486. if m.FieldCleared(agent.FieldBackground) {
  2487. fields = append(fields, agent.FieldBackground)
  2488. }
  2489. if m.FieldCleared(agent.FieldExamples) {
  2490. fields = append(fields, agent.FieldExamples)
  2491. }
  2492. if m.FieldCleared(agent.FieldModel) {
  2493. fields = append(fields, agent.FieldModel)
  2494. }
  2495. if m.FieldCleared(agent.FieldAPIBase) {
  2496. fields = append(fields, agent.FieldAPIBase)
  2497. }
  2498. if m.FieldCleared(agent.FieldAPIKey) {
  2499. fields = append(fields, agent.FieldAPIKey)
  2500. }
  2501. if m.FieldCleared(agent.FieldType) {
  2502. fields = append(fields, agent.FieldType)
  2503. }
  2504. return fields
  2505. }
  2506. // FieldCleared returns a boolean indicating if a field with the given name was
  2507. // cleared in this mutation.
  2508. func (m *AgentMutation) FieldCleared(name string) bool {
  2509. _, ok := m.clearedFields[name]
  2510. return ok
  2511. }
  2512. // ClearField clears the value of the field with the given name. It returns an
  2513. // error if the field is not defined in the schema.
  2514. func (m *AgentMutation) ClearField(name string) error {
  2515. switch name {
  2516. case agent.FieldDeletedAt:
  2517. m.ClearDeletedAt()
  2518. return nil
  2519. case agent.FieldRole:
  2520. m.ClearRole()
  2521. return nil
  2522. case agent.FieldStatus:
  2523. m.ClearStatus()
  2524. return nil
  2525. case agent.FieldBackground:
  2526. m.ClearBackground()
  2527. return nil
  2528. case agent.FieldExamples:
  2529. m.ClearExamples()
  2530. return nil
  2531. case agent.FieldModel:
  2532. m.ClearModel()
  2533. return nil
  2534. case agent.FieldAPIBase:
  2535. m.ClearAPIBase()
  2536. return nil
  2537. case agent.FieldAPIKey:
  2538. m.ClearAPIKey()
  2539. return nil
  2540. case agent.FieldType:
  2541. m.ClearType()
  2542. return nil
  2543. }
  2544. return fmt.Errorf("unknown Agent nullable field %s", name)
  2545. }
  2546. // ResetField resets all changes in the mutation for the field with the given name.
  2547. // It returns an error if the field is not defined in the schema.
  2548. func (m *AgentMutation) ResetField(name string) error {
  2549. switch name {
  2550. case agent.FieldCreatedAt:
  2551. m.ResetCreatedAt()
  2552. return nil
  2553. case agent.FieldUpdatedAt:
  2554. m.ResetUpdatedAt()
  2555. return nil
  2556. case agent.FieldDeletedAt:
  2557. m.ResetDeletedAt()
  2558. return nil
  2559. case agent.FieldName:
  2560. m.ResetName()
  2561. return nil
  2562. case agent.FieldRole:
  2563. m.ResetRole()
  2564. return nil
  2565. case agent.FieldStatus:
  2566. m.ResetStatus()
  2567. return nil
  2568. case agent.FieldBackground:
  2569. m.ResetBackground()
  2570. return nil
  2571. case agent.FieldExamples:
  2572. m.ResetExamples()
  2573. return nil
  2574. case agent.FieldOrganizationID:
  2575. m.ResetOrganizationID()
  2576. return nil
  2577. case agent.FieldDatasetID:
  2578. m.ResetDatasetID()
  2579. return nil
  2580. case agent.FieldCollectionID:
  2581. m.ResetCollectionID()
  2582. return nil
  2583. case agent.FieldModel:
  2584. m.ResetModel()
  2585. return nil
  2586. case agent.FieldAPIBase:
  2587. m.ResetAPIBase()
  2588. return nil
  2589. case agent.FieldAPIKey:
  2590. m.ResetAPIKey()
  2591. return nil
  2592. case agent.FieldType:
  2593. m.ResetType()
  2594. return nil
  2595. }
  2596. return fmt.Errorf("unknown Agent field %s", name)
  2597. }
  2598. // AddedEdges returns all edge names that were set/added in this mutation.
  2599. func (m *AgentMutation) AddedEdges() []string {
  2600. edges := make([]string, 0, 5)
  2601. if m.wx_agent != nil {
  2602. edges = append(edges, agent.EdgeWxAgent)
  2603. }
  2604. if m.token_agent != nil {
  2605. edges = append(edges, agent.EdgeTokenAgent)
  2606. }
  2607. if m.wa_agent != nil {
  2608. edges = append(edges, agent.EdgeWaAgent)
  2609. }
  2610. if m.xjs_agent != nil {
  2611. edges = append(edges, agent.EdgeXjsAgent)
  2612. }
  2613. if m.key_agent != nil {
  2614. edges = append(edges, agent.EdgeKeyAgent)
  2615. }
  2616. return edges
  2617. }
  2618. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2619. // name in this mutation.
  2620. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  2621. switch name {
  2622. case agent.EdgeWxAgent:
  2623. ids := make([]ent.Value, 0, len(m.wx_agent))
  2624. for id := range m.wx_agent {
  2625. ids = append(ids, id)
  2626. }
  2627. return ids
  2628. case agent.EdgeTokenAgent:
  2629. ids := make([]ent.Value, 0, len(m.token_agent))
  2630. for id := range m.token_agent {
  2631. ids = append(ids, id)
  2632. }
  2633. return ids
  2634. case agent.EdgeWaAgent:
  2635. ids := make([]ent.Value, 0, len(m.wa_agent))
  2636. for id := range m.wa_agent {
  2637. ids = append(ids, id)
  2638. }
  2639. return ids
  2640. case agent.EdgeXjsAgent:
  2641. ids := make([]ent.Value, 0, len(m.xjs_agent))
  2642. for id := range m.xjs_agent {
  2643. ids = append(ids, id)
  2644. }
  2645. return ids
  2646. case agent.EdgeKeyAgent:
  2647. ids := make([]ent.Value, 0, len(m.key_agent))
  2648. for id := range m.key_agent {
  2649. ids = append(ids, id)
  2650. }
  2651. return ids
  2652. }
  2653. return nil
  2654. }
  2655. // RemovedEdges returns all edge names that were removed in this mutation.
  2656. func (m *AgentMutation) RemovedEdges() []string {
  2657. edges := make([]string, 0, 5)
  2658. if m.removedwx_agent != nil {
  2659. edges = append(edges, agent.EdgeWxAgent)
  2660. }
  2661. if m.removedtoken_agent != nil {
  2662. edges = append(edges, agent.EdgeTokenAgent)
  2663. }
  2664. if m.removedwa_agent != nil {
  2665. edges = append(edges, agent.EdgeWaAgent)
  2666. }
  2667. if m.removedxjs_agent != nil {
  2668. edges = append(edges, agent.EdgeXjsAgent)
  2669. }
  2670. if m.removedkey_agent != nil {
  2671. edges = append(edges, agent.EdgeKeyAgent)
  2672. }
  2673. return edges
  2674. }
  2675. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2676. // the given name in this mutation.
  2677. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  2678. switch name {
  2679. case agent.EdgeWxAgent:
  2680. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2681. for id := range m.removedwx_agent {
  2682. ids = append(ids, id)
  2683. }
  2684. return ids
  2685. case agent.EdgeTokenAgent:
  2686. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  2687. for id := range m.removedtoken_agent {
  2688. ids = append(ids, id)
  2689. }
  2690. return ids
  2691. case agent.EdgeWaAgent:
  2692. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  2693. for id := range m.removedwa_agent {
  2694. ids = append(ids, id)
  2695. }
  2696. return ids
  2697. case agent.EdgeXjsAgent:
  2698. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  2699. for id := range m.removedxjs_agent {
  2700. ids = append(ids, id)
  2701. }
  2702. return ids
  2703. case agent.EdgeKeyAgent:
  2704. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  2705. for id := range m.removedkey_agent {
  2706. ids = append(ids, id)
  2707. }
  2708. return ids
  2709. }
  2710. return nil
  2711. }
  2712. // ClearedEdges returns all edge names that were cleared in this mutation.
  2713. func (m *AgentMutation) ClearedEdges() []string {
  2714. edges := make([]string, 0, 5)
  2715. if m.clearedwx_agent {
  2716. edges = append(edges, agent.EdgeWxAgent)
  2717. }
  2718. if m.clearedtoken_agent {
  2719. edges = append(edges, agent.EdgeTokenAgent)
  2720. }
  2721. if m.clearedwa_agent {
  2722. edges = append(edges, agent.EdgeWaAgent)
  2723. }
  2724. if m.clearedxjs_agent {
  2725. edges = append(edges, agent.EdgeXjsAgent)
  2726. }
  2727. if m.clearedkey_agent {
  2728. edges = append(edges, agent.EdgeKeyAgent)
  2729. }
  2730. return edges
  2731. }
  2732. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2733. // was cleared in this mutation.
  2734. func (m *AgentMutation) EdgeCleared(name string) bool {
  2735. switch name {
  2736. case agent.EdgeWxAgent:
  2737. return m.clearedwx_agent
  2738. case agent.EdgeTokenAgent:
  2739. return m.clearedtoken_agent
  2740. case agent.EdgeWaAgent:
  2741. return m.clearedwa_agent
  2742. case agent.EdgeXjsAgent:
  2743. return m.clearedxjs_agent
  2744. case agent.EdgeKeyAgent:
  2745. return m.clearedkey_agent
  2746. }
  2747. return false
  2748. }
  2749. // ClearEdge clears the value of the edge with the given name. It returns an error
  2750. // if that edge is not defined in the schema.
  2751. func (m *AgentMutation) ClearEdge(name string) error {
  2752. switch name {
  2753. }
  2754. return fmt.Errorf("unknown Agent unique edge %s", name)
  2755. }
  2756. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2757. // It returns an error if the edge is not defined in the schema.
  2758. func (m *AgentMutation) ResetEdge(name string) error {
  2759. switch name {
  2760. case agent.EdgeWxAgent:
  2761. m.ResetWxAgent()
  2762. return nil
  2763. case agent.EdgeTokenAgent:
  2764. m.ResetTokenAgent()
  2765. return nil
  2766. case agent.EdgeWaAgent:
  2767. m.ResetWaAgent()
  2768. return nil
  2769. case agent.EdgeXjsAgent:
  2770. m.ResetXjsAgent()
  2771. return nil
  2772. case agent.EdgeKeyAgent:
  2773. m.ResetKeyAgent()
  2774. return nil
  2775. }
  2776. return fmt.Errorf("unknown Agent edge %s", name)
  2777. }
  2778. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  2779. type AgentBaseMutation struct {
  2780. config
  2781. op Op
  2782. typ string
  2783. id *string
  2784. q *string
  2785. a *string
  2786. chunk_index *uint64
  2787. addchunk_index *int64
  2788. indexes *[]string
  2789. appendindexes []string
  2790. dataset_id *string
  2791. collection_id *string
  2792. source_name *string
  2793. can_write *[]bool
  2794. appendcan_write []bool
  2795. is_owner *[]bool
  2796. appendis_owner []bool
  2797. clearedFields map[string]struct{}
  2798. wx_agent map[uint64]struct{}
  2799. removedwx_agent map[uint64]struct{}
  2800. clearedwx_agent bool
  2801. done bool
  2802. oldValue func(context.Context) (*AgentBase, error)
  2803. predicates []predicate.AgentBase
  2804. }
  2805. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  2806. // agentbaseOption allows management of the mutation configuration using functional options.
  2807. type agentbaseOption func(*AgentBaseMutation)
  2808. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  2809. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  2810. m := &AgentBaseMutation{
  2811. config: c,
  2812. op: op,
  2813. typ: TypeAgentBase,
  2814. clearedFields: make(map[string]struct{}),
  2815. }
  2816. for _, opt := range opts {
  2817. opt(m)
  2818. }
  2819. return m
  2820. }
  2821. // withAgentBaseID sets the ID field of the mutation.
  2822. func withAgentBaseID(id string) agentbaseOption {
  2823. return func(m *AgentBaseMutation) {
  2824. var (
  2825. err error
  2826. once sync.Once
  2827. value *AgentBase
  2828. )
  2829. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  2830. once.Do(func() {
  2831. if m.done {
  2832. err = errors.New("querying old values post mutation is not allowed")
  2833. } else {
  2834. value, err = m.Client().AgentBase.Get(ctx, id)
  2835. }
  2836. })
  2837. return value, err
  2838. }
  2839. m.id = &id
  2840. }
  2841. }
  2842. // withAgentBase sets the old AgentBase of the mutation.
  2843. func withAgentBase(node *AgentBase) agentbaseOption {
  2844. return func(m *AgentBaseMutation) {
  2845. m.oldValue = func(context.Context) (*AgentBase, error) {
  2846. return node, nil
  2847. }
  2848. m.id = &node.ID
  2849. }
  2850. }
  2851. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2852. // executed in a transaction (ent.Tx), a transactional client is returned.
  2853. func (m AgentBaseMutation) Client() *Client {
  2854. client := &Client{config: m.config}
  2855. client.init()
  2856. return client
  2857. }
  2858. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2859. // it returns an error otherwise.
  2860. func (m AgentBaseMutation) Tx() (*Tx, error) {
  2861. if _, ok := m.driver.(*txDriver); !ok {
  2862. return nil, errors.New("ent: mutation is not running in a transaction")
  2863. }
  2864. tx := &Tx{config: m.config}
  2865. tx.init()
  2866. return tx, nil
  2867. }
  2868. // SetID sets the value of the id field. Note that this
  2869. // operation is only accepted on creation of AgentBase entities.
  2870. func (m *AgentBaseMutation) SetID(id string) {
  2871. m.id = &id
  2872. }
  2873. // ID returns the ID value in the mutation. Note that the ID is only available
  2874. // if it was provided to the builder or after it was returned from the database.
  2875. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  2876. if m.id == nil {
  2877. return
  2878. }
  2879. return *m.id, true
  2880. }
  2881. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2882. // That means, if the mutation is applied within a transaction with an isolation level such
  2883. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2884. // or updated by the mutation.
  2885. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  2886. switch {
  2887. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2888. id, exists := m.ID()
  2889. if exists {
  2890. return []string{id}, nil
  2891. }
  2892. fallthrough
  2893. case m.op.Is(OpUpdate | OpDelete):
  2894. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  2895. default:
  2896. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2897. }
  2898. }
  2899. // SetQ sets the "q" field.
  2900. func (m *AgentBaseMutation) SetQ(s string) {
  2901. m.q = &s
  2902. }
  2903. // Q returns the value of the "q" field in the mutation.
  2904. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  2905. v := m.q
  2906. if v == nil {
  2907. return
  2908. }
  2909. return *v, true
  2910. }
  2911. // OldQ returns the old "q" field's value of the AgentBase entity.
  2912. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2914. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  2915. if !m.op.Is(OpUpdateOne) {
  2916. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  2917. }
  2918. if m.id == nil || m.oldValue == nil {
  2919. return v, errors.New("OldQ requires an ID field in the mutation")
  2920. }
  2921. oldValue, err := m.oldValue(ctx)
  2922. if err != nil {
  2923. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  2924. }
  2925. return oldValue.Q, nil
  2926. }
  2927. // ClearQ clears the value of the "q" field.
  2928. func (m *AgentBaseMutation) ClearQ() {
  2929. m.q = nil
  2930. m.clearedFields[agentbase.FieldQ] = struct{}{}
  2931. }
  2932. // QCleared returns if the "q" field was cleared in this mutation.
  2933. func (m *AgentBaseMutation) QCleared() bool {
  2934. _, ok := m.clearedFields[agentbase.FieldQ]
  2935. return ok
  2936. }
  2937. // ResetQ resets all changes to the "q" field.
  2938. func (m *AgentBaseMutation) ResetQ() {
  2939. m.q = nil
  2940. delete(m.clearedFields, agentbase.FieldQ)
  2941. }
  2942. // SetA sets the "a" field.
  2943. func (m *AgentBaseMutation) SetA(s string) {
  2944. m.a = &s
  2945. }
  2946. // A returns the value of the "a" field in the mutation.
  2947. func (m *AgentBaseMutation) A() (r string, exists bool) {
  2948. v := m.a
  2949. if v == nil {
  2950. return
  2951. }
  2952. return *v, true
  2953. }
  2954. // OldA returns the old "a" field's value of the AgentBase entity.
  2955. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2957. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  2958. if !m.op.Is(OpUpdateOne) {
  2959. return v, errors.New("OldA is only allowed on UpdateOne operations")
  2960. }
  2961. if m.id == nil || m.oldValue == nil {
  2962. return v, errors.New("OldA requires an ID field in the mutation")
  2963. }
  2964. oldValue, err := m.oldValue(ctx)
  2965. if err != nil {
  2966. return v, fmt.Errorf("querying old value for OldA: %w", err)
  2967. }
  2968. return oldValue.A, nil
  2969. }
  2970. // ClearA clears the value of the "a" field.
  2971. func (m *AgentBaseMutation) ClearA() {
  2972. m.a = nil
  2973. m.clearedFields[agentbase.FieldA] = struct{}{}
  2974. }
  2975. // ACleared returns if the "a" field was cleared in this mutation.
  2976. func (m *AgentBaseMutation) ACleared() bool {
  2977. _, ok := m.clearedFields[agentbase.FieldA]
  2978. return ok
  2979. }
  2980. // ResetA resets all changes to the "a" field.
  2981. func (m *AgentBaseMutation) ResetA() {
  2982. m.a = nil
  2983. delete(m.clearedFields, agentbase.FieldA)
  2984. }
  2985. // SetChunkIndex sets the "chunk_index" field.
  2986. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  2987. m.chunk_index = &u
  2988. m.addchunk_index = nil
  2989. }
  2990. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  2991. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  2992. v := m.chunk_index
  2993. if v == nil {
  2994. return
  2995. }
  2996. return *v, true
  2997. }
  2998. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  2999. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3001. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  3002. if !m.op.Is(OpUpdateOne) {
  3003. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  3004. }
  3005. if m.id == nil || m.oldValue == nil {
  3006. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  3007. }
  3008. oldValue, err := m.oldValue(ctx)
  3009. if err != nil {
  3010. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  3011. }
  3012. return oldValue.ChunkIndex, nil
  3013. }
  3014. // AddChunkIndex adds u to the "chunk_index" field.
  3015. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  3016. if m.addchunk_index != nil {
  3017. *m.addchunk_index += u
  3018. } else {
  3019. m.addchunk_index = &u
  3020. }
  3021. }
  3022. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  3023. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  3024. v := m.addchunk_index
  3025. if v == nil {
  3026. return
  3027. }
  3028. return *v, true
  3029. }
  3030. // ResetChunkIndex resets all changes to the "chunk_index" field.
  3031. func (m *AgentBaseMutation) ResetChunkIndex() {
  3032. m.chunk_index = nil
  3033. m.addchunk_index = nil
  3034. }
  3035. // SetIndexes sets the "indexes" field.
  3036. func (m *AgentBaseMutation) SetIndexes(s []string) {
  3037. m.indexes = &s
  3038. m.appendindexes = nil
  3039. }
  3040. // Indexes returns the value of the "indexes" field in the mutation.
  3041. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  3042. v := m.indexes
  3043. if v == nil {
  3044. return
  3045. }
  3046. return *v, true
  3047. }
  3048. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  3049. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3051. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  3052. if !m.op.Is(OpUpdateOne) {
  3053. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  3054. }
  3055. if m.id == nil || m.oldValue == nil {
  3056. return v, errors.New("OldIndexes requires an ID field in the mutation")
  3057. }
  3058. oldValue, err := m.oldValue(ctx)
  3059. if err != nil {
  3060. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  3061. }
  3062. return oldValue.Indexes, nil
  3063. }
  3064. // AppendIndexes adds s to the "indexes" field.
  3065. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  3066. m.appendindexes = append(m.appendindexes, s...)
  3067. }
  3068. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  3069. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  3070. if len(m.appendindexes) == 0 {
  3071. return nil, false
  3072. }
  3073. return m.appendindexes, true
  3074. }
  3075. // ClearIndexes clears the value of the "indexes" field.
  3076. func (m *AgentBaseMutation) ClearIndexes() {
  3077. m.indexes = nil
  3078. m.appendindexes = nil
  3079. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  3080. }
  3081. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  3082. func (m *AgentBaseMutation) IndexesCleared() bool {
  3083. _, ok := m.clearedFields[agentbase.FieldIndexes]
  3084. return ok
  3085. }
  3086. // ResetIndexes resets all changes to the "indexes" field.
  3087. func (m *AgentBaseMutation) ResetIndexes() {
  3088. m.indexes = nil
  3089. m.appendindexes = nil
  3090. delete(m.clearedFields, agentbase.FieldIndexes)
  3091. }
  3092. // SetDatasetID sets the "dataset_id" field.
  3093. func (m *AgentBaseMutation) SetDatasetID(s string) {
  3094. m.dataset_id = &s
  3095. }
  3096. // DatasetID returns the value of the "dataset_id" field in the mutation.
  3097. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  3098. v := m.dataset_id
  3099. if v == nil {
  3100. return
  3101. }
  3102. return *v, true
  3103. }
  3104. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  3105. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3107. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  3108. if !m.op.Is(OpUpdateOne) {
  3109. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  3110. }
  3111. if m.id == nil || m.oldValue == nil {
  3112. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  3113. }
  3114. oldValue, err := m.oldValue(ctx)
  3115. if err != nil {
  3116. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  3117. }
  3118. return oldValue.DatasetID, nil
  3119. }
  3120. // ClearDatasetID clears the value of the "dataset_id" field.
  3121. func (m *AgentBaseMutation) ClearDatasetID() {
  3122. m.dataset_id = nil
  3123. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  3124. }
  3125. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  3126. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  3127. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  3128. return ok
  3129. }
  3130. // ResetDatasetID resets all changes to the "dataset_id" field.
  3131. func (m *AgentBaseMutation) ResetDatasetID() {
  3132. m.dataset_id = nil
  3133. delete(m.clearedFields, agentbase.FieldDatasetID)
  3134. }
  3135. // SetCollectionID sets the "collection_id" field.
  3136. func (m *AgentBaseMutation) SetCollectionID(s string) {
  3137. m.collection_id = &s
  3138. }
  3139. // CollectionID returns the value of the "collection_id" field in the mutation.
  3140. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  3141. v := m.collection_id
  3142. if v == nil {
  3143. return
  3144. }
  3145. return *v, true
  3146. }
  3147. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  3148. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3150. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  3151. if !m.op.Is(OpUpdateOne) {
  3152. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  3153. }
  3154. if m.id == nil || m.oldValue == nil {
  3155. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  3156. }
  3157. oldValue, err := m.oldValue(ctx)
  3158. if err != nil {
  3159. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  3160. }
  3161. return oldValue.CollectionID, nil
  3162. }
  3163. // ClearCollectionID clears the value of the "collection_id" field.
  3164. func (m *AgentBaseMutation) ClearCollectionID() {
  3165. m.collection_id = nil
  3166. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  3167. }
  3168. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  3169. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  3170. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  3171. return ok
  3172. }
  3173. // ResetCollectionID resets all changes to the "collection_id" field.
  3174. func (m *AgentBaseMutation) ResetCollectionID() {
  3175. m.collection_id = nil
  3176. delete(m.clearedFields, agentbase.FieldCollectionID)
  3177. }
  3178. // SetSourceName sets the "source_name" field.
  3179. func (m *AgentBaseMutation) SetSourceName(s string) {
  3180. m.source_name = &s
  3181. }
  3182. // SourceName returns the value of the "source_name" field in the mutation.
  3183. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  3184. v := m.source_name
  3185. if v == nil {
  3186. return
  3187. }
  3188. return *v, true
  3189. }
  3190. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  3191. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3193. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  3194. if !m.op.Is(OpUpdateOne) {
  3195. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  3196. }
  3197. if m.id == nil || m.oldValue == nil {
  3198. return v, errors.New("OldSourceName requires an ID field in the mutation")
  3199. }
  3200. oldValue, err := m.oldValue(ctx)
  3201. if err != nil {
  3202. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  3203. }
  3204. return oldValue.SourceName, nil
  3205. }
  3206. // ClearSourceName clears the value of the "source_name" field.
  3207. func (m *AgentBaseMutation) ClearSourceName() {
  3208. m.source_name = nil
  3209. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  3210. }
  3211. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  3212. func (m *AgentBaseMutation) SourceNameCleared() bool {
  3213. _, ok := m.clearedFields[agentbase.FieldSourceName]
  3214. return ok
  3215. }
  3216. // ResetSourceName resets all changes to the "source_name" field.
  3217. func (m *AgentBaseMutation) ResetSourceName() {
  3218. m.source_name = nil
  3219. delete(m.clearedFields, agentbase.FieldSourceName)
  3220. }
  3221. // SetCanWrite sets the "can_write" field.
  3222. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  3223. m.can_write = &b
  3224. m.appendcan_write = nil
  3225. }
  3226. // CanWrite returns the value of the "can_write" field in the mutation.
  3227. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  3228. v := m.can_write
  3229. if v == nil {
  3230. return
  3231. }
  3232. return *v, true
  3233. }
  3234. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  3235. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3237. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  3238. if !m.op.Is(OpUpdateOne) {
  3239. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  3240. }
  3241. if m.id == nil || m.oldValue == nil {
  3242. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  3243. }
  3244. oldValue, err := m.oldValue(ctx)
  3245. if err != nil {
  3246. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  3247. }
  3248. return oldValue.CanWrite, nil
  3249. }
  3250. // AppendCanWrite adds b to the "can_write" field.
  3251. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  3252. m.appendcan_write = append(m.appendcan_write, b...)
  3253. }
  3254. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  3255. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  3256. if len(m.appendcan_write) == 0 {
  3257. return nil, false
  3258. }
  3259. return m.appendcan_write, true
  3260. }
  3261. // ClearCanWrite clears the value of the "can_write" field.
  3262. func (m *AgentBaseMutation) ClearCanWrite() {
  3263. m.can_write = nil
  3264. m.appendcan_write = nil
  3265. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  3266. }
  3267. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  3268. func (m *AgentBaseMutation) CanWriteCleared() bool {
  3269. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  3270. return ok
  3271. }
  3272. // ResetCanWrite resets all changes to the "can_write" field.
  3273. func (m *AgentBaseMutation) ResetCanWrite() {
  3274. m.can_write = nil
  3275. m.appendcan_write = nil
  3276. delete(m.clearedFields, agentbase.FieldCanWrite)
  3277. }
  3278. // SetIsOwner sets the "is_owner" field.
  3279. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  3280. m.is_owner = &b
  3281. m.appendis_owner = nil
  3282. }
  3283. // IsOwner returns the value of the "is_owner" field in the mutation.
  3284. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  3285. v := m.is_owner
  3286. if v == nil {
  3287. return
  3288. }
  3289. return *v, true
  3290. }
  3291. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  3292. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3294. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  3295. if !m.op.Is(OpUpdateOne) {
  3296. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  3297. }
  3298. if m.id == nil || m.oldValue == nil {
  3299. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  3300. }
  3301. oldValue, err := m.oldValue(ctx)
  3302. if err != nil {
  3303. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  3304. }
  3305. return oldValue.IsOwner, nil
  3306. }
  3307. // AppendIsOwner adds b to the "is_owner" field.
  3308. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  3309. m.appendis_owner = append(m.appendis_owner, b...)
  3310. }
  3311. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  3312. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  3313. if len(m.appendis_owner) == 0 {
  3314. return nil, false
  3315. }
  3316. return m.appendis_owner, true
  3317. }
  3318. // ClearIsOwner clears the value of the "is_owner" field.
  3319. func (m *AgentBaseMutation) ClearIsOwner() {
  3320. m.is_owner = nil
  3321. m.appendis_owner = nil
  3322. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  3323. }
  3324. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  3325. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  3326. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  3327. return ok
  3328. }
  3329. // ResetIsOwner resets all changes to the "is_owner" field.
  3330. func (m *AgentBaseMutation) ResetIsOwner() {
  3331. m.is_owner = nil
  3332. m.appendis_owner = nil
  3333. delete(m.clearedFields, agentbase.FieldIsOwner)
  3334. }
  3335. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  3336. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  3337. if m.wx_agent == nil {
  3338. m.wx_agent = make(map[uint64]struct{})
  3339. }
  3340. for i := range ids {
  3341. m.wx_agent[ids[i]] = struct{}{}
  3342. }
  3343. }
  3344. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  3345. func (m *AgentBaseMutation) ClearWxAgent() {
  3346. m.clearedwx_agent = true
  3347. }
  3348. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  3349. func (m *AgentBaseMutation) WxAgentCleared() bool {
  3350. return m.clearedwx_agent
  3351. }
  3352. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  3353. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  3354. if m.removedwx_agent == nil {
  3355. m.removedwx_agent = make(map[uint64]struct{})
  3356. }
  3357. for i := range ids {
  3358. delete(m.wx_agent, ids[i])
  3359. m.removedwx_agent[ids[i]] = struct{}{}
  3360. }
  3361. }
  3362. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  3363. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  3364. for id := range m.removedwx_agent {
  3365. ids = append(ids, id)
  3366. }
  3367. return
  3368. }
  3369. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  3370. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  3371. for id := range m.wx_agent {
  3372. ids = append(ids, id)
  3373. }
  3374. return
  3375. }
  3376. // ResetWxAgent resets all changes to the "wx_agent" edge.
  3377. func (m *AgentBaseMutation) ResetWxAgent() {
  3378. m.wx_agent = nil
  3379. m.clearedwx_agent = false
  3380. m.removedwx_agent = nil
  3381. }
  3382. // Where appends a list predicates to the AgentBaseMutation builder.
  3383. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  3384. m.predicates = append(m.predicates, ps...)
  3385. }
  3386. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  3387. // users can use type-assertion to append predicates that do not depend on any generated package.
  3388. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  3389. p := make([]predicate.AgentBase, len(ps))
  3390. for i := range ps {
  3391. p[i] = ps[i]
  3392. }
  3393. m.Where(p...)
  3394. }
  3395. // Op returns the operation name.
  3396. func (m *AgentBaseMutation) Op() Op {
  3397. return m.op
  3398. }
  3399. // SetOp allows setting the mutation operation.
  3400. func (m *AgentBaseMutation) SetOp(op Op) {
  3401. m.op = op
  3402. }
  3403. // Type returns the node type of this mutation (AgentBase).
  3404. func (m *AgentBaseMutation) Type() string {
  3405. return m.typ
  3406. }
  3407. // Fields returns all fields that were changed during this mutation. Note that in
  3408. // order to get all numeric fields that were incremented/decremented, call
  3409. // AddedFields().
  3410. func (m *AgentBaseMutation) Fields() []string {
  3411. fields := make([]string, 0, 9)
  3412. if m.q != nil {
  3413. fields = append(fields, agentbase.FieldQ)
  3414. }
  3415. if m.a != nil {
  3416. fields = append(fields, agentbase.FieldA)
  3417. }
  3418. if m.chunk_index != nil {
  3419. fields = append(fields, agentbase.FieldChunkIndex)
  3420. }
  3421. if m.indexes != nil {
  3422. fields = append(fields, agentbase.FieldIndexes)
  3423. }
  3424. if m.dataset_id != nil {
  3425. fields = append(fields, agentbase.FieldDatasetID)
  3426. }
  3427. if m.collection_id != nil {
  3428. fields = append(fields, agentbase.FieldCollectionID)
  3429. }
  3430. if m.source_name != nil {
  3431. fields = append(fields, agentbase.FieldSourceName)
  3432. }
  3433. if m.can_write != nil {
  3434. fields = append(fields, agentbase.FieldCanWrite)
  3435. }
  3436. if m.is_owner != nil {
  3437. fields = append(fields, agentbase.FieldIsOwner)
  3438. }
  3439. return fields
  3440. }
  3441. // Field returns the value of a field with the given name. The second boolean
  3442. // return value indicates that this field was not set, or was not defined in the
  3443. // schema.
  3444. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  3445. switch name {
  3446. case agentbase.FieldQ:
  3447. return m.Q()
  3448. case agentbase.FieldA:
  3449. return m.A()
  3450. case agentbase.FieldChunkIndex:
  3451. return m.ChunkIndex()
  3452. case agentbase.FieldIndexes:
  3453. return m.Indexes()
  3454. case agentbase.FieldDatasetID:
  3455. return m.DatasetID()
  3456. case agentbase.FieldCollectionID:
  3457. return m.CollectionID()
  3458. case agentbase.FieldSourceName:
  3459. return m.SourceName()
  3460. case agentbase.FieldCanWrite:
  3461. return m.CanWrite()
  3462. case agentbase.FieldIsOwner:
  3463. return m.IsOwner()
  3464. }
  3465. return nil, false
  3466. }
  3467. // OldField returns the old value of the field from the database. An error is
  3468. // returned if the mutation operation is not UpdateOne, or the query to the
  3469. // database failed.
  3470. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3471. switch name {
  3472. case agentbase.FieldQ:
  3473. return m.OldQ(ctx)
  3474. case agentbase.FieldA:
  3475. return m.OldA(ctx)
  3476. case agentbase.FieldChunkIndex:
  3477. return m.OldChunkIndex(ctx)
  3478. case agentbase.FieldIndexes:
  3479. return m.OldIndexes(ctx)
  3480. case agentbase.FieldDatasetID:
  3481. return m.OldDatasetID(ctx)
  3482. case agentbase.FieldCollectionID:
  3483. return m.OldCollectionID(ctx)
  3484. case agentbase.FieldSourceName:
  3485. return m.OldSourceName(ctx)
  3486. case agentbase.FieldCanWrite:
  3487. return m.OldCanWrite(ctx)
  3488. case agentbase.FieldIsOwner:
  3489. return m.OldIsOwner(ctx)
  3490. }
  3491. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  3492. }
  3493. // SetField sets the value of a field with the given name. It returns an error if
  3494. // the field is not defined in the schema, or if the type mismatched the field
  3495. // type.
  3496. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  3497. switch name {
  3498. case agentbase.FieldQ:
  3499. v, ok := value.(string)
  3500. if !ok {
  3501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3502. }
  3503. m.SetQ(v)
  3504. return nil
  3505. case agentbase.FieldA:
  3506. v, ok := value.(string)
  3507. if !ok {
  3508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3509. }
  3510. m.SetA(v)
  3511. return nil
  3512. case agentbase.FieldChunkIndex:
  3513. v, ok := value.(uint64)
  3514. if !ok {
  3515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3516. }
  3517. m.SetChunkIndex(v)
  3518. return nil
  3519. case agentbase.FieldIndexes:
  3520. v, ok := value.([]string)
  3521. if !ok {
  3522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3523. }
  3524. m.SetIndexes(v)
  3525. return nil
  3526. case agentbase.FieldDatasetID:
  3527. v, ok := value.(string)
  3528. if !ok {
  3529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3530. }
  3531. m.SetDatasetID(v)
  3532. return nil
  3533. case agentbase.FieldCollectionID:
  3534. v, ok := value.(string)
  3535. if !ok {
  3536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3537. }
  3538. m.SetCollectionID(v)
  3539. return nil
  3540. case agentbase.FieldSourceName:
  3541. v, ok := value.(string)
  3542. if !ok {
  3543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3544. }
  3545. m.SetSourceName(v)
  3546. return nil
  3547. case agentbase.FieldCanWrite:
  3548. v, ok := value.([]bool)
  3549. if !ok {
  3550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3551. }
  3552. m.SetCanWrite(v)
  3553. return nil
  3554. case agentbase.FieldIsOwner:
  3555. v, ok := value.([]bool)
  3556. if !ok {
  3557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3558. }
  3559. m.SetIsOwner(v)
  3560. return nil
  3561. }
  3562. return fmt.Errorf("unknown AgentBase field %s", name)
  3563. }
  3564. // AddedFields returns all numeric fields that were incremented/decremented during
  3565. // this mutation.
  3566. func (m *AgentBaseMutation) AddedFields() []string {
  3567. var fields []string
  3568. if m.addchunk_index != nil {
  3569. fields = append(fields, agentbase.FieldChunkIndex)
  3570. }
  3571. return fields
  3572. }
  3573. // AddedField returns the numeric value that was incremented/decremented on a field
  3574. // with the given name. The second boolean return value indicates that this field
  3575. // was not set, or was not defined in the schema.
  3576. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  3577. switch name {
  3578. case agentbase.FieldChunkIndex:
  3579. return m.AddedChunkIndex()
  3580. }
  3581. return nil, false
  3582. }
  3583. // AddField adds the value to the field with the given name. It returns an error if
  3584. // the field is not defined in the schema, or if the type mismatched the field
  3585. // type.
  3586. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  3587. switch name {
  3588. case agentbase.FieldChunkIndex:
  3589. v, ok := value.(int64)
  3590. if !ok {
  3591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3592. }
  3593. m.AddChunkIndex(v)
  3594. return nil
  3595. }
  3596. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  3597. }
  3598. // ClearedFields returns all nullable fields that were cleared during this
  3599. // mutation.
  3600. func (m *AgentBaseMutation) ClearedFields() []string {
  3601. var fields []string
  3602. if m.FieldCleared(agentbase.FieldQ) {
  3603. fields = append(fields, agentbase.FieldQ)
  3604. }
  3605. if m.FieldCleared(agentbase.FieldA) {
  3606. fields = append(fields, agentbase.FieldA)
  3607. }
  3608. if m.FieldCleared(agentbase.FieldIndexes) {
  3609. fields = append(fields, agentbase.FieldIndexes)
  3610. }
  3611. if m.FieldCleared(agentbase.FieldDatasetID) {
  3612. fields = append(fields, agentbase.FieldDatasetID)
  3613. }
  3614. if m.FieldCleared(agentbase.FieldCollectionID) {
  3615. fields = append(fields, agentbase.FieldCollectionID)
  3616. }
  3617. if m.FieldCleared(agentbase.FieldSourceName) {
  3618. fields = append(fields, agentbase.FieldSourceName)
  3619. }
  3620. if m.FieldCleared(agentbase.FieldCanWrite) {
  3621. fields = append(fields, agentbase.FieldCanWrite)
  3622. }
  3623. if m.FieldCleared(agentbase.FieldIsOwner) {
  3624. fields = append(fields, agentbase.FieldIsOwner)
  3625. }
  3626. return fields
  3627. }
  3628. // FieldCleared returns a boolean indicating if a field with the given name was
  3629. // cleared in this mutation.
  3630. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  3631. _, ok := m.clearedFields[name]
  3632. return ok
  3633. }
  3634. // ClearField clears the value of the field with the given name. It returns an
  3635. // error if the field is not defined in the schema.
  3636. func (m *AgentBaseMutation) ClearField(name string) error {
  3637. switch name {
  3638. case agentbase.FieldQ:
  3639. m.ClearQ()
  3640. return nil
  3641. case agentbase.FieldA:
  3642. m.ClearA()
  3643. return nil
  3644. case agentbase.FieldIndexes:
  3645. m.ClearIndexes()
  3646. return nil
  3647. case agentbase.FieldDatasetID:
  3648. m.ClearDatasetID()
  3649. return nil
  3650. case agentbase.FieldCollectionID:
  3651. m.ClearCollectionID()
  3652. return nil
  3653. case agentbase.FieldSourceName:
  3654. m.ClearSourceName()
  3655. return nil
  3656. case agentbase.FieldCanWrite:
  3657. m.ClearCanWrite()
  3658. return nil
  3659. case agentbase.FieldIsOwner:
  3660. m.ClearIsOwner()
  3661. return nil
  3662. }
  3663. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  3664. }
  3665. // ResetField resets all changes in the mutation for the field with the given name.
  3666. // It returns an error if the field is not defined in the schema.
  3667. func (m *AgentBaseMutation) ResetField(name string) error {
  3668. switch name {
  3669. case agentbase.FieldQ:
  3670. m.ResetQ()
  3671. return nil
  3672. case agentbase.FieldA:
  3673. m.ResetA()
  3674. return nil
  3675. case agentbase.FieldChunkIndex:
  3676. m.ResetChunkIndex()
  3677. return nil
  3678. case agentbase.FieldIndexes:
  3679. m.ResetIndexes()
  3680. return nil
  3681. case agentbase.FieldDatasetID:
  3682. m.ResetDatasetID()
  3683. return nil
  3684. case agentbase.FieldCollectionID:
  3685. m.ResetCollectionID()
  3686. return nil
  3687. case agentbase.FieldSourceName:
  3688. m.ResetSourceName()
  3689. return nil
  3690. case agentbase.FieldCanWrite:
  3691. m.ResetCanWrite()
  3692. return nil
  3693. case agentbase.FieldIsOwner:
  3694. m.ResetIsOwner()
  3695. return nil
  3696. }
  3697. return fmt.Errorf("unknown AgentBase field %s", name)
  3698. }
  3699. // AddedEdges returns all edge names that were set/added in this mutation.
  3700. func (m *AgentBaseMutation) AddedEdges() []string {
  3701. edges := make([]string, 0, 1)
  3702. if m.wx_agent != nil {
  3703. edges = append(edges, agentbase.EdgeWxAgent)
  3704. }
  3705. return edges
  3706. }
  3707. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3708. // name in this mutation.
  3709. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  3710. switch name {
  3711. case agentbase.EdgeWxAgent:
  3712. ids := make([]ent.Value, 0, len(m.wx_agent))
  3713. for id := range m.wx_agent {
  3714. ids = append(ids, id)
  3715. }
  3716. return ids
  3717. }
  3718. return nil
  3719. }
  3720. // RemovedEdges returns all edge names that were removed in this mutation.
  3721. func (m *AgentBaseMutation) RemovedEdges() []string {
  3722. edges := make([]string, 0, 1)
  3723. if m.removedwx_agent != nil {
  3724. edges = append(edges, agentbase.EdgeWxAgent)
  3725. }
  3726. return edges
  3727. }
  3728. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3729. // the given name in this mutation.
  3730. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  3731. switch name {
  3732. case agentbase.EdgeWxAgent:
  3733. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  3734. for id := range m.removedwx_agent {
  3735. ids = append(ids, id)
  3736. }
  3737. return ids
  3738. }
  3739. return nil
  3740. }
  3741. // ClearedEdges returns all edge names that were cleared in this mutation.
  3742. func (m *AgentBaseMutation) ClearedEdges() []string {
  3743. edges := make([]string, 0, 1)
  3744. if m.clearedwx_agent {
  3745. edges = append(edges, agentbase.EdgeWxAgent)
  3746. }
  3747. return edges
  3748. }
  3749. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3750. // was cleared in this mutation.
  3751. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  3752. switch name {
  3753. case agentbase.EdgeWxAgent:
  3754. return m.clearedwx_agent
  3755. }
  3756. return false
  3757. }
  3758. // ClearEdge clears the value of the edge with the given name. It returns an error
  3759. // if that edge is not defined in the schema.
  3760. func (m *AgentBaseMutation) ClearEdge(name string) error {
  3761. switch name {
  3762. }
  3763. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  3764. }
  3765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3766. // It returns an error if the edge is not defined in the schema.
  3767. func (m *AgentBaseMutation) ResetEdge(name string) error {
  3768. switch name {
  3769. case agentbase.EdgeWxAgent:
  3770. m.ResetWxAgent()
  3771. return nil
  3772. }
  3773. return fmt.Errorf("unknown AgentBase edge %s", name)
  3774. }
  3775. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  3776. type AliyunAvatarMutation struct {
  3777. config
  3778. op Op
  3779. typ string
  3780. id *uint64
  3781. created_at *time.Time
  3782. updated_at *time.Time
  3783. deleted_at *time.Time
  3784. user_id *uint64
  3785. adduser_id *int64
  3786. biz_id *string
  3787. access_key_id *string
  3788. access_key_secret *string
  3789. app_id *string
  3790. tenant_id *uint64
  3791. addtenant_id *int64
  3792. response *string
  3793. token *string
  3794. session_id *string
  3795. clearedFields map[string]struct{}
  3796. done bool
  3797. oldValue func(context.Context) (*AliyunAvatar, error)
  3798. predicates []predicate.AliyunAvatar
  3799. }
  3800. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  3801. // aliyunavatarOption allows management of the mutation configuration using functional options.
  3802. type aliyunavatarOption func(*AliyunAvatarMutation)
  3803. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  3804. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  3805. m := &AliyunAvatarMutation{
  3806. config: c,
  3807. op: op,
  3808. typ: TypeAliyunAvatar,
  3809. clearedFields: make(map[string]struct{}),
  3810. }
  3811. for _, opt := range opts {
  3812. opt(m)
  3813. }
  3814. return m
  3815. }
  3816. // withAliyunAvatarID sets the ID field of the mutation.
  3817. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  3818. return func(m *AliyunAvatarMutation) {
  3819. var (
  3820. err error
  3821. once sync.Once
  3822. value *AliyunAvatar
  3823. )
  3824. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  3825. once.Do(func() {
  3826. if m.done {
  3827. err = errors.New("querying old values post mutation is not allowed")
  3828. } else {
  3829. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  3830. }
  3831. })
  3832. return value, err
  3833. }
  3834. m.id = &id
  3835. }
  3836. }
  3837. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  3838. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  3839. return func(m *AliyunAvatarMutation) {
  3840. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  3841. return node, nil
  3842. }
  3843. m.id = &node.ID
  3844. }
  3845. }
  3846. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3847. // executed in a transaction (ent.Tx), a transactional client is returned.
  3848. func (m AliyunAvatarMutation) Client() *Client {
  3849. client := &Client{config: m.config}
  3850. client.init()
  3851. return client
  3852. }
  3853. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3854. // it returns an error otherwise.
  3855. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  3856. if _, ok := m.driver.(*txDriver); !ok {
  3857. return nil, errors.New("ent: mutation is not running in a transaction")
  3858. }
  3859. tx := &Tx{config: m.config}
  3860. tx.init()
  3861. return tx, nil
  3862. }
  3863. // SetID sets the value of the id field. Note that this
  3864. // operation is only accepted on creation of AliyunAvatar entities.
  3865. func (m *AliyunAvatarMutation) SetID(id uint64) {
  3866. m.id = &id
  3867. }
  3868. // ID returns the ID value in the mutation. Note that the ID is only available
  3869. // if it was provided to the builder or after it was returned from the database.
  3870. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  3871. if m.id == nil {
  3872. return
  3873. }
  3874. return *m.id, true
  3875. }
  3876. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3877. // That means, if the mutation is applied within a transaction with an isolation level such
  3878. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3879. // or updated by the mutation.
  3880. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  3881. switch {
  3882. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3883. id, exists := m.ID()
  3884. if exists {
  3885. return []uint64{id}, nil
  3886. }
  3887. fallthrough
  3888. case m.op.Is(OpUpdate | OpDelete):
  3889. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  3890. default:
  3891. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3892. }
  3893. }
  3894. // SetCreatedAt sets the "created_at" field.
  3895. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  3896. m.created_at = &t
  3897. }
  3898. // CreatedAt returns the value of the "created_at" field in the mutation.
  3899. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  3900. v := m.created_at
  3901. if v == nil {
  3902. return
  3903. }
  3904. return *v, true
  3905. }
  3906. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  3907. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3909. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3910. if !m.op.Is(OpUpdateOne) {
  3911. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3912. }
  3913. if m.id == nil || m.oldValue == nil {
  3914. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3915. }
  3916. oldValue, err := m.oldValue(ctx)
  3917. if err != nil {
  3918. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3919. }
  3920. return oldValue.CreatedAt, nil
  3921. }
  3922. // ResetCreatedAt resets all changes to the "created_at" field.
  3923. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  3924. m.created_at = nil
  3925. }
  3926. // SetUpdatedAt sets the "updated_at" field.
  3927. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  3928. m.updated_at = &t
  3929. }
  3930. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3931. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  3932. v := m.updated_at
  3933. if v == nil {
  3934. return
  3935. }
  3936. return *v, true
  3937. }
  3938. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  3939. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3941. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3942. if !m.op.Is(OpUpdateOne) {
  3943. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3944. }
  3945. if m.id == nil || m.oldValue == nil {
  3946. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3947. }
  3948. oldValue, err := m.oldValue(ctx)
  3949. if err != nil {
  3950. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3951. }
  3952. return oldValue.UpdatedAt, nil
  3953. }
  3954. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3955. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  3956. m.updated_at = nil
  3957. }
  3958. // SetDeletedAt sets the "deleted_at" field.
  3959. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  3960. m.deleted_at = &t
  3961. }
  3962. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3963. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  3964. v := m.deleted_at
  3965. if v == nil {
  3966. return
  3967. }
  3968. return *v, true
  3969. }
  3970. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  3971. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3973. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3974. if !m.op.Is(OpUpdateOne) {
  3975. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3976. }
  3977. if m.id == nil || m.oldValue == nil {
  3978. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3979. }
  3980. oldValue, err := m.oldValue(ctx)
  3981. if err != nil {
  3982. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3983. }
  3984. return oldValue.DeletedAt, nil
  3985. }
  3986. // ClearDeletedAt clears the value of the "deleted_at" field.
  3987. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  3988. m.deleted_at = nil
  3989. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  3990. }
  3991. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3992. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  3993. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  3994. return ok
  3995. }
  3996. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3997. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  3998. m.deleted_at = nil
  3999. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  4000. }
  4001. // SetUserID sets the "user_id" field.
  4002. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  4003. m.user_id = &u
  4004. m.adduser_id = nil
  4005. }
  4006. // UserID returns the value of the "user_id" field in the mutation.
  4007. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  4008. v := m.user_id
  4009. if v == nil {
  4010. return
  4011. }
  4012. return *v, true
  4013. }
  4014. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  4015. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4017. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4018. if !m.op.Is(OpUpdateOne) {
  4019. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4020. }
  4021. if m.id == nil || m.oldValue == nil {
  4022. return v, errors.New("OldUserID requires an ID field in the mutation")
  4023. }
  4024. oldValue, err := m.oldValue(ctx)
  4025. if err != nil {
  4026. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4027. }
  4028. return oldValue.UserID, nil
  4029. }
  4030. // AddUserID adds u to the "user_id" field.
  4031. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  4032. if m.adduser_id != nil {
  4033. *m.adduser_id += u
  4034. } else {
  4035. m.adduser_id = &u
  4036. }
  4037. }
  4038. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4039. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  4040. v := m.adduser_id
  4041. if v == nil {
  4042. return
  4043. }
  4044. return *v, true
  4045. }
  4046. // ResetUserID resets all changes to the "user_id" field.
  4047. func (m *AliyunAvatarMutation) ResetUserID() {
  4048. m.user_id = nil
  4049. m.adduser_id = nil
  4050. }
  4051. // SetBizID sets the "biz_id" field.
  4052. func (m *AliyunAvatarMutation) SetBizID(s string) {
  4053. m.biz_id = &s
  4054. }
  4055. // BizID returns the value of the "biz_id" field in the mutation.
  4056. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  4057. v := m.biz_id
  4058. if v == nil {
  4059. return
  4060. }
  4061. return *v, true
  4062. }
  4063. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  4064. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4066. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  4067. if !m.op.Is(OpUpdateOne) {
  4068. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  4069. }
  4070. if m.id == nil || m.oldValue == nil {
  4071. return v, errors.New("OldBizID requires an ID field in the mutation")
  4072. }
  4073. oldValue, err := m.oldValue(ctx)
  4074. if err != nil {
  4075. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  4076. }
  4077. return oldValue.BizID, nil
  4078. }
  4079. // ResetBizID resets all changes to the "biz_id" field.
  4080. func (m *AliyunAvatarMutation) ResetBizID() {
  4081. m.biz_id = nil
  4082. }
  4083. // SetAccessKeyID sets the "access_key_id" field.
  4084. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  4085. m.access_key_id = &s
  4086. }
  4087. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  4088. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  4089. v := m.access_key_id
  4090. if v == nil {
  4091. return
  4092. }
  4093. return *v, true
  4094. }
  4095. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  4096. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4098. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  4099. if !m.op.Is(OpUpdateOne) {
  4100. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  4101. }
  4102. if m.id == nil || m.oldValue == nil {
  4103. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  4104. }
  4105. oldValue, err := m.oldValue(ctx)
  4106. if err != nil {
  4107. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  4108. }
  4109. return oldValue.AccessKeyID, nil
  4110. }
  4111. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  4112. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  4113. m.access_key_id = nil
  4114. }
  4115. // SetAccessKeySecret sets the "access_key_secret" field.
  4116. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  4117. m.access_key_secret = &s
  4118. }
  4119. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  4120. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  4121. v := m.access_key_secret
  4122. if v == nil {
  4123. return
  4124. }
  4125. return *v, true
  4126. }
  4127. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  4128. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4130. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  4131. if !m.op.Is(OpUpdateOne) {
  4132. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  4133. }
  4134. if m.id == nil || m.oldValue == nil {
  4135. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  4136. }
  4137. oldValue, err := m.oldValue(ctx)
  4138. if err != nil {
  4139. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  4140. }
  4141. return oldValue.AccessKeySecret, nil
  4142. }
  4143. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  4144. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  4145. m.access_key_secret = nil
  4146. }
  4147. // SetAppID sets the "app_id" field.
  4148. func (m *AliyunAvatarMutation) SetAppID(s string) {
  4149. m.app_id = &s
  4150. }
  4151. // AppID returns the value of the "app_id" field in the mutation.
  4152. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  4153. v := m.app_id
  4154. if v == nil {
  4155. return
  4156. }
  4157. return *v, true
  4158. }
  4159. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  4160. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4162. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  4163. if !m.op.Is(OpUpdateOne) {
  4164. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  4165. }
  4166. if m.id == nil || m.oldValue == nil {
  4167. return v, errors.New("OldAppID requires an ID field in the mutation")
  4168. }
  4169. oldValue, err := m.oldValue(ctx)
  4170. if err != nil {
  4171. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  4172. }
  4173. return oldValue.AppID, nil
  4174. }
  4175. // ClearAppID clears the value of the "app_id" field.
  4176. func (m *AliyunAvatarMutation) ClearAppID() {
  4177. m.app_id = nil
  4178. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  4179. }
  4180. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  4181. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  4182. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  4183. return ok
  4184. }
  4185. // ResetAppID resets all changes to the "app_id" field.
  4186. func (m *AliyunAvatarMutation) ResetAppID() {
  4187. m.app_id = nil
  4188. delete(m.clearedFields, aliyunavatar.FieldAppID)
  4189. }
  4190. // SetTenantID sets the "tenant_id" field.
  4191. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  4192. m.tenant_id = &u
  4193. m.addtenant_id = nil
  4194. }
  4195. // TenantID returns the value of the "tenant_id" field in the mutation.
  4196. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  4197. v := m.tenant_id
  4198. if v == nil {
  4199. return
  4200. }
  4201. return *v, true
  4202. }
  4203. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  4204. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4206. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  4207. if !m.op.Is(OpUpdateOne) {
  4208. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  4209. }
  4210. if m.id == nil || m.oldValue == nil {
  4211. return v, errors.New("OldTenantID requires an ID field in the mutation")
  4212. }
  4213. oldValue, err := m.oldValue(ctx)
  4214. if err != nil {
  4215. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  4216. }
  4217. return oldValue.TenantID, nil
  4218. }
  4219. // AddTenantID adds u to the "tenant_id" field.
  4220. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  4221. if m.addtenant_id != nil {
  4222. *m.addtenant_id += u
  4223. } else {
  4224. m.addtenant_id = &u
  4225. }
  4226. }
  4227. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  4228. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  4229. v := m.addtenant_id
  4230. if v == nil {
  4231. return
  4232. }
  4233. return *v, true
  4234. }
  4235. // ResetTenantID resets all changes to the "tenant_id" field.
  4236. func (m *AliyunAvatarMutation) ResetTenantID() {
  4237. m.tenant_id = nil
  4238. m.addtenant_id = nil
  4239. }
  4240. // SetResponse sets the "response" field.
  4241. func (m *AliyunAvatarMutation) SetResponse(s string) {
  4242. m.response = &s
  4243. }
  4244. // Response returns the value of the "response" field in the mutation.
  4245. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  4246. v := m.response
  4247. if v == nil {
  4248. return
  4249. }
  4250. return *v, true
  4251. }
  4252. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  4253. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4255. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  4256. if !m.op.Is(OpUpdateOne) {
  4257. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  4258. }
  4259. if m.id == nil || m.oldValue == nil {
  4260. return v, errors.New("OldResponse requires an ID field in the mutation")
  4261. }
  4262. oldValue, err := m.oldValue(ctx)
  4263. if err != nil {
  4264. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  4265. }
  4266. return oldValue.Response, nil
  4267. }
  4268. // ResetResponse resets all changes to the "response" field.
  4269. func (m *AliyunAvatarMutation) ResetResponse() {
  4270. m.response = nil
  4271. }
  4272. // SetToken sets the "token" field.
  4273. func (m *AliyunAvatarMutation) SetToken(s string) {
  4274. m.token = &s
  4275. }
  4276. // Token returns the value of the "token" field in the mutation.
  4277. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  4278. v := m.token
  4279. if v == nil {
  4280. return
  4281. }
  4282. return *v, true
  4283. }
  4284. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  4285. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4287. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  4288. if !m.op.Is(OpUpdateOne) {
  4289. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  4290. }
  4291. if m.id == nil || m.oldValue == nil {
  4292. return v, errors.New("OldToken requires an ID field in the mutation")
  4293. }
  4294. oldValue, err := m.oldValue(ctx)
  4295. if err != nil {
  4296. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  4297. }
  4298. return oldValue.Token, nil
  4299. }
  4300. // ResetToken resets all changes to the "token" field.
  4301. func (m *AliyunAvatarMutation) ResetToken() {
  4302. m.token = nil
  4303. }
  4304. // SetSessionID sets the "session_id" field.
  4305. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  4306. m.session_id = &s
  4307. }
  4308. // SessionID returns the value of the "session_id" field in the mutation.
  4309. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  4310. v := m.session_id
  4311. if v == nil {
  4312. return
  4313. }
  4314. return *v, true
  4315. }
  4316. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  4317. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4319. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  4320. if !m.op.Is(OpUpdateOne) {
  4321. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4322. }
  4323. if m.id == nil || m.oldValue == nil {
  4324. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4325. }
  4326. oldValue, err := m.oldValue(ctx)
  4327. if err != nil {
  4328. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4329. }
  4330. return oldValue.SessionID, nil
  4331. }
  4332. // ResetSessionID resets all changes to the "session_id" field.
  4333. func (m *AliyunAvatarMutation) ResetSessionID() {
  4334. m.session_id = nil
  4335. }
  4336. // Where appends a list predicates to the AliyunAvatarMutation builder.
  4337. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  4338. m.predicates = append(m.predicates, ps...)
  4339. }
  4340. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  4341. // users can use type-assertion to append predicates that do not depend on any generated package.
  4342. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  4343. p := make([]predicate.AliyunAvatar, len(ps))
  4344. for i := range ps {
  4345. p[i] = ps[i]
  4346. }
  4347. m.Where(p...)
  4348. }
  4349. // Op returns the operation name.
  4350. func (m *AliyunAvatarMutation) Op() Op {
  4351. return m.op
  4352. }
  4353. // SetOp allows setting the mutation operation.
  4354. func (m *AliyunAvatarMutation) SetOp(op Op) {
  4355. m.op = op
  4356. }
  4357. // Type returns the node type of this mutation (AliyunAvatar).
  4358. func (m *AliyunAvatarMutation) Type() string {
  4359. return m.typ
  4360. }
  4361. // Fields returns all fields that were changed during this mutation. Note that in
  4362. // order to get all numeric fields that were incremented/decremented, call
  4363. // AddedFields().
  4364. func (m *AliyunAvatarMutation) Fields() []string {
  4365. fields := make([]string, 0, 12)
  4366. if m.created_at != nil {
  4367. fields = append(fields, aliyunavatar.FieldCreatedAt)
  4368. }
  4369. if m.updated_at != nil {
  4370. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  4371. }
  4372. if m.deleted_at != nil {
  4373. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4374. }
  4375. if m.user_id != nil {
  4376. fields = append(fields, aliyunavatar.FieldUserID)
  4377. }
  4378. if m.biz_id != nil {
  4379. fields = append(fields, aliyunavatar.FieldBizID)
  4380. }
  4381. if m.access_key_id != nil {
  4382. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  4383. }
  4384. if m.access_key_secret != nil {
  4385. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  4386. }
  4387. if m.app_id != nil {
  4388. fields = append(fields, aliyunavatar.FieldAppID)
  4389. }
  4390. if m.tenant_id != nil {
  4391. fields = append(fields, aliyunavatar.FieldTenantID)
  4392. }
  4393. if m.response != nil {
  4394. fields = append(fields, aliyunavatar.FieldResponse)
  4395. }
  4396. if m.token != nil {
  4397. fields = append(fields, aliyunavatar.FieldToken)
  4398. }
  4399. if m.session_id != nil {
  4400. fields = append(fields, aliyunavatar.FieldSessionID)
  4401. }
  4402. return fields
  4403. }
  4404. // Field returns the value of a field with the given name. The second boolean
  4405. // return value indicates that this field was not set, or was not defined in the
  4406. // schema.
  4407. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  4408. switch name {
  4409. case aliyunavatar.FieldCreatedAt:
  4410. return m.CreatedAt()
  4411. case aliyunavatar.FieldUpdatedAt:
  4412. return m.UpdatedAt()
  4413. case aliyunavatar.FieldDeletedAt:
  4414. return m.DeletedAt()
  4415. case aliyunavatar.FieldUserID:
  4416. return m.UserID()
  4417. case aliyunavatar.FieldBizID:
  4418. return m.BizID()
  4419. case aliyunavatar.FieldAccessKeyID:
  4420. return m.AccessKeyID()
  4421. case aliyunavatar.FieldAccessKeySecret:
  4422. return m.AccessKeySecret()
  4423. case aliyunavatar.FieldAppID:
  4424. return m.AppID()
  4425. case aliyunavatar.FieldTenantID:
  4426. return m.TenantID()
  4427. case aliyunavatar.FieldResponse:
  4428. return m.Response()
  4429. case aliyunavatar.FieldToken:
  4430. return m.Token()
  4431. case aliyunavatar.FieldSessionID:
  4432. return m.SessionID()
  4433. }
  4434. return nil, false
  4435. }
  4436. // OldField returns the old value of the field from the database. An error is
  4437. // returned if the mutation operation is not UpdateOne, or the query to the
  4438. // database failed.
  4439. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4440. switch name {
  4441. case aliyunavatar.FieldCreatedAt:
  4442. return m.OldCreatedAt(ctx)
  4443. case aliyunavatar.FieldUpdatedAt:
  4444. return m.OldUpdatedAt(ctx)
  4445. case aliyunavatar.FieldDeletedAt:
  4446. return m.OldDeletedAt(ctx)
  4447. case aliyunavatar.FieldUserID:
  4448. return m.OldUserID(ctx)
  4449. case aliyunavatar.FieldBizID:
  4450. return m.OldBizID(ctx)
  4451. case aliyunavatar.FieldAccessKeyID:
  4452. return m.OldAccessKeyID(ctx)
  4453. case aliyunavatar.FieldAccessKeySecret:
  4454. return m.OldAccessKeySecret(ctx)
  4455. case aliyunavatar.FieldAppID:
  4456. return m.OldAppID(ctx)
  4457. case aliyunavatar.FieldTenantID:
  4458. return m.OldTenantID(ctx)
  4459. case aliyunavatar.FieldResponse:
  4460. return m.OldResponse(ctx)
  4461. case aliyunavatar.FieldToken:
  4462. return m.OldToken(ctx)
  4463. case aliyunavatar.FieldSessionID:
  4464. return m.OldSessionID(ctx)
  4465. }
  4466. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  4467. }
  4468. // SetField sets the value of a field with the given name. It returns an error if
  4469. // the field is not defined in the schema, or if the type mismatched the field
  4470. // type.
  4471. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  4472. switch name {
  4473. case aliyunavatar.FieldCreatedAt:
  4474. v, ok := value.(time.Time)
  4475. if !ok {
  4476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4477. }
  4478. m.SetCreatedAt(v)
  4479. return nil
  4480. case aliyunavatar.FieldUpdatedAt:
  4481. v, ok := value.(time.Time)
  4482. if !ok {
  4483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4484. }
  4485. m.SetUpdatedAt(v)
  4486. return nil
  4487. case aliyunavatar.FieldDeletedAt:
  4488. v, ok := value.(time.Time)
  4489. if !ok {
  4490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4491. }
  4492. m.SetDeletedAt(v)
  4493. return nil
  4494. case aliyunavatar.FieldUserID:
  4495. v, ok := value.(uint64)
  4496. if !ok {
  4497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4498. }
  4499. m.SetUserID(v)
  4500. return nil
  4501. case aliyunavatar.FieldBizID:
  4502. v, ok := value.(string)
  4503. if !ok {
  4504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4505. }
  4506. m.SetBizID(v)
  4507. return nil
  4508. case aliyunavatar.FieldAccessKeyID:
  4509. v, ok := value.(string)
  4510. if !ok {
  4511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4512. }
  4513. m.SetAccessKeyID(v)
  4514. return nil
  4515. case aliyunavatar.FieldAccessKeySecret:
  4516. v, ok := value.(string)
  4517. if !ok {
  4518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4519. }
  4520. m.SetAccessKeySecret(v)
  4521. return nil
  4522. case aliyunavatar.FieldAppID:
  4523. v, ok := value.(string)
  4524. if !ok {
  4525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4526. }
  4527. m.SetAppID(v)
  4528. return nil
  4529. case aliyunavatar.FieldTenantID:
  4530. v, ok := value.(uint64)
  4531. if !ok {
  4532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4533. }
  4534. m.SetTenantID(v)
  4535. return nil
  4536. case aliyunavatar.FieldResponse:
  4537. v, ok := value.(string)
  4538. if !ok {
  4539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4540. }
  4541. m.SetResponse(v)
  4542. return nil
  4543. case aliyunavatar.FieldToken:
  4544. v, ok := value.(string)
  4545. if !ok {
  4546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4547. }
  4548. m.SetToken(v)
  4549. return nil
  4550. case aliyunavatar.FieldSessionID:
  4551. v, ok := value.(string)
  4552. if !ok {
  4553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4554. }
  4555. m.SetSessionID(v)
  4556. return nil
  4557. }
  4558. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4559. }
  4560. // AddedFields returns all numeric fields that were incremented/decremented during
  4561. // this mutation.
  4562. func (m *AliyunAvatarMutation) AddedFields() []string {
  4563. var fields []string
  4564. if m.adduser_id != nil {
  4565. fields = append(fields, aliyunavatar.FieldUserID)
  4566. }
  4567. if m.addtenant_id != nil {
  4568. fields = append(fields, aliyunavatar.FieldTenantID)
  4569. }
  4570. return fields
  4571. }
  4572. // AddedField returns the numeric value that was incremented/decremented on a field
  4573. // with the given name. The second boolean return value indicates that this field
  4574. // was not set, or was not defined in the schema.
  4575. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  4576. switch name {
  4577. case aliyunavatar.FieldUserID:
  4578. return m.AddedUserID()
  4579. case aliyunavatar.FieldTenantID:
  4580. return m.AddedTenantID()
  4581. }
  4582. return nil, false
  4583. }
  4584. // AddField adds the value to the field with the given name. It returns an error if
  4585. // the field is not defined in the schema, or if the type mismatched the field
  4586. // type.
  4587. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  4588. switch name {
  4589. case aliyunavatar.FieldUserID:
  4590. v, ok := value.(int64)
  4591. if !ok {
  4592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4593. }
  4594. m.AddUserID(v)
  4595. return nil
  4596. case aliyunavatar.FieldTenantID:
  4597. v, ok := value.(int64)
  4598. if !ok {
  4599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4600. }
  4601. m.AddTenantID(v)
  4602. return nil
  4603. }
  4604. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  4605. }
  4606. // ClearedFields returns all nullable fields that were cleared during this
  4607. // mutation.
  4608. func (m *AliyunAvatarMutation) ClearedFields() []string {
  4609. var fields []string
  4610. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  4611. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4612. }
  4613. if m.FieldCleared(aliyunavatar.FieldAppID) {
  4614. fields = append(fields, aliyunavatar.FieldAppID)
  4615. }
  4616. return fields
  4617. }
  4618. // FieldCleared returns a boolean indicating if a field with the given name was
  4619. // cleared in this mutation.
  4620. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  4621. _, ok := m.clearedFields[name]
  4622. return ok
  4623. }
  4624. // ClearField clears the value of the field with the given name. It returns an
  4625. // error if the field is not defined in the schema.
  4626. func (m *AliyunAvatarMutation) ClearField(name string) error {
  4627. switch name {
  4628. case aliyunavatar.FieldDeletedAt:
  4629. m.ClearDeletedAt()
  4630. return nil
  4631. case aliyunavatar.FieldAppID:
  4632. m.ClearAppID()
  4633. return nil
  4634. }
  4635. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  4636. }
  4637. // ResetField resets all changes in the mutation for the field with the given name.
  4638. // It returns an error if the field is not defined in the schema.
  4639. func (m *AliyunAvatarMutation) ResetField(name string) error {
  4640. switch name {
  4641. case aliyunavatar.FieldCreatedAt:
  4642. m.ResetCreatedAt()
  4643. return nil
  4644. case aliyunavatar.FieldUpdatedAt:
  4645. m.ResetUpdatedAt()
  4646. return nil
  4647. case aliyunavatar.FieldDeletedAt:
  4648. m.ResetDeletedAt()
  4649. return nil
  4650. case aliyunavatar.FieldUserID:
  4651. m.ResetUserID()
  4652. return nil
  4653. case aliyunavatar.FieldBizID:
  4654. m.ResetBizID()
  4655. return nil
  4656. case aliyunavatar.FieldAccessKeyID:
  4657. m.ResetAccessKeyID()
  4658. return nil
  4659. case aliyunavatar.FieldAccessKeySecret:
  4660. m.ResetAccessKeySecret()
  4661. return nil
  4662. case aliyunavatar.FieldAppID:
  4663. m.ResetAppID()
  4664. return nil
  4665. case aliyunavatar.FieldTenantID:
  4666. m.ResetTenantID()
  4667. return nil
  4668. case aliyunavatar.FieldResponse:
  4669. m.ResetResponse()
  4670. return nil
  4671. case aliyunavatar.FieldToken:
  4672. m.ResetToken()
  4673. return nil
  4674. case aliyunavatar.FieldSessionID:
  4675. m.ResetSessionID()
  4676. return nil
  4677. }
  4678. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4679. }
  4680. // AddedEdges returns all edge names that were set/added in this mutation.
  4681. func (m *AliyunAvatarMutation) AddedEdges() []string {
  4682. edges := make([]string, 0, 0)
  4683. return edges
  4684. }
  4685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4686. // name in this mutation.
  4687. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  4688. return nil
  4689. }
  4690. // RemovedEdges returns all edge names that were removed in this mutation.
  4691. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  4692. edges := make([]string, 0, 0)
  4693. return edges
  4694. }
  4695. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4696. // the given name in this mutation.
  4697. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  4698. return nil
  4699. }
  4700. // ClearedEdges returns all edge names that were cleared in this mutation.
  4701. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  4702. edges := make([]string, 0, 0)
  4703. return edges
  4704. }
  4705. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4706. // was cleared in this mutation.
  4707. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  4708. return false
  4709. }
  4710. // ClearEdge clears the value of the edge with the given name. It returns an error
  4711. // if that edge is not defined in the schema.
  4712. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  4713. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  4714. }
  4715. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4716. // It returns an error if the edge is not defined in the schema.
  4717. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  4718. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  4719. }
  4720. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  4721. type AllocAgentMutation struct {
  4722. config
  4723. op Op
  4724. typ string
  4725. id *uint64
  4726. created_at *time.Time
  4727. updated_at *time.Time
  4728. deleted_at *time.Time
  4729. user_id *string
  4730. organization_id *uint64
  4731. addorganization_id *int64
  4732. agents *[]uint64
  4733. appendagents []uint64
  4734. status *int
  4735. addstatus *int
  4736. clearedFields map[string]struct{}
  4737. done bool
  4738. oldValue func(context.Context) (*AllocAgent, error)
  4739. predicates []predicate.AllocAgent
  4740. }
  4741. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  4742. // allocagentOption allows management of the mutation configuration using functional options.
  4743. type allocagentOption func(*AllocAgentMutation)
  4744. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  4745. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  4746. m := &AllocAgentMutation{
  4747. config: c,
  4748. op: op,
  4749. typ: TypeAllocAgent,
  4750. clearedFields: make(map[string]struct{}),
  4751. }
  4752. for _, opt := range opts {
  4753. opt(m)
  4754. }
  4755. return m
  4756. }
  4757. // withAllocAgentID sets the ID field of the mutation.
  4758. func withAllocAgentID(id uint64) allocagentOption {
  4759. return func(m *AllocAgentMutation) {
  4760. var (
  4761. err error
  4762. once sync.Once
  4763. value *AllocAgent
  4764. )
  4765. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  4766. once.Do(func() {
  4767. if m.done {
  4768. err = errors.New("querying old values post mutation is not allowed")
  4769. } else {
  4770. value, err = m.Client().AllocAgent.Get(ctx, id)
  4771. }
  4772. })
  4773. return value, err
  4774. }
  4775. m.id = &id
  4776. }
  4777. }
  4778. // withAllocAgent sets the old AllocAgent of the mutation.
  4779. func withAllocAgent(node *AllocAgent) allocagentOption {
  4780. return func(m *AllocAgentMutation) {
  4781. m.oldValue = func(context.Context) (*AllocAgent, error) {
  4782. return node, nil
  4783. }
  4784. m.id = &node.ID
  4785. }
  4786. }
  4787. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4788. // executed in a transaction (ent.Tx), a transactional client is returned.
  4789. func (m AllocAgentMutation) Client() *Client {
  4790. client := &Client{config: m.config}
  4791. client.init()
  4792. return client
  4793. }
  4794. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4795. // it returns an error otherwise.
  4796. func (m AllocAgentMutation) Tx() (*Tx, error) {
  4797. if _, ok := m.driver.(*txDriver); !ok {
  4798. return nil, errors.New("ent: mutation is not running in a transaction")
  4799. }
  4800. tx := &Tx{config: m.config}
  4801. tx.init()
  4802. return tx, nil
  4803. }
  4804. // SetID sets the value of the id field. Note that this
  4805. // operation is only accepted on creation of AllocAgent entities.
  4806. func (m *AllocAgentMutation) SetID(id uint64) {
  4807. m.id = &id
  4808. }
  4809. // ID returns the ID value in the mutation. Note that the ID is only available
  4810. // if it was provided to the builder or after it was returned from the database.
  4811. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  4812. if m.id == nil {
  4813. return
  4814. }
  4815. return *m.id, true
  4816. }
  4817. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4818. // That means, if the mutation is applied within a transaction with an isolation level such
  4819. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4820. // or updated by the mutation.
  4821. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  4822. switch {
  4823. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4824. id, exists := m.ID()
  4825. if exists {
  4826. return []uint64{id}, nil
  4827. }
  4828. fallthrough
  4829. case m.op.Is(OpUpdate | OpDelete):
  4830. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  4831. default:
  4832. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4833. }
  4834. }
  4835. // SetCreatedAt sets the "created_at" field.
  4836. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  4837. m.created_at = &t
  4838. }
  4839. // CreatedAt returns the value of the "created_at" field in the mutation.
  4840. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  4841. v := m.created_at
  4842. if v == nil {
  4843. return
  4844. }
  4845. return *v, true
  4846. }
  4847. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  4848. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4850. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4851. if !m.op.Is(OpUpdateOne) {
  4852. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4853. }
  4854. if m.id == nil || m.oldValue == nil {
  4855. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4856. }
  4857. oldValue, err := m.oldValue(ctx)
  4858. if err != nil {
  4859. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4860. }
  4861. return oldValue.CreatedAt, nil
  4862. }
  4863. // ResetCreatedAt resets all changes to the "created_at" field.
  4864. func (m *AllocAgentMutation) ResetCreatedAt() {
  4865. m.created_at = nil
  4866. }
  4867. // SetUpdatedAt sets the "updated_at" field.
  4868. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  4869. m.updated_at = &t
  4870. }
  4871. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4872. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  4873. v := m.updated_at
  4874. if v == nil {
  4875. return
  4876. }
  4877. return *v, true
  4878. }
  4879. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  4880. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4882. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4883. if !m.op.Is(OpUpdateOne) {
  4884. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4885. }
  4886. if m.id == nil || m.oldValue == nil {
  4887. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4888. }
  4889. oldValue, err := m.oldValue(ctx)
  4890. if err != nil {
  4891. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4892. }
  4893. return oldValue.UpdatedAt, nil
  4894. }
  4895. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4896. func (m *AllocAgentMutation) ResetUpdatedAt() {
  4897. m.updated_at = nil
  4898. }
  4899. // SetDeletedAt sets the "deleted_at" field.
  4900. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  4901. m.deleted_at = &t
  4902. }
  4903. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4904. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  4905. v := m.deleted_at
  4906. if v == nil {
  4907. return
  4908. }
  4909. return *v, true
  4910. }
  4911. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  4912. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4914. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4915. if !m.op.Is(OpUpdateOne) {
  4916. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4917. }
  4918. if m.id == nil || m.oldValue == nil {
  4919. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4920. }
  4921. oldValue, err := m.oldValue(ctx)
  4922. if err != nil {
  4923. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4924. }
  4925. return oldValue.DeletedAt, nil
  4926. }
  4927. // ClearDeletedAt clears the value of the "deleted_at" field.
  4928. func (m *AllocAgentMutation) ClearDeletedAt() {
  4929. m.deleted_at = nil
  4930. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  4931. }
  4932. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4933. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  4934. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  4935. return ok
  4936. }
  4937. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4938. func (m *AllocAgentMutation) ResetDeletedAt() {
  4939. m.deleted_at = nil
  4940. delete(m.clearedFields, allocagent.FieldDeletedAt)
  4941. }
  4942. // SetUserID sets the "user_id" field.
  4943. func (m *AllocAgentMutation) SetUserID(s string) {
  4944. m.user_id = &s
  4945. }
  4946. // UserID returns the value of the "user_id" field in the mutation.
  4947. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  4948. v := m.user_id
  4949. if v == nil {
  4950. return
  4951. }
  4952. return *v, true
  4953. }
  4954. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  4955. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4957. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  4958. if !m.op.Is(OpUpdateOne) {
  4959. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4960. }
  4961. if m.id == nil || m.oldValue == nil {
  4962. return v, errors.New("OldUserID requires an ID field in the mutation")
  4963. }
  4964. oldValue, err := m.oldValue(ctx)
  4965. if err != nil {
  4966. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4967. }
  4968. return oldValue.UserID, nil
  4969. }
  4970. // ClearUserID clears the value of the "user_id" field.
  4971. func (m *AllocAgentMutation) ClearUserID() {
  4972. m.user_id = nil
  4973. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  4974. }
  4975. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  4976. func (m *AllocAgentMutation) UserIDCleared() bool {
  4977. _, ok := m.clearedFields[allocagent.FieldUserID]
  4978. return ok
  4979. }
  4980. // ResetUserID resets all changes to the "user_id" field.
  4981. func (m *AllocAgentMutation) ResetUserID() {
  4982. m.user_id = nil
  4983. delete(m.clearedFields, allocagent.FieldUserID)
  4984. }
  4985. // SetOrganizationID sets the "organization_id" field.
  4986. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  4987. m.organization_id = &u
  4988. m.addorganization_id = nil
  4989. }
  4990. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4991. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  4992. v := m.organization_id
  4993. if v == nil {
  4994. return
  4995. }
  4996. return *v, true
  4997. }
  4998. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  4999. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5001. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5002. if !m.op.Is(OpUpdateOne) {
  5003. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5004. }
  5005. if m.id == nil || m.oldValue == nil {
  5006. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5007. }
  5008. oldValue, err := m.oldValue(ctx)
  5009. if err != nil {
  5010. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5011. }
  5012. return oldValue.OrganizationID, nil
  5013. }
  5014. // AddOrganizationID adds u to the "organization_id" field.
  5015. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  5016. if m.addorganization_id != nil {
  5017. *m.addorganization_id += u
  5018. } else {
  5019. m.addorganization_id = &u
  5020. }
  5021. }
  5022. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5023. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  5024. v := m.addorganization_id
  5025. if v == nil {
  5026. return
  5027. }
  5028. return *v, true
  5029. }
  5030. // ClearOrganizationID clears the value of the "organization_id" field.
  5031. func (m *AllocAgentMutation) ClearOrganizationID() {
  5032. m.organization_id = nil
  5033. m.addorganization_id = nil
  5034. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  5035. }
  5036. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5037. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  5038. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  5039. return ok
  5040. }
  5041. // ResetOrganizationID resets all changes to the "organization_id" field.
  5042. func (m *AllocAgentMutation) ResetOrganizationID() {
  5043. m.organization_id = nil
  5044. m.addorganization_id = nil
  5045. delete(m.clearedFields, allocagent.FieldOrganizationID)
  5046. }
  5047. // SetAgents sets the "agents" field.
  5048. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  5049. m.agents = &u
  5050. m.appendagents = nil
  5051. }
  5052. // Agents returns the value of the "agents" field in the mutation.
  5053. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  5054. v := m.agents
  5055. if v == nil {
  5056. return
  5057. }
  5058. return *v, true
  5059. }
  5060. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  5061. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5063. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  5064. if !m.op.Is(OpUpdateOne) {
  5065. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  5066. }
  5067. if m.id == nil || m.oldValue == nil {
  5068. return v, errors.New("OldAgents requires an ID field in the mutation")
  5069. }
  5070. oldValue, err := m.oldValue(ctx)
  5071. if err != nil {
  5072. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  5073. }
  5074. return oldValue.Agents, nil
  5075. }
  5076. // AppendAgents adds u to the "agents" field.
  5077. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  5078. m.appendagents = append(m.appendagents, u...)
  5079. }
  5080. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  5081. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  5082. if len(m.appendagents) == 0 {
  5083. return nil, false
  5084. }
  5085. return m.appendagents, true
  5086. }
  5087. // ResetAgents resets all changes to the "agents" field.
  5088. func (m *AllocAgentMutation) ResetAgents() {
  5089. m.agents = nil
  5090. m.appendagents = nil
  5091. }
  5092. // SetStatus sets the "status" field.
  5093. func (m *AllocAgentMutation) SetStatus(i int) {
  5094. m.status = &i
  5095. m.addstatus = nil
  5096. }
  5097. // Status returns the value of the "status" field in the mutation.
  5098. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  5099. v := m.status
  5100. if v == nil {
  5101. return
  5102. }
  5103. return *v, true
  5104. }
  5105. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  5106. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5108. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  5109. if !m.op.Is(OpUpdateOne) {
  5110. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5111. }
  5112. if m.id == nil || m.oldValue == nil {
  5113. return v, errors.New("OldStatus requires an ID field in the mutation")
  5114. }
  5115. oldValue, err := m.oldValue(ctx)
  5116. if err != nil {
  5117. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5118. }
  5119. return oldValue.Status, nil
  5120. }
  5121. // AddStatus adds i to the "status" field.
  5122. func (m *AllocAgentMutation) AddStatus(i int) {
  5123. if m.addstatus != nil {
  5124. *m.addstatus += i
  5125. } else {
  5126. m.addstatus = &i
  5127. }
  5128. }
  5129. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5130. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  5131. v := m.addstatus
  5132. if v == nil {
  5133. return
  5134. }
  5135. return *v, true
  5136. }
  5137. // ClearStatus clears the value of the "status" field.
  5138. func (m *AllocAgentMutation) ClearStatus() {
  5139. m.status = nil
  5140. m.addstatus = nil
  5141. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  5142. }
  5143. // StatusCleared returns if the "status" field was cleared in this mutation.
  5144. func (m *AllocAgentMutation) StatusCleared() bool {
  5145. _, ok := m.clearedFields[allocagent.FieldStatus]
  5146. return ok
  5147. }
  5148. // ResetStatus resets all changes to the "status" field.
  5149. func (m *AllocAgentMutation) ResetStatus() {
  5150. m.status = nil
  5151. m.addstatus = nil
  5152. delete(m.clearedFields, allocagent.FieldStatus)
  5153. }
  5154. // Where appends a list predicates to the AllocAgentMutation builder.
  5155. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  5156. m.predicates = append(m.predicates, ps...)
  5157. }
  5158. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  5159. // users can use type-assertion to append predicates that do not depend on any generated package.
  5160. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  5161. p := make([]predicate.AllocAgent, len(ps))
  5162. for i := range ps {
  5163. p[i] = ps[i]
  5164. }
  5165. m.Where(p...)
  5166. }
  5167. // Op returns the operation name.
  5168. func (m *AllocAgentMutation) Op() Op {
  5169. return m.op
  5170. }
  5171. // SetOp allows setting the mutation operation.
  5172. func (m *AllocAgentMutation) SetOp(op Op) {
  5173. m.op = op
  5174. }
  5175. // Type returns the node type of this mutation (AllocAgent).
  5176. func (m *AllocAgentMutation) Type() string {
  5177. return m.typ
  5178. }
  5179. // Fields returns all fields that were changed during this mutation. Note that in
  5180. // order to get all numeric fields that were incremented/decremented, call
  5181. // AddedFields().
  5182. func (m *AllocAgentMutation) Fields() []string {
  5183. fields := make([]string, 0, 7)
  5184. if m.created_at != nil {
  5185. fields = append(fields, allocagent.FieldCreatedAt)
  5186. }
  5187. if m.updated_at != nil {
  5188. fields = append(fields, allocagent.FieldUpdatedAt)
  5189. }
  5190. if m.deleted_at != nil {
  5191. fields = append(fields, allocagent.FieldDeletedAt)
  5192. }
  5193. if m.user_id != nil {
  5194. fields = append(fields, allocagent.FieldUserID)
  5195. }
  5196. if m.organization_id != nil {
  5197. fields = append(fields, allocagent.FieldOrganizationID)
  5198. }
  5199. if m.agents != nil {
  5200. fields = append(fields, allocagent.FieldAgents)
  5201. }
  5202. if m.status != nil {
  5203. fields = append(fields, allocagent.FieldStatus)
  5204. }
  5205. return fields
  5206. }
  5207. // Field returns the value of a field with the given name. The second boolean
  5208. // return value indicates that this field was not set, or was not defined in the
  5209. // schema.
  5210. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  5211. switch name {
  5212. case allocagent.FieldCreatedAt:
  5213. return m.CreatedAt()
  5214. case allocagent.FieldUpdatedAt:
  5215. return m.UpdatedAt()
  5216. case allocagent.FieldDeletedAt:
  5217. return m.DeletedAt()
  5218. case allocagent.FieldUserID:
  5219. return m.UserID()
  5220. case allocagent.FieldOrganizationID:
  5221. return m.OrganizationID()
  5222. case allocagent.FieldAgents:
  5223. return m.Agents()
  5224. case allocagent.FieldStatus:
  5225. return m.Status()
  5226. }
  5227. return nil, false
  5228. }
  5229. // OldField returns the old value of the field from the database. An error is
  5230. // returned if the mutation operation is not UpdateOne, or the query to the
  5231. // database failed.
  5232. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5233. switch name {
  5234. case allocagent.FieldCreatedAt:
  5235. return m.OldCreatedAt(ctx)
  5236. case allocagent.FieldUpdatedAt:
  5237. return m.OldUpdatedAt(ctx)
  5238. case allocagent.FieldDeletedAt:
  5239. return m.OldDeletedAt(ctx)
  5240. case allocagent.FieldUserID:
  5241. return m.OldUserID(ctx)
  5242. case allocagent.FieldOrganizationID:
  5243. return m.OldOrganizationID(ctx)
  5244. case allocagent.FieldAgents:
  5245. return m.OldAgents(ctx)
  5246. case allocagent.FieldStatus:
  5247. return m.OldStatus(ctx)
  5248. }
  5249. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  5250. }
  5251. // SetField sets the value of a field with the given name. It returns an error if
  5252. // the field is not defined in the schema, or if the type mismatched the field
  5253. // type.
  5254. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  5255. switch name {
  5256. case allocagent.FieldCreatedAt:
  5257. v, ok := value.(time.Time)
  5258. if !ok {
  5259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5260. }
  5261. m.SetCreatedAt(v)
  5262. return nil
  5263. case allocagent.FieldUpdatedAt:
  5264. v, ok := value.(time.Time)
  5265. if !ok {
  5266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5267. }
  5268. m.SetUpdatedAt(v)
  5269. return nil
  5270. case allocagent.FieldDeletedAt:
  5271. v, ok := value.(time.Time)
  5272. if !ok {
  5273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5274. }
  5275. m.SetDeletedAt(v)
  5276. return nil
  5277. case allocagent.FieldUserID:
  5278. v, ok := value.(string)
  5279. if !ok {
  5280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5281. }
  5282. m.SetUserID(v)
  5283. return nil
  5284. case allocagent.FieldOrganizationID:
  5285. v, ok := value.(uint64)
  5286. if !ok {
  5287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5288. }
  5289. m.SetOrganizationID(v)
  5290. return nil
  5291. case allocagent.FieldAgents:
  5292. v, ok := value.([]uint64)
  5293. if !ok {
  5294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5295. }
  5296. m.SetAgents(v)
  5297. return nil
  5298. case allocagent.FieldStatus:
  5299. v, ok := value.(int)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.SetStatus(v)
  5304. return nil
  5305. }
  5306. return fmt.Errorf("unknown AllocAgent field %s", name)
  5307. }
  5308. // AddedFields returns all numeric fields that were incremented/decremented during
  5309. // this mutation.
  5310. func (m *AllocAgentMutation) AddedFields() []string {
  5311. var fields []string
  5312. if m.addorganization_id != nil {
  5313. fields = append(fields, allocagent.FieldOrganizationID)
  5314. }
  5315. if m.addstatus != nil {
  5316. fields = append(fields, allocagent.FieldStatus)
  5317. }
  5318. return fields
  5319. }
  5320. // AddedField returns the numeric value that was incremented/decremented on a field
  5321. // with the given name. The second boolean return value indicates that this field
  5322. // was not set, or was not defined in the schema.
  5323. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  5324. switch name {
  5325. case allocagent.FieldOrganizationID:
  5326. return m.AddedOrganizationID()
  5327. case allocagent.FieldStatus:
  5328. return m.AddedStatus()
  5329. }
  5330. return nil, false
  5331. }
  5332. // AddField adds the value to the field with the given name. It returns an error if
  5333. // the field is not defined in the schema, or if the type mismatched the field
  5334. // type.
  5335. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  5336. switch name {
  5337. case allocagent.FieldOrganizationID:
  5338. v, ok := value.(int64)
  5339. if !ok {
  5340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5341. }
  5342. m.AddOrganizationID(v)
  5343. return nil
  5344. case allocagent.FieldStatus:
  5345. v, ok := value.(int)
  5346. if !ok {
  5347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5348. }
  5349. m.AddStatus(v)
  5350. return nil
  5351. }
  5352. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  5353. }
  5354. // ClearedFields returns all nullable fields that were cleared during this
  5355. // mutation.
  5356. func (m *AllocAgentMutation) ClearedFields() []string {
  5357. var fields []string
  5358. if m.FieldCleared(allocagent.FieldDeletedAt) {
  5359. fields = append(fields, allocagent.FieldDeletedAt)
  5360. }
  5361. if m.FieldCleared(allocagent.FieldUserID) {
  5362. fields = append(fields, allocagent.FieldUserID)
  5363. }
  5364. if m.FieldCleared(allocagent.FieldOrganizationID) {
  5365. fields = append(fields, allocagent.FieldOrganizationID)
  5366. }
  5367. if m.FieldCleared(allocagent.FieldStatus) {
  5368. fields = append(fields, allocagent.FieldStatus)
  5369. }
  5370. return fields
  5371. }
  5372. // FieldCleared returns a boolean indicating if a field with the given name was
  5373. // cleared in this mutation.
  5374. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  5375. _, ok := m.clearedFields[name]
  5376. return ok
  5377. }
  5378. // ClearField clears the value of the field with the given name. It returns an
  5379. // error if the field is not defined in the schema.
  5380. func (m *AllocAgentMutation) ClearField(name string) error {
  5381. switch name {
  5382. case allocagent.FieldDeletedAt:
  5383. m.ClearDeletedAt()
  5384. return nil
  5385. case allocagent.FieldUserID:
  5386. m.ClearUserID()
  5387. return nil
  5388. case allocagent.FieldOrganizationID:
  5389. m.ClearOrganizationID()
  5390. return nil
  5391. case allocagent.FieldStatus:
  5392. m.ClearStatus()
  5393. return nil
  5394. }
  5395. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  5396. }
  5397. // ResetField resets all changes in the mutation for the field with the given name.
  5398. // It returns an error if the field is not defined in the schema.
  5399. func (m *AllocAgentMutation) ResetField(name string) error {
  5400. switch name {
  5401. case allocagent.FieldCreatedAt:
  5402. m.ResetCreatedAt()
  5403. return nil
  5404. case allocagent.FieldUpdatedAt:
  5405. m.ResetUpdatedAt()
  5406. return nil
  5407. case allocagent.FieldDeletedAt:
  5408. m.ResetDeletedAt()
  5409. return nil
  5410. case allocagent.FieldUserID:
  5411. m.ResetUserID()
  5412. return nil
  5413. case allocagent.FieldOrganizationID:
  5414. m.ResetOrganizationID()
  5415. return nil
  5416. case allocagent.FieldAgents:
  5417. m.ResetAgents()
  5418. return nil
  5419. case allocagent.FieldStatus:
  5420. m.ResetStatus()
  5421. return nil
  5422. }
  5423. return fmt.Errorf("unknown AllocAgent field %s", name)
  5424. }
  5425. // AddedEdges returns all edge names that were set/added in this mutation.
  5426. func (m *AllocAgentMutation) AddedEdges() []string {
  5427. edges := make([]string, 0, 0)
  5428. return edges
  5429. }
  5430. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5431. // name in this mutation.
  5432. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  5433. return nil
  5434. }
  5435. // RemovedEdges returns all edge names that were removed in this mutation.
  5436. func (m *AllocAgentMutation) RemovedEdges() []string {
  5437. edges := make([]string, 0, 0)
  5438. return edges
  5439. }
  5440. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5441. // the given name in this mutation.
  5442. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  5443. return nil
  5444. }
  5445. // ClearedEdges returns all edge names that were cleared in this mutation.
  5446. func (m *AllocAgentMutation) ClearedEdges() []string {
  5447. edges := make([]string, 0, 0)
  5448. return edges
  5449. }
  5450. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5451. // was cleared in this mutation.
  5452. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  5453. return false
  5454. }
  5455. // ClearEdge clears the value of the edge with the given name. It returns an error
  5456. // if that edge is not defined in the schema.
  5457. func (m *AllocAgentMutation) ClearEdge(name string) error {
  5458. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  5459. }
  5460. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5461. // It returns an error if the edge is not defined in the schema.
  5462. func (m *AllocAgentMutation) ResetEdge(name string) error {
  5463. return fmt.Errorf("unknown AllocAgent edge %s", name)
  5464. }
  5465. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  5466. type ApiKeyMutation struct {
  5467. config
  5468. op Op
  5469. typ string
  5470. id *uint64
  5471. created_at *time.Time
  5472. updated_at *time.Time
  5473. deleted_at *time.Time
  5474. title *string
  5475. key *string
  5476. organization_id *uint64
  5477. addorganization_id *int64
  5478. custom_agent_base *string
  5479. custom_agent_key *string
  5480. openai_base *string
  5481. openai_key *string
  5482. clearedFields map[string]struct{}
  5483. agent *uint64
  5484. clearedagent bool
  5485. done bool
  5486. oldValue func(context.Context) (*ApiKey, error)
  5487. predicates []predicate.ApiKey
  5488. }
  5489. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  5490. // apikeyOption allows management of the mutation configuration using functional options.
  5491. type apikeyOption func(*ApiKeyMutation)
  5492. // newApiKeyMutation creates new mutation for the ApiKey entity.
  5493. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  5494. m := &ApiKeyMutation{
  5495. config: c,
  5496. op: op,
  5497. typ: TypeApiKey,
  5498. clearedFields: make(map[string]struct{}),
  5499. }
  5500. for _, opt := range opts {
  5501. opt(m)
  5502. }
  5503. return m
  5504. }
  5505. // withApiKeyID sets the ID field of the mutation.
  5506. func withApiKeyID(id uint64) apikeyOption {
  5507. return func(m *ApiKeyMutation) {
  5508. var (
  5509. err error
  5510. once sync.Once
  5511. value *ApiKey
  5512. )
  5513. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  5514. once.Do(func() {
  5515. if m.done {
  5516. err = errors.New("querying old values post mutation is not allowed")
  5517. } else {
  5518. value, err = m.Client().ApiKey.Get(ctx, id)
  5519. }
  5520. })
  5521. return value, err
  5522. }
  5523. m.id = &id
  5524. }
  5525. }
  5526. // withApiKey sets the old ApiKey of the mutation.
  5527. func withApiKey(node *ApiKey) apikeyOption {
  5528. return func(m *ApiKeyMutation) {
  5529. m.oldValue = func(context.Context) (*ApiKey, error) {
  5530. return node, nil
  5531. }
  5532. m.id = &node.ID
  5533. }
  5534. }
  5535. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5536. // executed in a transaction (ent.Tx), a transactional client is returned.
  5537. func (m ApiKeyMutation) Client() *Client {
  5538. client := &Client{config: m.config}
  5539. client.init()
  5540. return client
  5541. }
  5542. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5543. // it returns an error otherwise.
  5544. func (m ApiKeyMutation) Tx() (*Tx, error) {
  5545. if _, ok := m.driver.(*txDriver); !ok {
  5546. return nil, errors.New("ent: mutation is not running in a transaction")
  5547. }
  5548. tx := &Tx{config: m.config}
  5549. tx.init()
  5550. return tx, nil
  5551. }
  5552. // SetID sets the value of the id field. Note that this
  5553. // operation is only accepted on creation of ApiKey entities.
  5554. func (m *ApiKeyMutation) SetID(id uint64) {
  5555. m.id = &id
  5556. }
  5557. // ID returns the ID value in the mutation. Note that the ID is only available
  5558. // if it was provided to the builder or after it was returned from the database.
  5559. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  5560. if m.id == nil {
  5561. return
  5562. }
  5563. return *m.id, true
  5564. }
  5565. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5566. // That means, if the mutation is applied within a transaction with an isolation level such
  5567. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5568. // or updated by the mutation.
  5569. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  5570. switch {
  5571. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5572. id, exists := m.ID()
  5573. if exists {
  5574. return []uint64{id}, nil
  5575. }
  5576. fallthrough
  5577. case m.op.Is(OpUpdate | OpDelete):
  5578. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  5579. default:
  5580. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5581. }
  5582. }
  5583. // SetCreatedAt sets the "created_at" field.
  5584. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  5585. m.created_at = &t
  5586. }
  5587. // CreatedAt returns the value of the "created_at" field in the mutation.
  5588. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  5589. v := m.created_at
  5590. if v == nil {
  5591. return
  5592. }
  5593. return *v, true
  5594. }
  5595. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  5596. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5598. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5599. if !m.op.Is(OpUpdateOne) {
  5600. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5601. }
  5602. if m.id == nil || m.oldValue == nil {
  5603. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5604. }
  5605. oldValue, err := m.oldValue(ctx)
  5606. if err != nil {
  5607. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5608. }
  5609. return oldValue.CreatedAt, nil
  5610. }
  5611. // ResetCreatedAt resets all changes to the "created_at" field.
  5612. func (m *ApiKeyMutation) ResetCreatedAt() {
  5613. m.created_at = nil
  5614. }
  5615. // SetUpdatedAt sets the "updated_at" field.
  5616. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  5617. m.updated_at = &t
  5618. }
  5619. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5620. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  5621. v := m.updated_at
  5622. if v == nil {
  5623. return
  5624. }
  5625. return *v, true
  5626. }
  5627. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  5628. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5630. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5631. if !m.op.Is(OpUpdateOne) {
  5632. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5633. }
  5634. if m.id == nil || m.oldValue == nil {
  5635. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5636. }
  5637. oldValue, err := m.oldValue(ctx)
  5638. if err != nil {
  5639. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5640. }
  5641. return oldValue.UpdatedAt, nil
  5642. }
  5643. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5644. func (m *ApiKeyMutation) ResetUpdatedAt() {
  5645. m.updated_at = nil
  5646. }
  5647. // SetDeletedAt sets the "deleted_at" field.
  5648. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  5649. m.deleted_at = &t
  5650. }
  5651. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5652. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  5653. v := m.deleted_at
  5654. if v == nil {
  5655. return
  5656. }
  5657. return *v, true
  5658. }
  5659. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  5660. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5662. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5663. if !m.op.Is(OpUpdateOne) {
  5664. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5665. }
  5666. if m.id == nil || m.oldValue == nil {
  5667. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5668. }
  5669. oldValue, err := m.oldValue(ctx)
  5670. if err != nil {
  5671. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5672. }
  5673. return oldValue.DeletedAt, nil
  5674. }
  5675. // ClearDeletedAt clears the value of the "deleted_at" field.
  5676. func (m *ApiKeyMutation) ClearDeletedAt() {
  5677. m.deleted_at = nil
  5678. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  5679. }
  5680. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5681. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  5682. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  5683. return ok
  5684. }
  5685. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5686. func (m *ApiKeyMutation) ResetDeletedAt() {
  5687. m.deleted_at = nil
  5688. delete(m.clearedFields, apikey.FieldDeletedAt)
  5689. }
  5690. // SetTitle sets the "title" field.
  5691. func (m *ApiKeyMutation) SetTitle(s string) {
  5692. m.title = &s
  5693. }
  5694. // Title returns the value of the "title" field in the mutation.
  5695. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  5696. v := m.title
  5697. if v == nil {
  5698. return
  5699. }
  5700. return *v, true
  5701. }
  5702. // OldTitle returns the old "title" field's value of the ApiKey entity.
  5703. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5705. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  5706. if !m.op.Is(OpUpdateOne) {
  5707. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5708. }
  5709. if m.id == nil || m.oldValue == nil {
  5710. return v, errors.New("OldTitle requires an ID field in the mutation")
  5711. }
  5712. oldValue, err := m.oldValue(ctx)
  5713. if err != nil {
  5714. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5715. }
  5716. return oldValue.Title, nil
  5717. }
  5718. // ClearTitle clears the value of the "title" field.
  5719. func (m *ApiKeyMutation) ClearTitle() {
  5720. m.title = nil
  5721. m.clearedFields[apikey.FieldTitle] = struct{}{}
  5722. }
  5723. // TitleCleared returns if the "title" field was cleared in this mutation.
  5724. func (m *ApiKeyMutation) TitleCleared() bool {
  5725. _, ok := m.clearedFields[apikey.FieldTitle]
  5726. return ok
  5727. }
  5728. // ResetTitle resets all changes to the "title" field.
  5729. func (m *ApiKeyMutation) ResetTitle() {
  5730. m.title = nil
  5731. delete(m.clearedFields, apikey.FieldTitle)
  5732. }
  5733. // SetKey sets the "key" field.
  5734. func (m *ApiKeyMutation) SetKey(s string) {
  5735. m.key = &s
  5736. }
  5737. // Key returns the value of the "key" field in the mutation.
  5738. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  5739. v := m.key
  5740. if v == nil {
  5741. return
  5742. }
  5743. return *v, true
  5744. }
  5745. // OldKey returns the old "key" field's value of the ApiKey entity.
  5746. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5748. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  5749. if !m.op.Is(OpUpdateOne) {
  5750. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  5751. }
  5752. if m.id == nil || m.oldValue == nil {
  5753. return v, errors.New("OldKey requires an ID field in the mutation")
  5754. }
  5755. oldValue, err := m.oldValue(ctx)
  5756. if err != nil {
  5757. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  5758. }
  5759. return oldValue.Key, nil
  5760. }
  5761. // ClearKey clears the value of the "key" field.
  5762. func (m *ApiKeyMutation) ClearKey() {
  5763. m.key = nil
  5764. m.clearedFields[apikey.FieldKey] = struct{}{}
  5765. }
  5766. // KeyCleared returns if the "key" field was cleared in this mutation.
  5767. func (m *ApiKeyMutation) KeyCleared() bool {
  5768. _, ok := m.clearedFields[apikey.FieldKey]
  5769. return ok
  5770. }
  5771. // ResetKey resets all changes to the "key" field.
  5772. func (m *ApiKeyMutation) ResetKey() {
  5773. m.key = nil
  5774. delete(m.clearedFields, apikey.FieldKey)
  5775. }
  5776. // SetOrganizationID sets the "organization_id" field.
  5777. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  5778. m.organization_id = &u
  5779. m.addorganization_id = nil
  5780. }
  5781. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5782. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  5783. v := m.organization_id
  5784. if v == nil {
  5785. return
  5786. }
  5787. return *v, true
  5788. }
  5789. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  5790. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5792. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5793. if !m.op.Is(OpUpdateOne) {
  5794. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5795. }
  5796. if m.id == nil || m.oldValue == nil {
  5797. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5798. }
  5799. oldValue, err := m.oldValue(ctx)
  5800. if err != nil {
  5801. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5802. }
  5803. return oldValue.OrganizationID, nil
  5804. }
  5805. // AddOrganizationID adds u to the "organization_id" field.
  5806. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  5807. if m.addorganization_id != nil {
  5808. *m.addorganization_id += u
  5809. } else {
  5810. m.addorganization_id = &u
  5811. }
  5812. }
  5813. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5814. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  5815. v := m.addorganization_id
  5816. if v == nil {
  5817. return
  5818. }
  5819. return *v, true
  5820. }
  5821. // ResetOrganizationID resets all changes to the "organization_id" field.
  5822. func (m *ApiKeyMutation) ResetOrganizationID() {
  5823. m.organization_id = nil
  5824. m.addorganization_id = nil
  5825. }
  5826. // SetAgentID sets the "agent_id" field.
  5827. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  5828. m.agent = &u
  5829. }
  5830. // AgentID returns the value of the "agent_id" field in the mutation.
  5831. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  5832. v := m.agent
  5833. if v == nil {
  5834. return
  5835. }
  5836. return *v, true
  5837. }
  5838. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  5839. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5841. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  5842. if !m.op.Is(OpUpdateOne) {
  5843. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  5844. }
  5845. if m.id == nil || m.oldValue == nil {
  5846. return v, errors.New("OldAgentID requires an ID field in the mutation")
  5847. }
  5848. oldValue, err := m.oldValue(ctx)
  5849. if err != nil {
  5850. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  5851. }
  5852. return oldValue.AgentID, nil
  5853. }
  5854. // ResetAgentID resets all changes to the "agent_id" field.
  5855. func (m *ApiKeyMutation) ResetAgentID() {
  5856. m.agent = nil
  5857. }
  5858. // SetCustomAgentBase sets the "custom_agent_base" field.
  5859. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  5860. m.custom_agent_base = &s
  5861. }
  5862. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  5863. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  5864. v := m.custom_agent_base
  5865. if v == nil {
  5866. return
  5867. }
  5868. return *v, true
  5869. }
  5870. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  5871. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5873. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  5874. if !m.op.Is(OpUpdateOne) {
  5875. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  5876. }
  5877. if m.id == nil || m.oldValue == nil {
  5878. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  5879. }
  5880. oldValue, err := m.oldValue(ctx)
  5881. if err != nil {
  5882. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  5883. }
  5884. return oldValue.CustomAgentBase, nil
  5885. }
  5886. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  5887. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  5888. m.custom_agent_base = nil
  5889. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  5890. }
  5891. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  5892. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  5893. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  5894. return ok
  5895. }
  5896. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  5897. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  5898. m.custom_agent_base = nil
  5899. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  5900. }
  5901. // SetCustomAgentKey sets the "custom_agent_key" field.
  5902. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  5903. m.custom_agent_key = &s
  5904. }
  5905. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  5906. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  5907. v := m.custom_agent_key
  5908. if v == nil {
  5909. return
  5910. }
  5911. return *v, true
  5912. }
  5913. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  5914. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5916. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  5917. if !m.op.Is(OpUpdateOne) {
  5918. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  5919. }
  5920. if m.id == nil || m.oldValue == nil {
  5921. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  5922. }
  5923. oldValue, err := m.oldValue(ctx)
  5924. if err != nil {
  5925. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  5926. }
  5927. return oldValue.CustomAgentKey, nil
  5928. }
  5929. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  5930. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  5931. m.custom_agent_key = nil
  5932. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  5933. }
  5934. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  5935. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  5936. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  5937. return ok
  5938. }
  5939. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  5940. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  5941. m.custom_agent_key = nil
  5942. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  5943. }
  5944. // SetOpenaiBase sets the "openai_base" field.
  5945. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  5946. m.openai_base = &s
  5947. }
  5948. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  5949. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  5950. v := m.openai_base
  5951. if v == nil {
  5952. return
  5953. }
  5954. return *v, true
  5955. }
  5956. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  5957. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5959. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  5960. if !m.op.Is(OpUpdateOne) {
  5961. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  5962. }
  5963. if m.id == nil || m.oldValue == nil {
  5964. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  5965. }
  5966. oldValue, err := m.oldValue(ctx)
  5967. if err != nil {
  5968. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  5969. }
  5970. return oldValue.OpenaiBase, nil
  5971. }
  5972. // ClearOpenaiBase clears the value of the "openai_base" field.
  5973. func (m *ApiKeyMutation) ClearOpenaiBase() {
  5974. m.openai_base = nil
  5975. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  5976. }
  5977. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  5978. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  5979. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  5980. return ok
  5981. }
  5982. // ResetOpenaiBase resets all changes to the "openai_base" field.
  5983. func (m *ApiKeyMutation) ResetOpenaiBase() {
  5984. m.openai_base = nil
  5985. delete(m.clearedFields, apikey.FieldOpenaiBase)
  5986. }
  5987. // SetOpenaiKey sets the "openai_key" field.
  5988. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  5989. m.openai_key = &s
  5990. }
  5991. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  5992. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  5993. v := m.openai_key
  5994. if v == nil {
  5995. return
  5996. }
  5997. return *v, true
  5998. }
  5999. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  6000. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6002. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  6003. if !m.op.Is(OpUpdateOne) {
  6004. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  6005. }
  6006. if m.id == nil || m.oldValue == nil {
  6007. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  6008. }
  6009. oldValue, err := m.oldValue(ctx)
  6010. if err != nil {
  6011. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  6012. }
  6013. return oldValue.OpenaiKey, nil
  6014. }
  6015. // ClearOpenaiKey clears the value of the "openai_key" field.
  6016. func (m *ApiKeyMutation) ClearOpenaiKey() {
  6017. m.openai_key = nil
  6018. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  6019. }
  6020. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  6021. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  6022. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  6023. return ok
  6024. }
  6025. // ResetOpenaiKey resets all changes to the "openai_key" field.
  6026. func (m *ApiKeyMutation) ResetOpenaiKey() {
  6027. m.openai_key = nil
  6028. delete(m.clearedFields, apikey.FieldOpenaiKey)
  6029. }
  6030. // ClearAgent clears the "agent" edge to the Agent entity.
  6031. func (m *ApiKeyMutation) ClearAgent() {
  6032. m.clearedagent = true
  6033. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  6034. }
  6035. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  6036. func (m *ApiKeyMutation) AgentCleared() bool {
  6037. return m.clearedagent
  6038. }
  6039. // AgentIDs returns the "agent" edge IDs in the mutation.
  6040. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6041. // AgentID instead. It exists only for internal usage by the builders.
  6042. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  6043. if id := m.agent; id != nil {
  6044. ids = append(ids, *id)
  6045. }
  6046. return
  6047. }
  6048. // ResetAgent resets all changes to the "agent" edge.
  6049. func (m *ApiKeyMutation) ResetAgent() {
  6050. m.agent = nil
  6051. m.clearedagent = false
  6052. }
  6053. // Where appends a list predicates to the ApiKeyMutation builder.
  6054. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  6055. m.predicates = append(m.predicates, ps...)
  6056. }
  6057. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  6058. // users can use type-assertion to append predicates that do not depend on any generated package.
  6059. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  6060. p := make([]predicate.ApiKey, len(ps))
  6061. for i := range ps {
  6062. p[i] = ps[i]
  6063. }
  6064. m.Where(p...)
  6065. }
  6066. // Op returns the operation name.
  6067. func (m *ApiKeyMutation) Op() Op {
  6068. return m.op
  6069. }
  6070. // SetOp allows setting the mutation operation.
  6071. func (m *ApiKeyMutation) SetOp(op Op) {
  6072. m.op = op
  6073. }
  6074. // Type returns the node type of this mutation (ApiKey).
  6075. func (m *ApiKeyMutation) Type() string {
  6076. return m.typ
  6077. }
  6078. // Fields returns all fields that were changed during this mutation. Note that in
  6079. // order to get all numeric fields that were incremented/decremented, call
  6080. // AddedFields().
  6081. func (m *ApiKeyMutation) Fields() []string {
  6082. fields := make([]string, 0, 11)
  6083. if m.created_at != nil {
  6084. fields = append(fields, apikey.FieldCreatedAt)
  6085. }
  6086. if m.updated_at != nil {
  6087. fields = append(fields, apikey.FieldUpdatedAt)
  6088. }
  6089. if m.deleted_at != nil {
  6090. fields = append(fields, apikey.FieldDeletedAt)
  6091. }
  6092. if m.title != nil {
  6093. fields = append(fields, apikey.FieldTitle)
  6094. }
  6095. if m.key != nil {
  6096. fields = append(fields, apikey.FieldKey)
  6097. }
  6098. if m.organization_id != nil {
  6099. fields = append(fields, apikey.FieldOrganizationID)
  6100. }
  6101. if m.agent != nil {
  6102. fields = append(fields, apikey.FieldAgentID)
  6103. }
  6104. if m.custom_agent_base != nil {
  6105. fields = append(fields, apikey.FieldCustomAgentBase)
  6106. }
  6107. if m.custom_agent_key != nil {
  6108. fields = append(fields, apikey.FieldCustomAgentKey)
  6109. }
  6110. if m.openai_base != nil {
  6111. fields = append(fields, apikey.FieldOpenaiBase)
  6112. }
  6113. if m.openai_key != nil {
  6114. fields = append(fields, apikey.FieldOpenaiKey)
  6115. }
  6116. return fields
  6117. }
  6118. // Field returns the value of a field with the given name. The second boolean
  6119. // return value indicates that this field was not set, or was not defined in the
  6120. // schema.
  6121. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  6122. switch name {
  6123. case apikey.FieldCreatedAt:
  6124. return m.CreatedAt()
  6125. case apikey.FieldUpdatedAt:
  6126. return m.UpdatedAt()
  6127. case apikey.FieldDeletedAt:
  6128. return m.DeletedAt()
  6129. case apikey.FieldTitle:
  6130. return m.Title()
  6131. case apikey.FieldKey:
  6132. return m.Key()
  6133. case apikey.FieldOrganizationID:
  6134. return m.OrganizationID()
  6135. case apikey.FieldAgentID:
  6136. return m.AgentID()
  6137. case apikey.FieldCustomAgentBase:
  6138. return m.CustomAgentBase()
  6139. case apikey.FieldCustomAgentKey:
  6140. return m.CustomAgentKey()
  6141. case apikey.FieldOpenaiBase:
  6142. return m.OpenaiBase()
  6143. case apikey.FieldOpenaiKey:
  6144. return m.OpenaiKey()
  6145. }
  6146. return nil, false
  6147. }
  6148. // OldField returns the old value of the field from the database. An error is
  6149. // returned if the mutation operation is not UpdateOne, or the query to the
  6150. // database failed.
  6151. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6152. switch name {
  6153. case apikey.FieldCreatedAt:
  6154. return m.OldCreatedAt(ctx)
  6155. case apikey.FieldUpdatedAt:
  6156. return m.OldUpdatedAt(ctx)
  6157. case apikey.FieldDeletedAt:
  6158. return m.OldDeletedAt(ctx)
  6159. case apikey.FieldTitle:
  6160. return m.OldTitle(ctx)
  6161. case apikey.FieldKey:
  6162. return m.OldKey(ctx)
  6163. case apikey.FieldOrganizationID:
  6164. return m.OldOrganizationID(ctx)
  6165. case apikey.FieldAgentID:
  6166. return m.OldAgentID(ctx)
  6167. case apikey.FieldCustomAgentBase:
  6168. return m.OldCustomAgentBase(ctx)
  6169. case apikey.FieldCustomAgentKey:
  6170. return m.OldCustomAgentKey(ctx)
  6171. case apikey.FieldOpenaiBase:
  6172. return m.OldOpenaiBase(ctx)
  6173. case apikey.FieldOpenaiKey:
  6174. return m.OldOpenaiKey(ctx)
  6175. }
  6176. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  6177. }
  6178. // SetField sets the value of a field with the given name. It returns an error if
  6179. // the field is not defined in the schema, or if the type mismatched the field
  6180. // type.
  6181. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  6182. switch name {
  6183. case apikey.FieldCreatedAt:
  6184. v, ok := value.(time.Time)
  6185. if !ok {
  6186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6187. }
  6188. m.SetCreatedAt(v)
  6189. return nil
  6190. case apikey.FieldUpdatedAt:
  6191. v, ok := value.(time.Time)
  6192. if !ok {
  6193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6194. }
  6195. m.SetUpdatedAt(v)
  6196. return nil
  6197. case apikey.FieldDeletedAt:
  6198. v, ok := value.(time.Time)
  6199. if !ok {
  6200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6201. }
  6202. m.SetDeletedAt(v)
  6203. return nil
  6204. case apikey.FieldTitle:
  6205. v, ok := value.(string)
  6206. if !ok {
  6207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6208. }
  6209. m.SetTitle(v)
  6210. return nil
  6211. case apikey.FieldKey:
  6212. v, ok := value.(string)
  6213. if !ok {
  6214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6215. }
  6216. m.SetKey(v)
  6217. return nil
  6218. case apikey.FieldOrganizationID:
  6219. v, ok := value.(uint64)
  6220. if !ok {
  6221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6222. }
  6223. m.SetOrganizationID(v)
  6224. return nil
  6225. case apikey.FieldAgentID:
  6226. v, ok := value.(uint64)
  6227. if !ok {
  6228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6229. }
  6230. m.SetAgentID(v)
  6231. return nil
  6232. case apikey.FieldCustomAgentBase:
  6233. v, ok := value.(string)
  6234. if !ok {
  6235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6236. }
  6237. m.SetCustomAgentBase(v)
  6238. return nil
  6239. case apikey.FieldCustomAgentKey:
  6240. v, ok := value.(string)
  6241. if !ok {
  6242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6243. }
  6244. m.SetCustomAgentKey(v)
  6245. return nil
  6246. case apikey.FieldOpenaiBase:
  6247. v, ok := value.(string)
  6248. if !ok {
  6249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6250. }
  6251. m.SetOpenaiBase(v)
  6252. return nil
  6253. case apikey.FieldOpenaiKey:
  6254. v, ok := value.(string)
  6255. if !ok {
  6256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6257. }
  6258. m.SetOpenaiKey(v)
  6259. return nil
  6260. }
  6261. return fmt.Errorf("unknown ApiKey field %s", name)
  6262. }
  6263. // AddedFields returns all numeric fields that were incremented/decremented during
  6264. // this mutation.
  6265. func (m *ApiKeyMutation) AddedFields() []string {
  6266. var fields []string
  6267. if m.addorganization_id != nil {
  6268. fields = append(fields, apikey.FieldOrganizationID)
  6269. }
  6270. return fields
  6271. }
  6272. // AddedField returns the numeric value that was incremented/decremented on a field
  6273. // with the given name. The second boolean return value indicates that this field
  6274. // was not set, or was not defined in the schema.
  6275. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  6276. switch name {
  6277. case apikey.FieldOrganizationID:
  6278. return m.AddedOrganizationID()
  6279. }
  6280. return nil, false
  6281. }
  6282. // AddField adds the value to the field with the given name. It returns an error if
  6283. // the field is not defined in the schema, or if the type mismatched the field
  6284. // type.
  6285. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  6286. switch name {
  6287. case apikey.FieldOrganizationID:
  6288. v, ok := value.(int64)
  6289. if !ok {
  6290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6291. }
  6292. m.AddOrganizationID(v)
  6293. return nil
  6294. }
  6295. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  6296. }
  6297. // ClearedFields returns all nullable fields that were cleared during this
  6298. // mutation.
  6299. func (m *ApiKeyMutation) ClearedFields() []string {
  6300. var fields []string
  6301. if m.FieldCleared(apikey.FieldDeletedAt) {
  6302. fields = append(fields, apikey.FieldDeletedAt)
  6303. }
  6304. if m.FieldCleared(apikey.FieldTitle) {
  6305. fields = append(fields, apikey.FieldTitle)
  6306. }
  6307. if m.FieldCleared(apikey.FieldKey) {
  6308. fields = append(fields, apikey.FieldKey)
  6309. }
  6310. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  6311. fields = append(fields, apikey.FieldCustomAgentBase)
  6312. }
  6313. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  6314. fields = append(fields, apikey.FieldCustomAgentKey)
  6315. }
  6316. if m.FieldCleared(apikey.FieldOpenaiBase) {
  6317. fields = append(fields, apikey.FieldOpenaiBase)
  6318. }
  6319. if m.FieldCleared(apikey.FieldOpenaiKey) {
  6320. fields = append(fields, apikey.FieldOpenaiKey)
  6321. }
  6322. return fields
  6323. }
  6324. // FieldCleared returns a boolean indicating if a field with the given name was
  6325. // cleared in this mutation.
  6326. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  6327. _, ok := m.clearedFields[name]
  6328. return ok
  6329. }
  6330. // ClearField clears the value of the field with the given name. It returns an
  6331. // error if the field is not defined in the schema.
  6332. func (m *ApiKeyMutation) ClearField(name string) error {
  6333. switch name {
  6334. case apikey.FieldDeletedAt:
  6335. m.ClearDeletedAt()
  6336. return nil
  6337. case apikey.FieldTitle:
  6338. m.ClearTitle()
  6339. return nil
  6340. case apikey.FieldKey:
  6341. m.ClearKey()
  6342. return nil
  6343. case apikey.FieldCustomAgentBase:
  6344. m.ClearCustomAgentBase()
  6345. return nil
  6346. case apikey.FieldCustomAgentKey:
  6347. m.ClearCustomAgentKey()
  6348. return nil
  6349. case apikey.FieldOpenaiBase:
  6350. m.ClearOpenaiBase()
  6351. return nil
  6352. case apikey.FieldOpenaiKey:
  6353. m.ClearOpenaiKey()
  6354. return nil
  6355. }
  6356. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  6357. }
  6358. // ResetField resets all changes in the mutation for the field with the given name.
  6359. // It returns an error if the field is not defined in the schema.
  6360. func (m *ApiKeyMutation) ResetField(name string) error {
  6361. switch name {
  6362. case apikey.FieldCreatedAt:
  6363. m.ResetCreatedAt()
  6364. return nil
  6365. case apikey.FieldUpdatedAt:
  6366. m.ResetUpdatedAt()
  6367. return nil
  6368. case apikey.FieldDeletedAt:
  6369. m.ResetDeletedAt()
  6370. return nil
  6371. case apikey.FieldTitle:
  6372. m.ResetTitle()
  6373. return nil
  6374. case apikey.FieldKey:
  6375. m.ResetKey()
  6376. return nil
  6377. case apikey.FieldOrganizationID:
  6378. m.ResetOrganizationID()
  6379. return nil
  6380. case apikey.FieldAgentID:
  6381. m.ResetAgentID()
  6382. return nil
  6383. case apikey.FieldCustomAgentBase:
  6384. m.ResetCustomAgentBase()
  6385. return nil
  6386. case apikey.FieldCustomAgentKey:
  6387. m.ResetCustomAgentKey()
  6388. return nil
  6389. case apikey.FieldOpenaiBase:
  6390. m.ResetOpenaiBase()
  6391. return nil
  6392. case apikey.FieldOpenaiKey:
  6393. m.ResetOpenaiKey()
  6394. return nil
  6395. }
  6396. return fmt.Errorf("unknown ApiKey field %s", name)
  6397. }
  6398. // AddedEdges returns all edge names that were set/added in this mutation.
  6399. func (m *ApiKeyMutation) AddedEdges() []string {
  6400. edges := make([]string, 0, 1)
  6401. if m.agent != nil {
  6402. edges = append(edges, apikey.EdgeAgent)
  6403. }
  6404. return edges
  6405. }
  6406. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6407. // name in this mutation.
  6408. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  6409. switch name {
  6410. case apikey.EdgeAgent:
  6411. if id := m.agent; id != nil {
  6412. return []ent.Value{*id}
  6413. }
  6414. }
  6415. return nil
  6416. }
  6417. // RemovedEdges returns all edge names that were removed in this mutation.
  6418. func (m *ApiKeyMutation) RemovedEdges() []string {
  6419. edges := make([]string, 0, 1)
  6420. return edges
  6421. }
  6422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6423. // the given name in this mutation.
  6424. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  6425. return nil
  6426. }
  6427. // ClearedEdges returns all edge names that were cleared in this mutation.
  6428. func (m *ApiKeyMutation) ClearedEdges() []string {
  6429. edges := make([]string, 0, 1)
  6430. if m.clearedagent {
  6431. edges = append(edges, apikey.EdgeAgent)
  6432. }
  6433. return edges
  6434. }
  6435. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6436. // was cleared in this mutation.
  6437. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  6438. switch name {
  6439. case apikey.EdgeAgent:
  6440. return m.clearedagent
  6441. }
  6442. return false
  6443. }
  6444. // ClearEdge clears the value of the edge with the given name. It returns an error
  6445. // if that edge is not defined in the schema.
  6446. func (m *ApiKeyMutation) ClearEdge(name string) error {
  6447. switch name {
  6448. case apikey.EdgeAgent:
  6449. m.ClearAgent()
  6450. return nil
  6451. }
  6452. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  6453. }
  6454. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6455. // It returns an error if the edge is not defined in the schema.
  6456. func (m *ApiKeyMutation) ResetEdge(name string) error {
  6457. switch name {
  6458. case apikey.EdgeAgent:
  6459. m.ResetAgent()
  6460. return nil
  6461. }
  6462. return fmt.Errorf("unknown ApiKey edge %s", name)
  6463. }
  6464. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  6465. type BatchMsgMutation struct {
  6466. config
  6467. op Op
  6468. typ string
  6469. id *uint64
  6470. created_at *time.Time
  6471. updated_at *time.Time
  6472. deleted_at *time.Time
  6473. status *uint8
  6474. addstatus *int8
  6475. batch_no *string
  6476. task_name *string
  6477. fromwxid *string
  6478. msg *string
  6479. tag *string
  6480. tagids *string
  6481. total *int32
  6482. addtotal *int32
  6483. success *int32
  6484. addsuccess *int32
  6485. fail *int32
  6486. addfail *int32
  6487. start_time *time.Time
  6488. stop_time *time.Time
  6489. send_time *time.Time
  6490. _type *int32
  6491. add_type *int32
  6492. organization_id *uint64
  6493. addorganization_id *int64
  6494. ctype *uint64
  6495. addctype *int64
  6496. cc *string
  6497. phone *string
  6498. template_name *string
  6499. template_code *string
  6500. lang *string
  6501. clearedFields map[string]struct{}
  6502. done bool
  6503. oldValue func(context.Context) (*BatchMsg, error)
  6504. predicates []predicate.BatchMsg
  6505. }
  6506. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  6507. // batchmsgOption allows management of the mutation configuration using functional options.
  6508. type batchmsgOption func(*BatchMsgMutation)
  6509. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  6510. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  6511. m := &BatchMsgMutation{
  6512. config: c,
  6513. op: op,
  6514. typ: TypeBatchMsg,
  6515. clearedFields: make(map[string]struct{}),
  6516. }
  6517. for _, opt := range opts {
  6518. opt(m)
  6519. }
  6520. return m
  6521. }
  6522. // withBatchMsgID sets the ID field of the mutation.
  6523. func withBatchMsgID(id uint64) batchmsgOption {
  6524. return func(m *BatchMsgMutation) {
  6525. var (
  6526. err error
  6527. once sync.Once
  6528. value *BatchMsg
  6529. )
  6530. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  6531. once.Do(func() {
  6532. if m.done {
  6533. err = errors.New("querying old values post mutation is not allowed")
  6534. } else {
  6535. value, err = m.Client().BatchMsg.Get(ctx, id)
  6536. }
  6537. })
  6538. return value, err
  6539. }
  6540. m.id = &id
  6541. }
  6542. }
  6543. // withBatchMsg sets the old BatchMsg of the mutation.
  6544. func withBatchMsg(node *BatchMsg) batchmsgOption {
  6545. return func(m *BatchMsgMutation) {
  6546. m.oldValue = func(context.Context) (*BatchMsg, error) {
  6547. return node, nil
  6548. }
  6549. m.id = &node.ID
  6550. }
  6551. }
  6552. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6553. // executed in a transaction (ent.Tx), a transactional client is returned.
  6554. func (m BatchMsgMutation) Client() *Client {
  6555. client := &Client{config: m.config}
  6556. client.init()
  6557. return client
  6558. }
  6559. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6560. // it returns an error otherwise.
  6561. func (m BatchMsgMutation) Tx() (*Tx, error) {
  6562. if _, ok := m.driver.(*txDriver); !ok {
  6563. return nil, errors.New("ent: mutation is not running in a transaction")
  6564. }
  6565. tx := &Tx{config: m.config}
  6566. tx.init()
  6567. return tx, nil
  6568. }
  6569. // SetID sets the value of the id field. Note that this
  6570. // operation is only accepted on creation of BatchMsg entities.
  6571. func (m *BatchMsgMutation) SetID(id uint64) {
  6572. m.id = &id
  6573. }
  6574. // ID returns the ID value in the mutation. Note that the ID is only available
  6575. // if it was provided to the builder or after it was returned from the database.
  6576. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  6577. if m.id == nil {
  6578. return
  6579. }
  6580. return *m.id, true
  6581. }
  6582. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6583. // That means, if the mutation is applied within a transaction with an isolation level such
  6584. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6585. // or updated by the mutation.
  6586. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6587. switch {
  6588. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6589. id, exists := m.ID()
  6590. if exists {
  6591. return []uint64{id}, nil
  6592. }
  6593. fallthrough
  6594. case m.op.Is(OpUpdate | OpDelete):
  6595. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  6596. default:
  6597. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6598. }
  6599. }
  6600. // SetCreatedAt sets the "created_at" field.
  6601. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  6602. m.created_at = &t
  6603. }
  6604. // CreatedAt returns the value of the "created_at" field in the mutation.
  6605. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  6606. v := m.created_at
  6607. if v == nil {
  6608. return
  6609. }
  6610. return *v, true
  6611. }
  6612. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  6613. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6615. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6616. if !m.op.Is(OpUpdateOne) {
  6617. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6618. }
  6619. if m.id == nil || m.oldValue == nil {
  6620. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6621. }
  6622. oldValue, err := m.oldValue(ctx)
  6623. if err != nil {
  6624. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6625. }
  6626. return oldValue.CreatedAt, nil
  6627. }
  6628. // ResetCreatedAt resets all changes to the "created_at" field.
  6629. func (m *BatchMsgMutation) ResetCreatedAt() {
  6630. m.created_at = nil
  6631. }
  6632. // SetUpdatedAt sets the "updated_at" field.
  6633. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  6634. m.updated_at = &t
  6635. }
  6636. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6637. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6638. v := m.updated_at
  6639. if v == nil {
  6640. return
  6641. }
  6642. return *v, true
  6643. }
  6644. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  6645. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6647. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6648. if !m.op.Is(OpUpdateOne) {
  6649. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6650. }
  6651. if m.id == nil || m.oldValue == nil {
  6652. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6653. }
  6654. oldValue, err := m.oldValue(ctx)
  6655. if err != nil {
  6656. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6657. }
  6658. return oldValue.UpdatedAt, nil
  6659. }
  6660. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6661. func (m *BatchMsgMutation) ResetUpdatedAt() {
  6662. m.updated_at = nil
  6663. }
  6664. // SetDeletedAt sets the "deleted_at" field.
  6665. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  6666. m.deleted_at = &t
  6667. }
  6668. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6669. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  6670. v := m.deleted_at
  6671. if v == nil {
  6672. return
  6673. }
  6674. return *v, true
  6675. }
  6676. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  6677. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6679. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6680. if !m.op.Is(OpUpdateOne) {
  6681. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6682. }
  6683. if m.id == nil || m.oldValue == nil {
  6684. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6685. }
  6686. oldValue, err := m.oldValue(ctx)
  6687. if err != nil {
  6688. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6689. }
  6690. return oldValue.DeletedAt, nil
  6691. }
  6692. // ClearDeletedAt clears the value of the "deleted_at" field.
  6693. func (m *BatchMsgMutation) ClearDeletedAt() {
  6694. m.deleted_at = nil
  6695. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  6696. }
  6697. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6698. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  6699. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  6700. return ok
  6701. }
  6702. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6703. func (m *BatchMsgMutation) ResetDeletedAt() {
  6704. m.deleted_at = nil
  6705. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  6706. }
  6707. // SetStatus sets the "status" field.
  6708. func (m *BatchMsgMutation) SetStatus(u uint8) {
  6709. m.status = &u
  6710. m.addstatus = nil
  6711. }
  6712. // Status returns the value of the "status" field in the mutation.
  6713. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  6714. v := m.status
  6715. if v == nil {
  6716. return
  6717. }
  6718. return *v, true
  6719. }
  6720. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  6721. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6723. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6724. if !m.op.Is(OpUpdateOne) {
  6725. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6726. }
  6727. if m.id == nil || m.oldValue == nil {
  6728. return v, errors.New("OldStatus requires an ID field in the mutation")
  6729. }
  6730. oldValue, err := m.oldValue(ctx)
  6731. if err != nil {
  6732. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6733. }
  6734. return oldValue.Status, nil
  6735. }
  6736. // AddStatus adds u to the "status" field.
  6737. func (m *BatchMsgMutation) AddStatus(u int8) {
  6738. if m.addstatus != nil {
  6739. *m.addstatus += u
  6740. } else {
  6741. m.addstatus = &u
  6742. }
  6743. }
  6744. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6745. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  6746. v := m.addstatus
  6747. if v == nil {
  6748. return
  6749. }
  6750. return *v, true
  6751. }
  6752. // ClearStatus clears the value of the "status" field.
  6753. func (m *BatchMsgMutation) ClearStatus() {
  6754. m.status = nil
  6755. m.addstatus = nil
  6756. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  6757. }
  6758. // StatusCleared returns if the "status" field was cleared in this mutation.
  6759. func (m *BatchMsgMutation) StatusCleared() bool {
  6760. _, ok := m.clearedFields[batchmsg.FieldStatus]
  6761. return ok
  6762. }
  6763. // ResetStatus resets all changes to the "status" field.
  6764. func (m *BatchMsgMutation) ResetStatus() {
  6765. m.status = nil
  6766. m.addstatus = nil
  6767. delete(m.clearedFields, batchmsg.FieldStatus)
  6768. }
  6769. // SetBatchNo sets the "batch_no" field.
  6770. func (m *BatchMsgMutation) SetBatchNo(s string) {
  6771. m.batch_no = &s
  6772. }
  6773. // BatchNo returns the value of the "batch_no" field in the mutation.
  6774. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  6775. v := m.batch_no
  6776. if v == nil {
  6777. return
  6778. }
  6779. return *v, true
  6780. }
  6781. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  6782. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6784. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6785. if !m.op.Is(OpUpdateOne) {
  6786. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6787. }
  6788. if m.id == nil || m.oldValue == nil {
  6789. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6790. }
  6791. oldValue, err := m.oldValue(ctx)
  6792. if err != nil {
  6793. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6794. }
  6795. return oldValue.BatchNo, nil
  6796. }
  6797. // ClearBatchNo clears the value of the "batch_no" field.
  6798. func (m *BatchMsgMutation) ClearBatchNo() {
  6799. m.batch_no = nil
  6800. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  6801. }
  6802. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6803. func (m *BatchMsgMutation) BatchNoCleared() bool {
  6804. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  6805. return ok
  6806. }
  6807. // ResetBatchNo resets all changes to the "batch_no" field.
  6808. func (m *BatchMsgMutation) ResetBatchNo() {
  6809. m.batch_no = nil
  6810. delete(m.clearedFields, batchmsg.FieldBatchNo)
  6811. }
  6812. // SetTaskName sets the "task_name" field.
  6813. func (m *BatchMsgMutation) SetTaskName(s string) {
  6814. m.task_name = &s
  6815. }
  6816. // TaskName returns the value of the "task_name" field in the mutation.
  6817. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  6818. v := m.task_name
  6819. if v == nil {
  6820. return
  6821. }
  6822. return *v, true
  6823. }
  6824. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  6825. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6827. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  6828. if !m.op.Is(OpUpdateOne) {
  6829. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  6830. }
  6831. if m.id == nil || m.oldValue == nil {
  6832. return v, errors.New("OldTaskName requires an ID field in the mutation")
  6833. }
  6834. oldValue, err := m.oldValue(ctx)
  6835. if err != nil {
  6836. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  6837. }
  6838. return oldValue.TaskName, nil
  6839. }
  6840. // ClearTaskName clears the value of the "task_name" field.
  6841. func (m *BatchMsgMutation) ClearTaskName() {
  6842. m.task_name = nil
  6843. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  6844. }
  6845. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  6846. func (m *BatchMsgMutation) TaskNameCleared() bool {
  6847. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  6848. return ok
  6849. }
  6850. // ResetTaskName resets all changes to the "task_name" field.
  6851. func (m *BatchMsgMutation) ResetTaskName() {
  6852. m.task_name = nil
  6853. delete(m.clearedFields, batchmsg.FieldTaskName)
  6854. }
  6855. // SetFromwxid sets the "fromwxid" field.
  6856. func (m *BatchMsgMutation) SetFromwxid(s string) {
  6857. m.fromwxid = &s
  6858. }
  6859. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6860. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  6861. v := m.fromwxid
  6862. if v == nil {
  6863. return
  6864. }
  6865. return *v, true
  6866. }
  6867. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  6868. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6870. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  6871. if !m.op.Is(OpUpdateOne) {
  6872. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  6873. }
  6874. if m.id == nil || m.oldValue == nil {
  6875. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  6876. }
  6877. oldValue, err := m.oldValue(ctx)
  6878. if err != nil {
  6879. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  6880. }
  6881. return oldValue.Fromwxid, nil
  6882. }
  6883. // ClearFromwxid clears the value of the "fromwxid" field.
  6884. func (m *BatchMsgMutation) ClearFromwxid() {
  6885. m.fromwxid = nil
  6886. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  6887. }
  6888. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  6889. func (m *BatchMsgMutation) FromwxidCleared() bool {
  6890. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  6891. return ok
  6892. }
  6893. // ResetFromwxid resets all changes to the "fromwxid" field.
  6894. func (m *BatchMsgMutation) ResetFromwxid() {
  6895. m.fromwxid = nil
  6896. delete(m.clearedFields, batchmsg.FieldFromwxid)
  6897. }
  6898. // SetMsg sets the "msg" field.
  6899. func (m *BatchMsgMutation) SetMsg(s string) {
  6900. m.msg = &s
  6901. }
  6902. // Msg returns the value of the "msg" field in the mutation.
  6903. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  6904. v := m.msg
  6905. if v == nil {
  6906. return
  6907. }
  6908. return *v, true
  6909. }
  6910. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  6911. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6913. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  6914. if !m.op.Is(OpUpdateOne) {
  6915. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  6916. }
  6917. if m.id == nil || m.oldValue == nil {
  6918. return v, errors.New("OldMsg requires an ID field in the mutation")
  6919. }
  6920. oldValue, err := m.oldValue(ctx)
  6921. if err != nil {
  6922. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  6923. }
  6924. return oldValue.Msg, nil
  6925. }
  6926. // ClearMsg clears the value of the "msg" field.
  6927. func (m *BatchMsgMutation) ClearMsg() {
  6928. m.msg = nil
  6929. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  6930. }
  6931. // MsgCleared returns if the "msg" field was cleared in this mutation.
  6932. func (m *BatchMsgMutation) MsgCleared() bool {
  6933. _, ok := m.clearedFields[batchmsg.FieldMsg]
  6934. return ok
  6935. }
  6936. // ResetMsg resets all changes to the "msg" field.
  6937. func (m *BatchMsgMutation) ResetMsg() {
  6938. m.msg = nil
  6939. delete(m.clearedFields, batchmsg.FieldMsg)
  6940. }
  6941. // SetTag sets the "tag" field.
  6942. func (m *BatchMsgMutation) SetTag(s string) {
  6943. m.tag = &s
  6944. }
  6945. // Tag returns the value of the "tag" field in the mutation.
  6946. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  6947. v := m.tag
  6948. if v == nil {
  6949. return
  6950. }
  6951. return *v, true
  6952. }
  6953. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  6954. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6956. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  6957. if !m.op.Is(OpUpdateOne) {
  6958. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  6959. }
  6960. if m.id == nil || m.oldValue == nil {
  6961. return v, errors.New("OldTag requires an ID field in the mutation")
  6962. }
  6963. oldValue, err := m.oldValue(ctx)
  6964. if err != nil {
  6965. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  6966. }
  6967. return oldValue.Tag, nil
  6968. }
  6969. // ClearTag clears the value of the "tag" field.
  6970. func (m *BatchMsgMutation) ClearTag() {
  6971. m.tag = nil
  6972. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  6973. }
  6974. // TagCleared returns if the "tag" field was cleared in this mutation.
  6975. func (m *BatchMsgMutation) TagCleared() bool {
  6976. _, ok := m.clearedFields[batchmsg.FieldTag]
  6977. return ok
  6978. }
  6979. // ResetTag resets all changes to the "tag" field.
  6980. func (m *BatchMsgMutation) ResetTag() {
  6981. m.tag = nil
  6982. delete(m.clearedFields, batchmsg.FieldTag)
  6983. }
  6984. // SetTagids sets the "tagids" field.
  6985. func (m *BatchMsgMutation) SetTagids(s string) {
  6986. m.tagids = &s
  6987. }
  6988. // Tagids returns the value of the "tagids" field in the mutation.
  6989. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  6990. v := m.tagids
  6991. if v == nil {
  6992. return
  6993. }
  6994. return *v, true
  6995. }
  6996. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  6997. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6999. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  7000. if !m.op.Is(OpUpdateOne) {
  7001. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  7002. }
  7003. if m.id == nil || m.oldValue == nil {
  7004. return v, errors.New("OldTagids requires an ID field in the mutation")
  7005. }
  7006. oldValue, err := m.oldValue(ctx)
  7007. if err != nil {
  7008. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  7009. }
  7010. return oldValue.Tagids, nil
  7011. }
  7012. // ClearTagids clears the value of the "tagids" field.
  7013. func (m *BatchMsgMutation) ClearTagids() {
  7014. m.tagids = nil
  7015. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  7016. }
  7017. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  7018. func (m *BatchMsgMutation) TagidsCleared() bool {
  7019. _, ok := m.clearedFields[batchmsg.FieldTagids]
  7020. return ok
  7021. }
  7022. // ResetTagids resets all changes to the "tagids" field.
  7023. func (m *BatchMsgMutation) ResetTagids() {
  7024. m.tagids = nil
  7025. delete(m.clearedFields, batchmsg.FieldTagids)
  7026. }
  7027. // SetTotal sets the "total" field.
  7028. func (m *BatchMsgMutation) SetTotal(i int32) {
  7029. m.total = &i
  7030. m.addtotal = nil
  7031. }
  7032. // Total returns the value of the "total" field in the mutation.
  7033. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  7034. v := m.total
  7035. if v == nil {
  7036. return
  7037. }
  7038. return *v, true
  7039. }
  7040. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  7041. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7043. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  7044. if !m.op.Is(OpUpdateOne) {
  7045. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  7046. }
  7047. if m.id == nil || m.oldValue == nil {
  7048. return v, errors.New("OldTotal requires an ID field in the mutation")
  7049. }
  7050. oldValue, err := m.oldValue(ctx)
  7051. if err != nil {
  7052. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  7053. }
  7054. return oldValue.Total, nil
  7055. }
  7056. // AddTotal adds i to the "total" field.
  7057. func (m *BatchMsgMutation) AddTotal(i int32) {
  7058. if m.addtotal != nil {
  7059. *m.addtotal += i
  7060. } else {
  7061. m.addtotal = &i
  7062. }
  7063. }
  7064. // AddedTotal returns the value that was added to the "total" field in this mutation.
  7065. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  7066. v := m.addtotal
  7067. if v == nil {
  7068. return
  7069. }
  7070. return *v, true
  7071. }
  7072. // ClearTotal clears the value of the "total" field.
  7073. func (m *BatchMsgMutation) ClearTotal() {
  7074. m.total = nil
  7075. m.addtotal = nil
  7076. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  7077. }
  7078. // TotalCleared returns if the "total" field was cleared in this mutation.
  7079. func (m *BatchMsgMutation) TotalCleared() bool {
  7080. _, ok := m.clearedFields[batchmsg.FieldTotal]
  7081. return ok
  7082. }
  7083. // ResetTotal resets all changes to the "total" field.
  7084. func (m *BatchMsgMutation) ResetTotal() {
  7085. m.total = nil
  7086. m.addtotal = nil
  7087. delete(m.clearedFields, batchmsg.FieldTotal)
  7088. }
  7089. // SetSuccess sets the "success" field.
  7090. func (m *BatchMsgMutation) SetSuccess(i int32) {
  7091. m.success = &i
  7092. m.addsuccess = nil
  7093. }
  7094. // Success returns the value of the "success" field in the mutation.
  7095. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  7096. v := m.success
  7097. if v == nil {
  7098. return
  7099. }
  7100. return *v, true
  7101. }
  7102. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  7103. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7105. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  7106. if !m.op.Is(OpUpdateOne) {
  7107. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  7108. }
  7109. if m.id == nil || m.oldValue == nil {
  7110. return v, errors.New("OldSuccess requires an ID field in the mutation")
  7111. }
  7112. oldValue, err := m.oldValue(ctx)
  7113. if err != nil {
  7114. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  7115. }
  7116. return oldValue.Success, nil
  7117. }
  7118. // AddSuccess adds i to the "success" field.
  7119. func (m *BatchMsgMutation) AddSuccess(i int32) {
  7120. if m.addsuccess != nil {
  7121. *m.addsuccess += i
  7122. } else {
  7123. m.addsuccess = &i
  7124. }
  7125. }
  7126. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  7127. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  7128. v := m.addsuccess
  7129. if v == nil {
  7130. return
  7131. }
  7132. return *v, true
  7133. }
  7134. // ClearSuccess clears the value of the "success" field.
  7135. func (m *BatchMsgMutation) ClearSuccess() {
  7136. m.success = nil
  7137. m.addsuccess = nil
  7138. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  7139. }
  7140. // SuccessCleared returns if the "success" field was cleared in this mutation.
  7141. func (m *BatchMsgMutation) SuccessCleared() bool {
  7142. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  7143. return ok
  7144. }
  7145. // ResetSuccess resets all changes to the "success" field.
  7146. func (m *BatchMsgMutation) ResetSuccess() {
  7147. m.success = nil
  7148. m.addsuccess = nil
  7149. delete(m.clearedFields, batchmsg.FieldSuccess)
  7150. }
  7151. // SetFail sets the "fail" field.
  7152. func (m *BatchMsgMutation) SetFail(i int32) {
  7153. m.fail = &i
  7154. m.addfail = nil
  7155. }
  7156. // Fail returns the value of the "fail" field in the mutation.
  7157. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  7158. v := m.fail
  7159. if v == nil {
  7160. return
  7161. }
  7162. return *v, true
  7163. }
  7164. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  7165. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7167. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  7168. if !m.op.Is(OpUpdateOne) {
  7169. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  7170. }
  7171. if m.id == nil || m.oldValue == nil {
  7172. return v, errors.New("OldFail requires an ID field in the mutation")
  7173. }
  7174. oldValue, err := m.oldValue(ctx)
  7175. if err != nil {
  7176. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  7177. }
  7178. return oldValue.Fail, nil
  7179. }
  7180. // AddFail adds i to the "fail" field.
  7181. func (m *BatchMsgMutation) AddFail(i int32) {
  7182. if m.addfail != nil {
  7183. *m.addfail += i
  7184. } else {
  7185. m.addfail = &i
  7186. }
  7187. }
  7188. // AddedFail returns the value that was added to the "fail" field in this mutation.
  7189. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  7190. v := m.addfail
  7191. if v == nil {
  7192. return
  7193. }
  7194. return *v, true
  7195. }
  7196. // ClearFail clears the value of the "fail" field.
  7197. func (m *BatchMsgMutation) ClearFail() {
  7198. m.fail = nil
  7199. m.addfail = nil
  7200. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  7201. }
  7202. // FailCleared returns if the "fail" field was cleared in this mutation.
  7203. func (m *BatchMsgMutation) FailCleared() bool {
  7204. _, ok := m.clearedFields[batchmsg.FieldFail]
  7205. return ok
  7206. }
  7207. // ResetFail resets all changes to the "fail" field.
  7208. func (m *BatchMsgMutation) ResetFail() {
  7209. m.fail = nil
  7210. m.addfail = nil
  7211. delete(m.clearedFields, batchmsg.FieldFail)
  7212. }
  7213. // SetStartTime sets the "start_time" field.
  7214. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  7215. m.start_time = &t
  7216. }
  7217. // StartTime returns the value of the "start_time" field in the mutation.
  7218. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  7219. v := m.start_time
  7220. if v == nil {
  7221. return
  7222. }
  7223. return *v, true
  7224. }
  7225. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  7226. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7228. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  7229. if !m.op.Is(OpUpdateOne) {
  7230. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  7231. }
  7232. if m.id == nil || m.oldValue == nil {
  7233. return v, errors.New("OldStartTime requires an ID field in the mutation")
  7234. }
  7235. oldValue, err := m.oldValue(ctx)
  7236. if err != nil {
  7237. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  7238. }
  7239. return oldValue.StartTime, nil
  7240. }
  7241. // ClearStartTime clears the value of the "start_time" field.
  7242. func (m *BatchMsgMutation) ClearStartTime() {
  7243. m.start_time = nil
  7244. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  7245. }
  7246. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  7247. func (m *BatchMsgMutation) StartTimeCleared() bool {
  7248. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  7249. return ok
  7250. }
  7251. // ResetStartTime resets all changes to the "start_time" field.
  7252. func (m *BatchMsgMutation) ResetStartTime() {
  7253. m.start_time = nil
  7254. delete(m.clearedFields, batchmsg.FieldStartTime)
  7255. }
  7256. // SetStopTime sets the "stop_time" field.
  7257. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  7258. m.stop_time = &t
  7259. }
  7260. // StopTime returns the value of the "stop_time" field in the mutation.
  7261. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  7262. v := m.stop_time
  7263. if v == nil {
  7264. return
  7265. }
  7266. return *v, true
  7267. }
  7268. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  7269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7271. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  7272. if !m.op.Is(OpUpdateOne) {
  7273. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  7274. }
  7275. if m.id == nil || m.oldValue == nil {
  7276. return v, errors.New("OldStopTime requires an ID field in the mutation")
  7277. }
  7278. oldValue, err := m.oldValue(ctx)
  7279. if err != nil {
  7280. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  7281. }
  7282. return oldValue.StopTime, nil
  7283. }
  7284. // ClearStopTime clears the value of the "stop_time" field.
  7285. func (m *BatchMsgMutation) ClearStopTime() {
  7286. m.stop_time = nil
  7287. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  7288. }
  7289. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  7290. func (m *BatchMsgMutation) StopTimeCleared() bool {
  7291. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  7292. return ok
  7293. }
  7294. // ResetStopTime resets all changes to the "stop_time" field.
  7295. func (m *BatchMsgMutation) ResetStopTime() {
  7296. m.stop_time = nil
  7297. delete(m.clearedFields, batchmsg.FieldStopTime)
  7298. }
  7299. // SetSendTime sets the "send_time" field.
  7300. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  7301. m.send_time = &t
  7302. }
  7303. // SendTime returns the value of the "send_time" field in the mutation.
  7304. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  7305. v := m.send_time
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  7312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldSendTime requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  7324. }
  7325. return oldValue.SendTime, nil
  7326. }
  7327. // ClearSendTime clears the value of the "send_time" field.
  7328. func (m *BatchMsgMutation) ClearSendTime() {
  7329. m.send_time = nil
  7330. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  7331. }
  7332. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  7333. func (m *BatchMsgMutation) SendTimeCleared() bool {
  7334. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  7335. return ok
  7336. }
  7337. // ResetSendTime resets all changes to the "send_time" field.
  7338. func (m *BatchMsgMutation) ResetSendTime() {
  7339. m.send_time = nil
  7340. delete(m.clearedFields, batchmsg.FieldSendTime)
  7341. }
  7342. // SetType sets the "type" field.
  7343. func (m *BatchMsgMutation) SetType(i int32) {
  7344. m._type = &i
  7345. m.add_type = nil
  7346. }
  7347. // GetType returns the value of the "type" field in the mutation.
  7348. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  7349. v := m._type
  7350. if v == nil {
  7351. return
  7352. }
  7353. return *v, true
  7354. }
  7355. // OldType returns the old "type" field's value of the BatchMsg entity.
  7356. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7358. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  7359. if !m.op.Is(OpUpdateOne) {
  7360. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7361. }
  7362. if m.id == nil || m.oldValue == nil {
  7363. return v, errors.New("OldType requires an ID field in the mutation")
  7364. }
  7365. oldValue, err := m.oldValue(ctx)
  7366. if err != nil {
  7367. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7368. }
  7369. return oldValue.Type, nil
  7370. }
  7371. // AddType adds i to the "type" field.
  7372. func (m *BatchMsgMutation) AddType(i int32) {
  7373. if m.add_type != nil {
  7374. *m.add_type += i
  7375. } else {
  7376. m.add_type = &i
  7377. }
  7378. }
  7379. // AddedType returns the value that was added to the "type" field in this mutation.
  7380. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  7381. v := m.add_type
  7382. if v == nil {
  7383. return
  7384. }
  7385. return *v, true
  7386. }
  7387. // ClearType clears the value of the "type" field.
  7388. func (m *BatchMsgMutation) ClearType() {
  7389. m._type = nil
  7390. m.add_type = nil
  7391. m.clearedFields[batchmsg.FieldType] = struct{}{}
  7392. }
  7393. // TypeCleared returns if the "type" field was cleared in this mutation.
  7394. func (m *BatchMsgMutation) TypeCleared() bool {
  7395. _, ok := m.clearedFields[batchmsg.FieldType]
  7396. return ok
  7397. }
  7398. // ResetType resets all changes to the "type" field.
  7399. func (m *BatchMsgMutation) ResetType() {
  7400. m._type = nil
  7401. m.add_type = nil
  7402. delete(m.clearedFields, batchmsg.FieldType)
  7403. }
  7404. // SetOrganizationID sets the "organization_id" field.
  7405. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  7406. m.organization_id = &u
  7407. m.addorganization_id = nil
  7408. }
  7409. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7410. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  7411. v := m.organization_id
  7412. if v == nil {
  7413. return
  7414. }
  7415. return *v, true
  7416. }
  7417. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  7418. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7420. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7421. if !m.op.Is(OpUpdateOne) {
  7422. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7423. }
  7424. if m.id == nil || m.oldValue == nil {
  7425. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7426. }
  7427. oldValue, err := m.oldValue(ctx)
  7428. if err != nil {
  7429. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7430. }
  7431. return oldValue.OrganizationID, nil
  7432. }
  7433. // AddOrganizationID adds u to the "organization_id" field.
  7434. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  7435. if m.addorganization_id != nil {
  7436. *m.addorganization_id += u
  7437. } else {
  7438. m.addorganization_id = &u
  7439. }
  7440. }
  7441. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7442. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  7443. v := m.addorganization_id
  7444. if v == nil {
  7445. return
  7446. }
  7447. return *v, true
  7448. }
  7449. // ResetOrganizationID resets all changes to the "organization_id" field.
  7450. func (m *BatchMsgMutation) ResetOrganizationID() {
  7451. m.organization_id = nil
  7452. m.addorganization_id = nil
  7453. }
  7454. // SetCtype sets the "ctype" field.
  7455. func (m *BatchMsgMutation) SetCtype(u uint64) {
  7456. m.ctype = &u
  7457. m.addctype = nil
  7458. }
  7459. // Ctype returns the value of the "ctype" field in the mutation.
  7460. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  7461. v := m.ctype
  7462. if v == nil {
  7463. return
  7464. }
  7465. return *v, true
  7466. }
  7467. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  7468. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7470. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  7471. if !m.op.Is(OpUpdateOne) {
  7472. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  7473. }
  7474. if m.id == nil || m.oldValue == nil {
  7475. return v, errors.New("OldCtype requires an ID field in the mutation")
  7476. }
  7477. oldValue, err := m.oldValue(ctx)
  7478. if err != nil {
  7479. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  7480. }
  7481. return oldValue.Ctype, nil
  7482. }
  7483. // AddCtype adds u to the "ctype" field.
  7484. func (m *BatchMsgMutation) AddCtype(u int64) {
  7485. if m.addctype != nil {
  7486. *m.addctype += u
  7487. } else {
  7488. m.addctype = &u
  7489. }
  7490. }
  7491. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  7492. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  7493. v := m.addctype
  7494. if v == nil {
  7495. return
  7496. }
  7497. return *v, true
  7498. }
  7499. // ResetCtype resets all changes to the "ctype" field.
  7500. func (m *BatchMsgMutation) ResetCtype() {
  7501. m.ctype = nil
  7502. m.addctype = nil
  7503. }
  7504. // SetCc sets the "cc" field.
  7505. func (m *BatchMsgMutation) SetCc(s string) {
  7506. m.cc = &s
  7507. }
  7508. // Cc returns the value of the "cc" field in the mutation.
  7509. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  7510. v := m.cc
  7511. if v == nil {
  7512. return
  7513. }
  7514. return *v, true
  7515. }
  7516. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  7517. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7519. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  7520. if !m.op.Is(OpUpdateOne) {
  7521. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  7522. }
  7523. if m.id == nil || m.oldValue == nil {
  7524. return v, errors.New("OldCc requires an ID field in the mutation")
  7525. }
  7526. oldValue, err := m.oldValue(ctx)
  7527. if err != nil {
  7528. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  7529. }
  7530. return oldValue.Cc, nil
  7531. }
  7532. // ClearCc clears the value of the "cc" field.
  7533. func (m *BatchMsgMutation) ClearCc() {
  7534. m.cc = nil
  7535. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  7536. }
  7537. // CcCleared returns if the "cc" field was cleared in this mutation.
  7538. func (m *BatchMsgMutation) CcCleared() bool {
  7539. _, ok := m.clearedFields[batchmsg.FieldCc]
  7540. return ok
  7541. }
  7542. // ResetCc resets all changes to the "cc" field.
  7543. func (m *BatchMsgMutation) ResetCc() {
  7544. m.cc = nil
  7545. delete(m.clearedFields, batchmsg.FieldCc)
  7546. }
  7547. // SetPhone sets the "phone" field.
  7548. func (m *BatchMsgMutation) SetPhone(s string) {
  7549. m.phone = &s
  7550. }
  7551. // Phone returns the value of the "phone" field in the mutation.
  7552. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  7553. v := m.phone
  7554. if v == nil {
  7555. return
  7556. }
  7557. return *v, true
  7558. }
  7559. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  7560. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7562. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  7563. if !m.op.Is(OpUpdateOne) {
  7564. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  7565. }
  7566. if m.id == nil || m.oldValue == nil {
  7567. return v, errors.New("OldPhone requires an ID field in the mutation")
  7568. }
  7569. oldValue, err := m.oldValue(ctx)
  7570. if err != nil {
  7571. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  7572. }
  7573. return oldValue.Phone, nil
  7574. }
  7575. // ClearPhone clears the value of the "phone" field.
  7576. func (m *BatchMsgMutation) ClearPhone() {
  7577. m.phone = nil
  7578. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  7579. }
  7580. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  7581. func (m *BatchMsgMutation) PhoneCleared() bool {
  7582. _, ok := m.clearedFields[batchmsg.FieldPhone]
  7583. return ok
  7584. }
  7585. // ResetPhone resets all changes to the "phone" field.
  7586. func (m *BatchMsgMutation) ResetPhone() {
  7587. m.phone = nil
  7588. delete(m.clearedFields, batchmsg.FieldPhone)
  7589. }
  7590. // SetTemplateName sets the "template_name" field.
  7591. func (m *BatchMsgMutation) SetTemplateName(s string) {
  7592. m.template_name = &s
  7593. }
  7594. // TemplateName returns the value of the "template_name" field in the mutation.
  7595. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  7596. v := m.template_name
  7597. if v == nil {
  7598. return
  7599. }
  7600. return *v, true
  7601. }
  7602. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  7603. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7605. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  7606. if !m.op.Is(OpUpdateOne) {
  7607. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  7608. }
  7609. if m.id == nil || m.oldValue == nil {
  7610. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  7611. }
  7612. oldValue, err := m.oldValue(ctx)
  7613. if err != nil {
  7614. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  7615. }
  7616. return oldValue.TemplateName, nil
  7617. }
  7618. // ClearTemplateName clears the value of the "template_name" field.
  7619. func (m *BatchMsgMutation) ClearTemplateName() {
  7620. m.template_name = nil
  7621. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  7622. }
  7623. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  7624. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  7625. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  7626. return ok
  7627. }
  7628. // ResetTemplateName resets all changes to the "template_name" field.
  7629. func (m *BatchMsgMutation) ResetTemplateName() {
  7630. m.template_name = nil
  7631. delete(m.clearedFields, batchmsg.FieldTemplateName)
  7632. }
  7633. // SetTemplateCode sets the "template_code" field.
  7634. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  7635. m.template_code = &s
  7636. }
  7637. // TemplateCode returns the value of the "template_code" field in the mutation.
  7638. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  7639. v := m.template_code
  7640. if v == nil {
  7641. return
  7642. }
  7643. return *v, true
  7644. }
  7645. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  7646. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7648. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  7649. if !m.op.Is(OpUpdateOne) {
  7650. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  7651. }
  7652. if m.id == nil || m.oldValue == nil {
  7653. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  7654. }
  7655. oldValue, err := m.oldValue(ctx)
  7656. if err != nil {
  7657. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  7658. }
  7659. return oldValue.TemplateCode, nil
  7660. }
  7661. // ClearTemplateCode clears the value of the "template_code" field.
  7662. func (m *BatchMsgMutation) ClearTemplateCode() {
  7663. m.template_code = nil
  7664. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  7665. }
  7666. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  7667. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  7668. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  7669. return ok
  7670. }
  7671. // ResetTemplateCode resets all changes to the "template_code" field.
  7672. func (m *BatchMsgMutation) ResetTemplateCode() {
  7673. m.template_code = nil
  7674. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  7675. }
  7676. // SetLang sets the "lang" field.
  7677. func (m *BatchMsgMutation) SetLang(s string) {
  7678. m.lang = &s
  7679. }
  7680. // Lang returns the value of the "lang" field in the mutation.
  7681. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  7682. v := m.lang
  7683. if v == nil {
  7684. return
  7685. }
  7686. return *v, true
  7687. }
  7688. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  7689. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7691. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  7692. if !m.op.Is(OpUpdateOne) {
  7693. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  7694. }
  7695. if m.id == nil || m.oldValue == nil {
  7696. return v, errors.New("OldLang requires an ID field in the mutation")
  7697. }
  7698. oldValue, err := m.oldValue(ctx)
  7699. if err != nil {
  7700. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  7701. }
  7702. return oldValue.Lang, nil
  7703. }
  7704. // ClearLang clears the value of the "lang" field.
  7705. func (m *BatchMsgMutation) ClearLang() {
  7706. m.lang = nil
  7707. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  7708. }
  7709. // LangCleared returns if the "lang" field was cleared in this mutation.
  7710. func (m *BatchMsgMutation) LangCleared() bool {
  7711. _, ok := m.clearedFields[batchmsg.FieldLang]
  7712. return ok
  7713. }
  7714. // ResetLang resets all changes to the "lang" field.
  7715. func (m *BatchMsgMutation) ResetLang() {
  7716. m.lang = nil
  7717. delete(m.clearedFields, batchmsg.FieldLang)
  7718. }
  7719. // Where appends a list predicates to the BatchMsgMutation builder.
  7720. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  7721. m.predicates = append(m.predicates, ps...)
  7722. }
  7723. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  7724. // users can use type-assertion to append predicates that do not depend on any generated package.
  7725. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7726. p := make([]predicate.BatchMsg, len(ps))
  7727. for i := range ps {
  7728. p[i] = ps[i]
  7729. }
  7730. m.Where(p...)
  7731. }
  7732. // Op returns the operation name.
  7733. func (m *BatchMsgMutation) Op() Op {
  7734. return m.op
  7735. }
  7736. // SetOp allows setting the mutation operation.
  7737. func (m *BatchMsgMutation) SetOp(op Op) {
  7738. m.op = op
  7739. }
  7740. // Type returns the node type of this mutation (BatchMsg).
  7741. func (m *BatchMsgMutation) Type() string {
  7742. return m.typ
  7743. }
  7744. // Fields returns all fields that were changed during this mutation. Note that in
  7745. // order to get all numeric fields that were incremented/decremented, call
  7746. // AddedFields().
  7747. func (m *BatchMsgMutation) Fields() []string {
  7748. fields := make([]string, 0, 24)
  7749. if m.created_at != nil {
  7750. fields = append(fields, batchmsg.FieldCreatedAt)
  7751. }
  7752. if m.updated_at != nil {
  7753. fields = append(fields, batchmsg.FieldUpdatedAt)
  7754. }
  7755. if m.deleted_at != nil {
  7756. fields = append(fields, batchmsg.FieldDeletedAt)
  7757. }
  7758. if m.status != nil {
  7759. fields = append(fields, batchmsg.FieldStatus)
  7760. }
  7761. if m.batch_no != nil {
  7762. fields = append(fields, batchmsg.FieldBatchNo)
  7763. }
  7764. if m.task_name != nil {
  7765. fields = append(fields, batchmsg.FieldTaskName)
  7766. }
  7767. if m.fromwxid != nil {
  7768. fields = append(fields, batchmsg.FieldFromwxid)
  7769. }
  7770. if m.msg != nil {
  7771. fields = append(fields, batchmsg.FieldMsg)
  7772. }
  7773. if m.tag != nil {
  7774. fields = append(fields, batchmsg.FieldTag)
  7775. }
  7776. if m.tagids != nil {
  7777. fields = append(fields, batchmsg.FieldTagids)
  7778. }
  7779. if m.total != nil {
  7780. fields = append(fields, batchmsg.FieldTotal)
  7781. }
  7782. if m.success != nil {
  7783. fields = append(fields, batchmsg.FieldSuccess)
  7784. }
  7785. if m.fail != nil {
  7786. fields = append(fields, batchmsg.FieldFail)
  7787. }
  7788. if m.start_time != nil {
  7789. fields = append(fields, batchmsg.FieldStartTime)
  7790. }
  7791. if m.stop_time != nil {
  7792. fields = append(fields, batchmsg.FieldStopTime)
  7793. }
  7794. if m.send_time != nil {
  7795. fields = append(fields, batchmsg.FieldSendTime)
  7796. }
  7797. if m._type != nil {
  7798. fields = append(fields, batchmsg.FieldType)
  7799. }
  7800. if m.organization_id != nil {
  7801. fields = append(fields, batchmsg.FieldOrganizationID)
  7802. }
  7803. if m.ctype != nil {
  7804. fields = append(fields, batchmsg.FieldCtype)
  7805. }
  7806. if m.cc != nil {
  7807. fields = append(fields, batchmsg.FieldCc)
  7808. }
  7809. if m.phone != nil {
  7810. fields = append(fields, batchmsg.FieldPhone)
  7811. }
  7812. if m.template_name != nil {
  7813. fields = append(fields, batchmsg.FieldTemplateName)
  7814. }
  7815. if m.template_code != nil {
  7816. fields = append(fields, batchmsg.FieldTemplateCode)
  7817. }
  7818. if m.lang != nil {
  7819. fields = append(fields, batchmsg.FieldLang)
  7820. }
  7821. return fields
  7822. }
  7823. // Field returns the value of a field with the given name. The second boolean
  7824. // return value indicates that this field was not set, or was not defined in the
  7825. // schema.
  7826. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  7827. switch name {
  7828. case batchmsg.FieldCreatedAt:
  7829. return m.CreatedAt()
  7830. case batchmsg.FieldUpdatedAt:
  7831. return m.UpdatedAt()
  7832. case batchmsg.FieldDeletedAt:
  7833. return m.DeletedAt()
  7834. case batchmsg.FieldStatus:
  7835. return m.Status()
  7836. case batchmsg.FieldBatchNo:
  7837. return m.BatchNo()
  7838. case batchmsg.FieldTaskName:
  7839. return m.TaskName()
  7840. case batchmsg.FieldFromwxid:
  7841. return m.Fromwxid()
  7842. case batchmsg.FieldMsg:
  7843. return m.Msg()
  7844. case batchmsg.FieldTag:
  7845. return m.Tag()
  7846. case batchmsg.FieldTagids:
  7847. return m.Tagids()
  7848. case batchmsg.FieldTotal:
  7849. return m.Total()
  7850. case batchmsg.FieldSuccess:
  7851. return m.Success()
  7852. case batchmsg.FieldFail:
  7853. return m.Fail()
  7854. case batchmsg.FieldStartTime:
  7855. return m.StartTime()
  7856. case batchmsg.FieldStopTime:
  7857. return m.StopTime()
  7858. case batchmsg.FieldSendTime:
  7859. return m.SendTime()
  7860. case batchmsg.FieldType:
  7861. return m.GetType()
  7862. case batchmsg.FieldOrganizationID:
  7863. return m.OrganizationID()
  7864. case batchmsg.FieldCtype:
  7865. return m.Ctype()
  7866. case batchmsg.FieldCc:
  7867. return m.Cc()
  7868. case batchmsg.FieldPhone:
  7869. return m.Phone()
  7870. case batchmsg.FieldTemplateName:
  7871. return m.TemplateName()
  7872. case batchmsg.FieldTemplateCode:
  7873. return m.TemplateCode()
  7874. case batchmsg.FieldLang:
  7875. return m.Lang()
  7876. }
  7877. return nil, false
  7878. }
  7879. // OldField returns the old value of the field from the database. An error is
  7880. // returned if the mutation operation is not UpdateOne, or the query to the
  7881. // database failed.
  7882. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7883. switch name {
  7884. case batchmsg.FieldCreatedAt:
  7885. return m.OldCreatedAt(ctx)
  7886. case batchmsg.FieldUpdatedAt:
  7887. return m.OldUpdatedAt(ctx)
  7888. case batchmsg.FieldDeletedAt:
  7889. return m.OldDeletedAt(ctx)
  7890. case batchmsg.FieldStatus:
  7891. return m.OldStatus(ctx)
  7892. case batchmsg.FieldBatchNo:
  7893. return m.OldBatchNo(ctx)
  7894. case batchmsg.FieldTaskName:
  7895. return m.OldTaskName(ctx)
  7896. case batchmsg.FieldFromwxid:
  7897. return m.OldFromwxid(ctx)
  7898. case batchmsg.FieldMsg:
  7899. return m.OldMsg(ctx)
  7900. case batchmsg.FieldTag:
  7901. return m.OldTag(ctx)
  7902. case batchmsg.FieldTagids:
  7903. return m.OldTagids(ctx)
  7904. case batchmsg.FieldTotal:
  7905. return m.OldTotal(ctx)
  7906. case batchmsg.FieldSuccess:
  7907. return m.OldSuccess(ctx)
  7908. case batchmsg.FieldFail:
  7909. return m.OldFail(ctx)
  7910. case batchmsg.FieldStartTime:
  7911. return m.OldStartTime(ctx)
  7912. case batchmsg.FieldStopTime:
  7913. return m.OldStopTime(ctx)
  7914. case batchmsg.FieldSendTime:
  7915. return m.OldSendTime(ctx)
  7916. case batchmsg.FieldType:
  7917. return m.OldType(ctx)
  7918. case batchmsg.FieldOrganizationID:
  7919. return m.OldOrganizationID(ctx)
  7920. case batchmsg.FieldCtype:
  7921. return m.OldCtype(ctx)
  7922. case batchmsg.FieldCc:
  7923. return m.OldCc(ctx)
  7924. case batchmsg.FieldPhone:
  7925. return m.OldPhone(ctx)
  7926. case batchmsg.FieldTemplateName:
  7927. return m.OldTemplateName(ctx)
  7928. case batchmsg.FieldTemplateCode:
  7929. return m.OldTemplateCode(ctx)
  7930. case batchmsg.FieldLang:
  7931. return m.OldLang(ctx)
  7932. }
  7933. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  7934. }
  7935. // SetField sets the value of a field with the given name. It returns an error if
  7936. // the field is not defined in the schema, or if the type mismatched the field
  7937. // type.
  7938. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  7939. switch name {
  7940. case batchmsg.FieldCreatedAt:
  7941. v, ok := value.(time.Time)
  7942. if !ok {
  7943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7944. }
  7945. m.SetCreatedAt(v)
  7946. return nil
  7947. case batchmsg.FieldUpdatedAt:
  7948. v, ok := value.(time.Time)
  7949. if !ok {
  7950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7951. }
  7952. m.SetUpdatedAt(v)
  7953. return nil
  7954. case batchmsg.FieldDeletedAt:
  7955. v, ok := value.(time.Time)
  7956. if !ok {
  7957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7958. }
  7959. m.SetDeletedAt(v)
  7960. return nil
  7961. case batchmsg.FieldStatus:
  7962. v, ok := value.(uint8)
  7963. if !ok {
  7964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7965. }
  7966. m.SetStatus(v)
  7967. return nil
  7968. case batchmsg.FieldBatchNo:
  7969. v, ok := value.(string)
  7970. if !ok {
  7971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7972. }
  7973. m.SetBatchNo(v)
  7974. return nil
  7975. case batchmsg.FieldTaskName:
  7976. v, ok := value.(string)
  7977. if !ok {
  7978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7979. }
  7980. m.SetTaskName(v)
  7981. return nil
  7982. case batchmsg.FieldFromwxid:
  7983. v, ok := value.(string)
  7984. if !ok {
  7985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7986. }
  7987. m.SetFromwxid(v)
  7988. return nil
  7989. case batchmsg.FieldMsg:
  7990. v, ok := value.(string)
  7991. if !ok {
  7992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7993. }
  7994. m.SetMsg(v)
  7995. return nil
  7996. case batchmsg.FieldTag:
  7997. v, ok := value.(string)
  7998. if !ok {
  7999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8000. }
  8001. m.SetTag(v)
  8002. return nil
  8003. case batchmsg.FieldTagids:
  8004. v, ok := value.(string)
  8005. if !ok {
  8006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8007. }
  8008. m.SetTagids(v)
  8009. return nil
  8010. case batchmsg.FieldTotal:
  8011. v, ok := value.(int32)
  8012. if !ok {
  8013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8014. }
  8015. m.SetTotal(v)
  8016. return nil
  8017. case batchmsg.FieldSuccess:
  8018. v, ok := value.(int32)
  8019. if !ok {
  8020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8021. }
  8022. m.SetSuccess(v)
  8023. return nil
  8024. case batchmsg.FieldFail:
  8025. v, ok := value.(int32)
  8026. if !ok {
  8027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8028. }
  8029. m.SetFail(v)
  8030. return nil
  8031. case batchmsg.FieldStartTime:
  8032. v, ok := value.(time.Time)
  8033. if !ok {
  8034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8035. }
  8036. m.SetStartTime(v)
  8037. return nil
  8038. case batchmsg.FieldStopTime:
  8039. v, ok := value.(time.Time)
  8040. if !ok {
  8041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8042. }
  8043. m.SetStopTime(v)
  8044. return nil
  8045. case batchmsg.FieldSendTime:
  8046. v, ok := value.(time.Time)
  8047. if !ok {
  8048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8049. }
  8050. m.SetSendTime(v)
  8051. return nil
  8052. case batchmsg.FieldType:
  8053. v, ok := value.(int32)
  8054. if !ok {
  8055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8056. }
  8057. m.SetType(v)
  8058. return nil
  8059. case batchmsg.FieldOrganizationID:
  8060. v, ok := value.(uint64)
  8061. if !ok {
  8062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8063. }
  8064. m.SetOrganizationID(v)
  8065. return nil
  8066. case batchmsg.FieldCtype:
  8067. v, ok := value.(uint64)
  8068. if !ok {
  8069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8070. }
  8071. m.SetCtype(v)
  8072. return nil
  8073. case batchmsg.FieldCc:
  8074. v, ok := value.(string)
  8075. if !ok {
  8076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8077. }
  8078. m.SetCc(v)
  8079. return nil
  8080. case batchmsg.FieldPhone:
  8081. v, ok := value.(string)
  8082. if !ok {
  8083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8084. }
  8085. m.SetPhone(v)
  8086. return nil
  8087. case batchmsg.FieldTemplateName:
  8088. v, ok := value.(string)
  8089. if !ok {
  8090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8091. }
  8092. m.SetTemplateName(v)
  8093. return nil
  8094. case batchmsg.FieldTemplateCode:
  8095. v, ok := value.(string)
  8096. if !ok {
  8097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8098. }
  8099. m.SetTemplateCode(v)
  8100. return nil
  8101. case batchmsg.FieldLang:
  8102. v, ok := value.(string)
  8103. if !ok {
  8104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8105. }
  8106. m.SetLang(v)
  8107. return nil
  8108. }
  8109. return fmt.Errorf("unknown BatchMsg field %s", name)
  8110. }
  8111. // AddedFields returns all numeric fields that were incremented/decremented during
  8112. // this mutation.
  8113. func (m *BatchMsgMutation) AddedFields() []string {
  8114. var fields []string
  8115. if m.addstatus != nil {
  8116. fields = append(fields, batchmsg.FieldStatus)
  8117. }
  8118. if m.addtotal != nil {
  8119. fields = append(fields, batchmsg.FieldTotal)
  8120. }
  8121. if m.addsuccess != nil {
  8122. fields = append(fields, batchmsg.FieldSuccess)
  8123. }
  8124. if m.addfail != nil {
  8125. fields = append(fields, batchmsg.FieldFail)
  8126. }
  8127. if m.add_type != nil {
  8128. fields = append(fields, batchmsg.FieldType)
  8129. }
  8130. if m.addorganization_id != nil {
  8131. fields = append(fields, batchmsg.FieldOrganizationID)
  8132. }
  8133. if m.addctype != nil {
  8134. fields = append(fields, batchmsg.FieldCtype)
  8135. }
  8136. return fields
  8137. }
  8138. // AddedField returns the numeric value that was incremented/decremented on a field
  8139. // with the given name. The second boolean return value indicates that this field
  8140. // was not set, or was not defined in the schema.
  8141. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  8142. switch name {
  8143. case batchmsg.FieldStatus:
  8144. return m.AddedStatus()
  8145. case batchmsg.FieldTotal:
  8146. return m.AddedTotal()
  8147. case batchmsg.FieldSuccess:
  8148. return m.AddedSuccess()
  8149. case batchmsg.FieldFail:
  8150. return m.AddedFail()
  8151. case batchmsg.FieldType:
  8152. return m.AddedType()
  8153. case batchmsg.FieldOrganizationID:
  8154. return m.AddedOrganizationID()
  8155. case batchmsg.FieldCtype:
  8156. return m.AddedCtype()
  8157. }
  8158. return nil, false
  8159. }
  8160. // AddField adds the value to the field with the given name. It returns an error if
  8161. // the field is not defined in the schema, or if the type mismatched the field
  8162. // type.
  8163. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  8164. switch name {
  8165. case batchmsg.FieldStatus:
  8166. v, ok := value.(int8)
  8167. if !ok {
  8168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8169. }
  8170. m.AddStatus(v)
  8171. return nil
  8172. case batchmsg.FieldTotal:
  8173. v, ok := value.(int32)
  8174. if !ok {
  8175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8176. }
  8177. m.AddTotal(v)
  8178. return nil
  8179. case batchmsg.FieldSuccess:
  8180. v, ok := value.(int32)
  8181. if !ok {
  8182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8183. }
  8184. m.AddSuccess(v)
  8185. return nil
  8186. case batchmsg.FieldFail:
  8187. v, ok := value.(int32)
  8188. if !ok {
  8189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8190. }
  8191. m.AddFail(v)
  8192. return nil
  8193. case batchmsg.FieldType:
  8194. v, ok := value.(int32)
  8195. if !ok {
  8196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8197. }
  8198. m.AddType(v)
  8199. return nil
  8200. case batchmsg.FieldOrganizationID:
  8201. v, ok := value.(int64)
  8202. if !ok {
  8203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8204. }
  8205. m.AddOrganizationID(v)
  8206. return nil
  8207. case batchmsg.FieldCtype:
  8208. v, ok := value.(int64)
  8209. if !ok {
  8210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8211. }
  8212. m.AddCtype(v)
  8213. return nil
  8214. }
  8215. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  8216. }
  8217. // ClearedFields returns all nullable fields that were cleared during this
  8218. // mutation.
  8219. func (m *BatchMsgMutation) ClearedFields() []string {
  8220. var fields []string
  8221. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  8222. fields = append(fields, batchmsg.FieldDeletedAt)
  8223. }
  8224. if m.FieldCleared(batchmsg.FieldStatus) {
  8225. fields = append(fields, batchmsg.FieldStatus)
  8226. }
  8227. if m.FieldCleared(batchmsg.FieldBatchNo) {
  8228. fields = append(fields, batchmsg.FieldBatchNo)
  8229. }
  8230. if m.FieldCleared(batchmsg.FieldTaskName) {
  8231. fields = append(fields, batchmsg.FieldTaskName)
  8232. }
  8233. if m.FieldCleared(batchmsg.FieldFromwxid) {
  8234. fields = append(fields, batchmsg.FieldFromwxid)
  8235. }
  8236. if m.FieldCleared(batchmsg.FieldMsg) {
  8237. fields = append(fields, batchmsg.FieldMsg)
  8238. }
  8239. if m.FieldCleared(batchmsg.FieldTag) {
  8240. fields = append(fields, batchmsg.FieldTag)
  8241. }
  8242. if m.FieldCleared(batchmsg.FieldTagids) {
  8243. fields = append(fields, batchmsg.FieldTagids)
  8244. }
  8245. if m.FieldCleared(batchmsg.FieldTotal) {
  8246. fields = append(fields, batchmsg.FieldTotal)
  8247. }
  8248. if m.FieldCleared(batchmsg.FieldSuccess) {
  8249. fields = append(fields, batchmsg.FieldSuccess)
  8250. }
  8251. if m.FieldCleared(batchmsg.FieldFail) {
  8252. fields = append(fields, batchmsg.FieldFail)
  8253. }
  8254. if m.FieldCleared(batchmsg.FieldStartTime) {
  8255. fields = append(fields, batchmsg.FieldStartTime)
  8256. }
  8257. if m.FieldCleared(batchmsg.FieldStopTime) {
  8258. fields = append(fields, batchmsg.FieldStopTime)
  8259. }
  8260. if m.FieldCleared(batchmsg.FieldSendTime) {
  8261. fields = append(fields, batchmsg.FieldSendTime)
  8262. }
  8263. if m.FieldCleared(batchmsg.FieldType) {
  8264. fields = append(fields, batchmsg.FieldType)
  8265. }
  8266. if m.FieldCleared(batchmsg.FieldCc) {
  8267. fields = append(fields, batchmsg.FieldCc)
  8268. }
  8269. if m.FieldCleared(batchmsg.FieldPhone) {
  8270. fields = append(fields, batchmsg.FieldPhone)
  8271. }
  8272. if m.FieldCleared(batchmsg.FieldTemplateName) {
  8273. fields = append(fields, batchmsg.FieldTemplateName)
  8274. }
  8275. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  8276. fields = append(fields, batchmsg.FieldTemplateCode)
  8277. }
  8278. if m.FieldCleared(batchmsg.FieldLang) {
  8279. fields = append(fields, batchmsg.FieldLang)
  8280. }
  8281. return fields
  8282. }
  8283. // FieldCleared returns a boolean indicating if a field with the given name was
  8284. // cleared in this mutation.
  8285. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  8286. _, ok := m.clearedFields[name]
  8287. return ok
  8288. }
  8289. // ClearField clears the value of the field with the given name. It returns an
  8290. // error if the field is not defined in the schema.
  8291. func (m *BatchMsgMutation) ClearField(name string) error {
  8292. switch name {
  8293. case batchmsg.FieldDeletedAt:
  8294. m.ClearDeletedAt()
  8295. return nil
  8296. case batchmsg.FieldStatus:
  8297. m.ClearStatus()
  8298. return nil
  8299. case batchmsg.FieldBatchNo:
  8300. m.ClearBatchNo()
  8301. return nil
  8302. case batchmsg.FieldTaskName:
  8303. m.ClearTaskName()
  8304. return nil
  8305. case batchmsg.FieldFromwxid:
  8306. m.ClearFromwxid()
  8307. return nil
  8308. case batchmsg.FieldMsg:
  8309. m.ClearMsg()
  8310. return nil
  8311. case batchmsg.FieldTag:
  8312. m.ClearTag()
  8313. return nil
  8314. case batchmsg.FieldTagids:
  8315. m.ClearTagids()
  8316. return nil
  8317. case batchmsg.FieldTotal:
  8318. m.ClearTotal()
  8319. return nil
  8320. case batchmsg.FieldSuccess:
  8321. m.ClearSuccess()
  8322. return nil
  8323. case batchmsg.FieldFail:
  8324. m.ClearFail()
  8325. return nil
  8326. case batchmsg.FieldStartTime:
  8327. m.ClearStartTime()
  8328. return nil
  8329. case batchmsg.FieldStopTime:
  8330. m.ClearStopTime()
  8331. return nil
  8332. case batchmsg.FieldSendTime:
  8333. m.ClearSendTime()
  8334. return nil
  8335. case batchmsg.FieldType:
  8336. m.ClearType()
  8337. return nil
  8338. case batchmsg.FieldCc:
  8339. m.ClearCc()
  8340. return nil
  8341. case batchmsg.FieldPhone:
  8342. m.ClearPhone()
  8343. return nil
  8344. case batchmsg.FieldTemplateName:
  8345. m.ClearTemplateName()
  8346. return nil
  8347. case batchmsg.FieldTemplateCode:
  8348. m.ClearTemplateCode()
  8349. return nil
  8350. case batchmsg.FieldLang:
  8351. m.ClearLang()
  8352. return nil
  8353. }
  8354. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  8355. }
  8356. // ResetField resets all changes in the mutation for the field with the given name.
  8357. // It returns an error if the field is not defined in the schema.
  8358. func (m *BatchMsgMutation) ResetField(name string) error {
  8359. switch name {
  8360. case batchmsg.FieldCreatedAt:
  8361. m.ResetCreatedAt()
  8362. return nil
  8363. case batchmsg.FieldUpdatedAt:
  8364. m.ResetUpdatedAt()
  8365. return nil
  8366. case batchmsg.FieldDeletedAt:
  8367. m.ResetDeletedAt()
  8368. return nil
  8369. case batchmsg.FieldStatus:
  8370. m.ResetStatus()
  8371. return nil
  8372. case batchmsg.FieldBatchNo:
  8373. m.ResetBatchNo()
  8374. return nil
  8375. case batchmsg.FieldTaskName:
  8376. m.ResetTaskName()
  8377. return nil
  8378. case batchmsg.FieldFromwxid:
  8379. m.ResetFromwxid()
  8380. return nil
  8381. case batchmsg.FieldMsg:
  8382. m.ResetMsg()
  8383. return nil
  8384. case batchmsg.FieldTag:
  8385. m.ResetTag()
  8386. return nil
  8387. case batchmsg.FieldTagids:
  8388. m.ResetTagids()
  8389. return nil
  8390. case batchmsg.FieldTotal:
  8391. m.ResetTotal()
  8392. return nil
  8393. case batchmsg.FieldSuccess:
  8394. m.ResetSuccess()
  8395. return nil
  8396. case batchmsg.FieldFail:
  8397. m.ResetFail()
  8398. return nil
  8399. case batchmsg.FieldStartTime:
  8400. m.ResetStartTime()
  8401. return nil
  8402. case batchmsg.FieldStopTime:
  8403. m.ResetStopTime()
  8404. return nil
  8405. case batchmsg.FieldSendTime:
  8406. m.ResetSendTime()
  8407. return nil
  8408. case batchmsg.FieldType:
  8409. m.ResetType()
  8410. return nil
  8411. case batchmsg.FieldOrganizationID:
  8412. m.ResetOrganizationID()
  8413. return nil
  8414. case batchmsg.FieldCtype:
  8415. m.ResetCtype()
  8416. return nil
  8417. case batchmsg.FieldCc:
  8418. m.ResetCc()
  8419. return nil
  8420. case batchmsg.FieldPhone:
  8421. m.ResetPhone()
  8422. return nil
  8423. case batchmsg.FieldTemplateName:
  8424. m.ResetTemplateName()
  8425. return nil
  8426. case batchmsg.FieldTemplateCode:
  8427. m.ResetTemplateCode()
  8428. return nil
  8429. case batchmsg.FieldLang:
  8430. m.ResetLang()
  8431. return nil
  8432. }
  8433. return fmt.Errorf("unknown BatchMsg field %s", name)
  8434. }
  8435. // AddedEdges returns all edge names that were set/added in this mutation.
  8436. func (m *BatchMsgMutation) AddedEdges() []string {
  8437. edges := make([]string, 0, 0)
  8438. return edges
  8439. }
  8440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8441. // name in this mutation.
  8442. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  8443. return nil
  8444. }
  8445. // RemovedEdges returns all edge names that were removed in this mutation.
  8446. func (m *BatchMsgMutation) RemovedEdges() []string {
  8447. edges := make([]string, 0, 0)
  8448. return edges
  8449. }
  8450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8451. // the given name in this mutation.
  8452. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  8453. return nil
  8454. }
  8455. // ClearedEdges returns all edge names that were cleared in this mutation.
  8456. func (m *BatchMsgMutation) ClearedEdges() []string {
  8457. edges := make([]string, 0, 0)
  8458. return edges
  8459. }
  8460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8461. // was cleared in this mutation.
  8462. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  8463. return false
  8464. }
  8465. // ClearEdge clears the value of the edge with the given name. It returns an error
  8466. // if that edge is not defined in the schema.
  8467. func (m *BatchMsgMutation) ClearEdge(name string) error {
  8468. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  8469. }
  8470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8471. // It returns an error if the edge is not defined in the schema.
  8472. func (m *BatchMsgMutation) ResetEdge(name string) error {
  8473. return fmt.Errorf("unknown BatchMsg edge %s", name)
  8474. }
  8475. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  8476. type CategoryMutation struct {
  8477. config
  8478. op Op
  8479. typ string
  8480. id *uint64
  8481. created_at *time.Time
  8482. updated_at *time.Time
  8483. deleted_at *time.Time
  8484. name *string
  8485. organization_id *uint64
  8486. addorganization_id *int64
  8487. clearedFields map[string]struct{}
  8488. done bool
  8489. oldValue func(context.Context) (*Category, error)
  8490. predicates []predicate.Category
  8491. }
  8492. var _ ent.Mutation = (*CategoryMutation)(nil)
  8493. // categoryOption allows management of the mutation configuration using functional options.
  8494. type categoryOption func(*CategoryMutation)
  8495. // newCategoryMutation creates new mutation for the Category entity.
  8496. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  8497. m := &CategoryMutation{
  8498. config: c,
  8499. op: op,
  8500. typ: TypeCategory,
  8501. clearedFields: make(map[string]struct{}),
  8502. }
  8503. for _, opt := range opts {
  8504. opt(m)
  8505. }
  8506. return m
  8507. }
  8508. // withCategoryID sets the ID field of the mutation.
  8509. func withCategoryID(id uint64) categoryOption {
  8510. return func(m *CategoryMutation) {
  8511. var (
  8512. err error
  8513. once sync.Once
  8514. value *Category
  8515. )
  8516. m.oldValue = func(ctx context.Context) (*Category, error) {
  8517. once.Do(func() {
  8518. if m.done {
  8519. err = errors.New("querying old values post mutation is not allowed")
  8520. } else {
  8521. value, err = m.Client().Category.Get(ctx, id)
  8522. }
  8523. })
  8524. return value, err
  8525. }
  8526. m.id = &id
  8527. }
  8528. }
  8529. // withCategory sets the old Category of the mutation.
  8530. func withCategory(node *Category) categoryOption {
  8531. return func(m *CategoryMutation) {
  8532. m.oldValue = func(context.Context) (*Category, error) {
  8533. return node, nil
  8534. }
  8535. m.id = &node.ID
  8536. }
  8537. }
  8538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8539. // executed in a transaction (ent.Tx), a transactional client is returned.
  8540. func (m CategoryMutation) Client() *Client {
  8541. client := &Client{config: m.config}
  8542. client.init()
  8543. return client
  8544. }
  8545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8546. // it returns an error otherwise.
  8547. func (m CategoryMutation) Tx() (*Tx, error) {
  8548. if _, ok := m.driver.(*txDriver); !ok {
  8549. return nil, errors.New("ent: mutation is not running in a transaction")
  8550. }
  8551. tx := &Tx{config: m.config}
  8552. tx.init()
  8553. return tx, nil
  8554. }
  8555. // SetID sets the value of the id field. Note that this
  8556. // operation is only accepted on creation of Category entities.
  8557. func (m *CategoryMutation) SetID(id uint64) {
  8558. m.id = &id
  8559. }
  8560. // ID returns the ID value in the mutation. Note that the ID is only available
  8561. // if it was provided to the builder or after it was returned from the database.
  8562. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  8563. if m.id == nil {
  8564. return
  8565. }
  8566. return *m.id, true
  8567. }
  8568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8569. // That means, if the mutation is applied within a transaction with an isolation level such
  8570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8571. // or updated by the mutation.
  8572. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  8573. switch {
  8574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8575. id, exists := m.ID()
  8576. if exists {
  8577. return []uint64{id}, nil
  8578. }
  8579. fallthrough
  8580. case m.op.Is(OpUpdate | OpDelete):
  8581. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  8582. default:
  8583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8584. }
  8585. }
  8586. // SetCreatedAt sets the "created_at" field.
  8587. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  8588. m.created_at = &t
  8589. }
  8590. // CreatedAt returns the value of the "created_at" field in the mutation.
  8591. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  8592. v := m.created_at
  8593. if v == nil {
  8594. return
  8595. }
  8596. return *v, true
  8597. }
  8598. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  8599. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8601. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8602. if !m.op.Is(OpUpdateOne) {
  8603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8604. }
  8605. if m.id == nil || m.oldValue == nil {
  8606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8607. }
  8608. oldValue, err := m.oldValue(ctx)
  8609. if err != nil {
  8610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8611. }
  8612. return oldValue.CreatedAt, nil
  8613. }
  8614. // ResetCreatedAt resets all changes to the "created_at" field.
  8615. func (m *CategoryMutation) ResetCreatedAt() {
  8616. m.created_at = nil
  8617. }
  8618. // SetUpdatedAt sets the "updated_at" field.
  8619. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  8620. m.updated_at = &t
  8621. }
  8622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8623. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  8624. v := m.updated_at
  8625. if v == nil {
  8626. return
  8627. }
  8628. return *v, true
  8629. }
  8630. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  8631. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8633. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8634. if !m.op.Is(OpUpdateOne) {
  8635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8636. }
  8637. if m.id == nil || m.oldValue == nil {
  8638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8639. }
  8640. oldValue, err := m.oldValue(ctx)
  8641. if err != nil {
  8642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8643. }
  8644. return oldValue.UpdatedAt, nil
  8645. }
  8646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8647. func (m *CategoryMutation) ResetUpdatedAt() {
  8648. m.updated_at = nil
  8649. }
  8650. // SetDeletedAt sets the "deleted_at" field.
  8651. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  8652. m.deleted_at = &t
  8653. }
  8654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8655. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  8656. v := m.deleted_at
  8657. if v == nil {
  8658. return
  8659. }
  8660. return *v, true
  8661. }
  8662. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  8663. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8665. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8666. if !m.op.Is(OpUpdateOne) {
  8667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8668. }
  8669. if m.id == nil || m.oldValue == nil {
  8670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8671. }
  8672. oldValue, err := m.oldValue(ctx)
  8673. if err != nil {
  8674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8675. }
  8676. return oldValue.DeletedAt, nil
  8677. }
  8678. // ClearDeletedAt clears the value of the "deleted_at" field.
  8679. func (m *CategoryMutation) ClearDeletedAt() {
  8680. m.deleted_at = nil
  8681. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  8682. }
  8683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8684. func (m *CategoryMutation) DeletedAtCleared() bool {
  8685. _, ok := m.clearedFields[category.FieldDeletedAt]
  8686. return ok
  8687. }
  8688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8689. func (m *CategoryMutation) ResetDeletedAt() {
  8690. m.deleted_at = nil
  8691. delete(m.clearedFields, category.FieldDeletedAt)
  8692. }
  8693. // SetName sets the "name" field.
  8694. func (m *CategoryMutation) SetName(s string) {
  8695. m.name = &s
  8696. }
  8697. // Name returns the value of the "name" field in the mutation.
  8698. func (m *CategoryMutation) Name() (r string, exists bool) {
  8699. v := m.name
  8700. if v == nil {
  8701. return
  8702. }
  8703. return *v, true
  8704. }
  8705. // OldName returns the old "name" field's value of the Category entity.
  8706. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8708. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  8709. if !m.op.Is(OpUpdateOne) {
  8710. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8711. }
  8712. if m.id == nil || m.oldValue == nil {
  8713. return v, errors.New("OldName requires an ID field in the mutation")
  8714. }
  8715. oldValue, err := m.oldValue(ctx)
  8716. if err != nil {
  8717. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8718. }
  8719. return oldValue.Name, nil
  8720. }
  8721. // ResetName resets all changes to the "name" field.
  8722. func (m *CategoryMutation) ResetName() {
  8723. m.name = nil
  8724. }
  8725. // SetOrganizationID sets the "organization_id" field.
  8726. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  8727. m.organization_id = &u
  8728. m.addorganization_id = nil
  8729. }
  8730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8731. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  8732. v := m.organization_id
  8733. if v == nil {
  8734. return
  8735. }
  8736. return *v, true
  8737. }
  8738. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  8739. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8741. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8742. if !m.op.Is(OpUpdateOne) {
  8743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8744. }
  8745. if m.id == nil || m.oldValue == nil {
  8746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8747. }
  8748. oldValue, err := m.oldValue(ctx)
  8749. if err != nil {
  8750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8751. }
  8752. return oldValue.OrganizationID, nil
  8753. }
  8754. // AddOrganizationID adds u to the "organization_id" field.
  8755. func (m *CategoryMutation) AddOrganizationID(u int64) {
  8756. if m.addorganization_id != nil {
  8757. *m.addorganization_id += u
  8758. } else {
  8759. m.addorganization_id = &u
  8760. }
  8761. }
  8762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8763. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  8764. v := m.addorganization_id
  8765. if v == nil {
  8766. return
  8767. }
  8768. return *v, true
  8769. }
  8770. // ResetOrganizationID resets all changes to the "organization_id" field.
  8771. func (m *CategoryMutation) ResetOrganizationID() {
  8772. m.organization_id = nil
  8773. m.addorganization_id = nil
  8774. }
  8775. // Where appends a list predicates to the CategoryMutation builder.
  8776. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  8777. m.predicates = append(m.predicates, ps...)
  8778. }
  8779. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  8780. // users can use type-assertion to append predicates that do not depend on any generated package.
  8781. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  8782. p := make([]predicate.Category, len(ps))
  8783. for i := range ps {
  8784. p[i] = ps[i]
  8785. }
  8786. m.Where(p...)
  8787. }
  8788. // Op returns the operation name.
  8789. func (m *CategoryMutation) Op() Op {
  8790. return m.op
  8791. }
  8792. // SetOp allows setting the mutation operation.
  8793. func (m *CategoryMutation) SetOp(op Op) {
  8794. m.op = op
  8795. }
  8796. // Type returns the node type of this mutation (Category).
  8797. func (m *CategoryMutation) Type() string {
  8798. return m.typ
  8799. }
  8800. // Fields returns all fields that were changed during this mutation. Note that in
  8801. // order to get all numeric fields that were incremented/decremented, call
  8802. // AddedFields().
  8803. func (m *CategoryMutation) Fields() []string {
  8804. fields := make([]string, 0, 5)
  8805. if m.created_at != nil {
  8806. fields = append(fields, category.FieldCreatedAt)
  8807. }
  8808. if m.updated_at != nil {
  8809. fields = append(fields, category.FieldUpdatedAt)
  8810. }
  8811. if m.deleted_at != nil {
  8812. fields = append(fields, category.FieldDeletedAt)
  8813. }
  8814. if m.name != nil {
  8815. fields = append(fields, category.FieldName)
  8816. }
  8817. if m.organization_id != nil {
  8818. fields = append(fields, category.FieldOrganizationID)
  8819. }
  8820. return fields
  8821. }
  8822. // Field returns the value of a field with the given name. The second boolean
  8823. // return value indicates that this field was not set, or was not defined in the
  8824. // schema.
  8825. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  8826. switch name {
  8827. case category.FieldCreatedAt:
  8828. return m.CreatedAt()
  8829. case category.FieldUpdatedAt:
  8830. return m.UpdatedAt()
  8831. case category.FieldDeletedAt:
  8832. return m.DeletedAt()
  8833. case category.FieldName:
  8834. return m.Name()
  8835. case category.FieldOrganizationID:
  8836. return m.OrganizationID()
  8837. }
  8838. return nil, false
  8839. }
  8840. // OldField returns the old value of the field from the database. An error is
  8841. // returned if the mutation operation is not UpdateOne, or the query to the
  8842. // database failed.
  8843. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8844. switch name {
  8845. case category.FieldCreatedAt:
  8846. return m.OldCreatedAt(ctx)
  8847. case category.FieldUpdatedAt:
  8848. return m.OldUpdatedAt(ctx)
  8849. case category.FieldDeletedAt:
  8850. return m.OldDeletedAt(ctx)
  8851. case category.FieldName:
  8852. return m.OldName(ctx)
  8853. case category.FieldOrganizationID:
  8854. return m.OldOrganizationID(ctx)
  8855. }
  8856. return nil, fmt.Errorf("unknown Category field %s", name)
  8857. }
  8858. // SetField sets the value of a field with the given name. It returns an error if
  8859. // the field is not defined in the schema, or if the type mismatched the field
  8860. // type.
  8861. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  8862. switch name {
  8863. case category.FieldCreatedAt:
  8864. v, ok := value.(time.Time)
  8865. if !ok {
  8866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8867. }
  8868. m.SetCreatedAt(v)
  8869. return nil
  8870. case category.FieldUpdatedAt:
  8871. v, ok := value.(time.Time)
  8872. if !ok {
  8873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8874. }
  8875. m.SetUpdatedAt(v)
  8876. return nil
  8877. case category.FieldDeletedAt:
  8878. v, ok := value.(time.Time)
  8879. if !ok {
  8880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8881. }
  8882. m.SetDeletedAt(v)
  8883. return nil
  8884. case category.FieldName:
  8885. v, ok := value.(string)
  8886. if !ok {
  8887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8888. }
  8889. m.SetName(v)
  8890. return nil
  8891. case category.FieldOrganizationID:
  8892. v, ok := value.(uint64)
  8893. if !ok {
  8894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8895. }
  8896. m.SetOrganizationID(v)
  8897. return nil
  8898. }
  8899. return fmt.Errorf("unknown Category field %s", name)
  8900. }
  8901. // AddedFields returns all numeric fields that were incremented/decremented during
  8902. // this mutation.
  8903. func (m *CategoryMutation) AddedFields() []string {
  8904. var fields []string
  8905. if m.addorganization_id != nil {
  8906. fields = append(fields, category.FieldOrganizationID)
  8907. }
  8908. return fields
  8909. }
  8910. // AddedField returns the numeric value that was incremented/decremented on a field
  8911. // with the given name. The second boolean return value indicates that this field
  8912. // was not set, or was not defined in the schema.
  8913. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  8914. switch name {
  8915. case category.FieldOrganizationID:
  8916. return m.AddedOrganizationID()
  8917. }
  8918. return nil, false
  8919. }
  8920. // AddField adds the value to the field with the given name. It returns an error if
  8921. // the field is not defined in the schema, or if the type mismatched the field
  8922. // type.
  8923. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  8924. switch name {
  8925. case category.FieldOrganizationID:
  8926. v, ok := value.(int64)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.AddOrganizationID(v)
  8931. return nil
  8932. }
  8933. return fmt.Errorf("unknown Category numeric field %s", name)
  8934. }
  8935. // ClearedFields returns all nullable fields that were cleared during this
  8936. // mutation.
  8937. func (m *CategoryMutation) ClearedFields() []string {
  8938. var fields []string
  8939. if m.FieldCleared(category.FieldDeletedAt) {
  8940. fields = append(fields, category.FieldDeletedAt)
  8941. }
  8942. return fields
  8943. }
  8944. // FieldCleared returns a boolean indicating if a field with the given name was
  8945. // cleared in this mutation.
  8946. func (m *CategoryMutation) FieldCleared(name string) bool {
  8947. _, ok := m.clearedFields[name]
  8948. return ok
  8949. }
  8950. // ClearField clears the value of the field with the given name. It returns an
  8951. // error if the field is not defined in the schema.
  8952. func (m *CategoryMutation) ClearField(name string) error {
  8953. switch name {
  8954. case category.FieldDeletedAt:
  8955. m.ClearDeletedAt()
  8956. return nil
  8957. }
  8958. return fmt.Errorf("unknown Category nullable field %s", name)
  8959. }
  8960. // ResetField resets all changes in the mutation for the field with the given name.
  8961. // It returns an error if the field is not defined in the schema.
  8962. func (m *CategoryMutation) ResetField(name string) error {
  8963. switch name {
  8964. case category.FieldCreatedAt:
  8965. m.ResetCreatedAt()
  8966. return nil
  8967. case category.FieldUpdatedAt:
  8968. m.ResetUpdatedAt()
  8969. return nil
  8970. case category.FieldDeletedAt:
  8971. m.ResetDeletedAt()
  8972. return nil
  8973. case category.FieldName:
  8974. m.ResetName()
  8975. return nil
  8976. case category.FieldOrganizationID:
  8977. m.ResetOrganizationID()
  8978. return nil
  8979. }
  8980. return fmt.Errorf("unknown Category field %s", name)
  8981. }
  8982. // AddedEdges returns all edge names that were set/added in this mutation.
  8983. func (m *CategoryMutation) AddedEdges() []string {
  8984. edges := make([]string, 0, 0)
  8985. return edges
  8986. }
  8987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8988. // name in this mutation.
  8989. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  8990. return nil
  8991. }
  8992. // RemovedEdges returns all edge names that were removed in this mutation.
  8993. func (m *CategoryMutation) RemovedEdges() []string {
  8994. edges := make([]string, 0, 0)
  8995. return edges
  8996. }
  8997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8998. // the given name in this mutation.
  8999. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  9000. return nil
  9001. }
  9002. // ClearedEdges returns all edge names that were cleared in this mutation.
  9003. func (m *CategoryMutation) ClearedEdges() []string {
  9004. edges := make([]string, 0, 0)
  9005. return edges
  9006. }
  9007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9008. // was cleared in this mutation.
  9009. func (m *CategoryMutation) EdgeCleared(name string) bool {
  9010. return false
  9011. }
  9012. // ClearEdge clears the value of the edge with the given name. It returns an error
  9013. // if that edge is not defined in the schema.
  9014. func (m *CategoryMutation) ClearEdge(name string) error {
  9015. return fmt.Errorf("unknown Category unique edge %s", name)
  9016. }
  9017. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9018. // It returns an error if the edge is not defined in the schema.
  9019. func (m *CategoryMutation) ResetEdge(name string) error {
  9020. return fmt.Errorf("unknown Category edge %s", name)
  9021. }
  9022. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  9023. type ChatRecordsMutation struct {
  9024. config
  9025. op Op
  9026. typ string
  9027. id *uint64
  9028. created_at *time.Time
  9029. updated_at *time.Time
  9030. deleted_at *time.Time
  9031. content *string
  9032. content_type *uint8
  9033. addcontent_type *int8
  9034. session_id *uint64
  9035. addsession_id *int64
  9036. user_id *uint64
  9037. adduser_id *int64
  9038. bot_id *uint64
  9039. addbot_id *int64
  9040. bot_type *uint8
  9041. addbot_type *int8
  9042. clearedFields map[string]struct{}
  9043. done bool
  9044. oldValue func(context.Context) (*ChatRecords, error)
  9045. predicates []predicate.ChatRecords
  9046. }
  9047. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  9048. // chatrecordsOption allows management of the mutation configuration using functional options.
  9049. type chatrecordsOption func(*ChatRecordsMutation)
  9050. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  9051. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  9052. m := &ChatRecordsMutation{
  9053. config: c,
  9054. op: op,
  9055. typ: TypeChatRecords,
  9056. clearedFields: make(map[string]struct{}),
  9057. }
  9058. for _, opt := range opts {
  9059. opt(m)
  9060. }
  9061. return m
  9062. }
  9063. // withChatRecordsID sets the ID field of the mutation.
  9064. func withChatRecordsID(id uint64) chatrecordsOption {
  9065. return func(m *ChatRecordsMutation) {
  9066. var (
  9067. err error
  9068. once sync.Once
  9069. value *ChatRecords
  9070. )
  9071. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  9072. once.Do(func() {
  9073. if m.done {
  9074. err = errors.New("querying old values post mutation is not allowed")
  9075. } else {
  9076. value, err = m.Client().ChatRecords.Get(ctx, id)
  9077. }
  9078. })
  9079. return value, err
  9080. }
  9081. m.id = &id
  9082. }
  9083. }
  9084. // withChatRecords sets the old ChatRecords of the mutation.
  9085. func withChatRecords(node *ChatRecords) chatrecordsOption {
  9086. return func(m *ChatRecordsMutation) {
  9087. m.oldValue = func(context.Context) (*ChatRecords, error) {
  9088. return node, nil
  9089. }
  9090. m.id = &node.ID
  9091. }
  9092. }
  9093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9094. // executed in a transaction (ent.Tx), a transactional client is returned.
  9095. func (m ChatRecordsMutation) Client() *Client {
  9096. client := &Client{config: m.config}
  9097. client.init()
  9098. return client
  9099. }
  9100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9101. // it returns an error otherwise.
  9102. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  9103. if _, ok := m.driver.(*txDriver); !ok {
  9104. return nil, errors.New("ent: mutation is not running in a transaction")
  9105. }
  9106. tx := &Tx{config: m.config}
  9107. tx.init()
  9108. return tx, nil
  9109. }
  9110. // SetID sets the value of the id field. Note that this
  9111. // operation is only accepted on creation of ChatRecords entities.
  9112. func (m *ChatRecordsMutation) SetID(id uint64) {
  9113. m.id = &id
  9114. }
  9115. // ID returns the ID value in the mutation. Note that the ID is only available
  9116. // if it was provided to the builder or after it was returned from the database.
  9117. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  9118. if m.id == nil {
  9119. return
  9120. }
  9121. return *m.id, true
  9122. }
  9123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9124. // That means, if the mutation is applied within a transaction with an isolation level such
  9125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9126. // or updated by the mutation.
  9127. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9128. switch {
  9129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9130. id, exists := m.ID()
  9131. if exists {
  9132. return []uint64{id}, nil
  9133. }
  9134. fallthrough
  9135. case m.op.Is(OpUpdate | OpDelete):
  9136. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  9137. default:
  9138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9139. }
  9140. }
  9141. // SetCreatedAt sets the "created_at" field.
  9142. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  9143. m.created_at = &t
  9144. }
  9145. // CreatedAt returns the value of the "created_at" field in the mutation.
  9146. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9147. v := m.created_at
  9148. if v == nil {
  9149. return
  9150. }
  9151. return *v, true
  9152. }
  9153. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  9154. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9156. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9157. if !m.op.Is(OpUpdateOne) {
  9158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9159. }
  9160. if m.id == nil || m.oldValue == nil {
  9161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9162. }
  9163. oldValue, err := m.oldValue(ctx)
  9164. if err != nil {
  9165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9166. }
  9167. return oldValue.CreatedAt, nil
  9168. }
  9169. // ResetCreatedAt resets all changes to the "created_at" field.
  9170. func (m *ChatRecordsMutation) ResetCreatedAt() {
  9171. m.created_at = nil
  9172. }
  9173. // SetUpdatedAt sets the "updated_at" field.
  9174. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  9175. m.updated_at = &t
  9176. }
  9177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9178. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9179. v := m.updated_at
  9180. if v == nil {
  9181. return
  9182. }
  9183. return *v, true
  9184. }
  9185. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  9186. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9188. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9189. if !m.op.Is(OpUpdateOne) {
  9190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9191. }
  9192. if m.id == nil || m.oldValue == nil {
  9193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9194. }
  9195. oldValue, err := m.oldValue(ctx)
  9196. if err != nil {
  9197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9198. }
  9199. return oldValue.UpdatedAt, nil
  9200. }
  9201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9202. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  9203. m.updated_at = nil
  9204. }
  9205. // SetDeletedAt sets the "deleted_at" field.
  9206. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  9207. m.deleted_at = &t
  9208. }
  9209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9210. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9211. v := m.deleted_at
  9212. if v == nil {
  9213. return
  9214. }
  9215. return *v, true
  9216. }
  9217. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  9218. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9220. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9221. if !m.op.Is(OpUpdateOne) {
  9222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9223. }
  9224. if m.id == nil || m.oldValue == nil {
  9225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9226. }
  9227. oldValue, err := m.oldValue(ctx)
  9228. if err != nil {
  9229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9230. }
  9231. return oldValue.DeletedAt, nil
  9232. }
  9233. // ClearDeletedAt clears the value of the "deleted_at" field.
  9234. func (m *ChatRecordsMutation) ClearDeletedAt() {
  9235. m.deleted_at = nil
  9236. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  9237. }
  9238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9239. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  9240. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  9241. return ok
  9242. }
  9243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9244. func (m *ChatRecordsMutation) ResetDeletedAt() {
  9245. m.deleted_at = nil
  9246. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  9247. }
  9248. // SetContent sets the "content" field.
  9249. func (m *ChatRecordsMutation) SetContent(s string) {
  9250. m.content = &s
  9251. }
  9252. // Content returns the value of the "content" field in the mutation.
  9253. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  9254. v := m.content
  9255. if v == nil {
  9256. return
  9257. }
  9258. return *v, true
  9259. }
  9260. // OldContent returns the old "content" field's value of the ChatRecords entity.
  9261. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9263. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9264. if !m.op.Is(OpUpdateOne) {
  9265. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9266. }
  9267. if m.id == nil || m.oldValue == nil {
  9268. return v, errors.New("OldContent requires an ID field in the mutation")
  9269. }
  9270. oldValue, err := m.oldValue(ctx)
  9271. if err != nil {
  9272. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9273. }
  9274. return oldValue.Content, nil
  9275. }
  9276. // ResetContent resets all changes to the "content" field.
  9277. func (m *ChatRecordsMutation) ResetContent() {
  9278. m.content = nil
  9279. }
  9280. // SetContentType sets the "content_type" field.
  9281. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  9282. m.content_type = &u
  9283. m.addcontent_type = nil
  9284. }
  9285. // ContentType returns the value of the "content_type" field in the mutation.
  9286. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  9287. v := m.content_type
  9288. if v == nil {
  9289. return
  9290. }
  9291. return *v, true
  9292. }
  9293. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  9294. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9296. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  9297. if !m.op.Is(OpUpdateOne) {
  9298. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9299. }
  9300. if m.id == nil || m.oldValue == nil {
  9301. return v, errors.New("OldContentType requires an ID field in the mutation")
  9302. }
  9303. oldValue, err := m.oldValue(ctx)
  9304. if err != nil {
  9305. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9306. }
  9307. return oldValue.ContentType, nil
  9308. }
  9309. // AddContentType adds u to the "content_type" field.
  9310. func (m *ChatRecordsMutation) AddContentType(u int8) {
  9311. if m.addcontent_type != nil {
  9312. *m.addcontent_type += u
  9313. } else {
  9314. m.addcontent_type = &u
  9315. }
  9316. }
  9317. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9318. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  9319. v := m.addcontent_type
  9320. if v == nil {
  9321. return
  9322. }
  9323. return *v, true
  9324. }
  9325. // ResetContentType resets all changes to the "content_type" field.
  9326. func (m *ChatRecordsMutation) ResetContentType() {
  9327. m.content_type = nil
  9328. m.addcontent_type = nil
  9329. }
  9330. // SetSessionID sets the "session_id" field.
  9331. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  9332. m.session_id = &u
  9333. m.addsession_id = nil
  9334. }
  9335. // SessionID returns the value of the "session_id" field in the mutation.
  9336. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  9337. v := m.session_id
  9338. if v == nil {
  9339. return
  9340. }
  9341. return *v, true
  9342. }
  9343. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  9344. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9346. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  9347. if !m.op.Is(OpUpdateOne) {
  9348. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  9349. }
  9350. if m.id == nil || m.oldValue == nil {
  9351. return v, errors.New("OldSessionID requires an ID field in the mutation")
  9352. }
  9353. oldValue, err := m.oldValue(ctx)
  9354. if err != nil {
  9355. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  9356. }
  9357. return oldValue.SessionID, nil
  9358. }
  9359. // AddSessionID adds u to the "session_id" field.
  9360. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  9361. if m.addsession_id != nil {
  9362. *m.addsession_id += u
  9363. } else {
  9364. m.addsession_id = &u
  9365. }
  9366. }
  9367. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  9368. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  9369. v := m.addsession_id
  9370. if v == nil {
  9371. return
  9372. }
  9373. return *v, true
  9374. }
  9375. // ResetSessionID resets all changes to the "session_id" field.
  9376. func (m *ChatRecordsMutation) ResetSessionID() {
  9377. m.session_id = nil
  9378. m.addsession_id = nil
  9379. }
  9380. // SetUserID sets the "user_id" field.
  9381. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  9382. m.user_id = &u
  9383. m.adduser_id = nil
  9384. }
  9385. // UserID returns the value of the "user_id" field in the mutation.
  9386. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  9387. v := m.user_id
  9388. if v == nil {
  9389. return
  9390. }
  9391. return *v, true
  9392. }
  9393. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  9394. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9396. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9397. if !m.op.Is(OpUpdateOne) {
  9398. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9399. }
  9400. if m.id == nil || m.oldValue == nil {
  9401. return v, errors.New("OldUserID requires an ID field in the mutation")
  9402. }
  9403. oldValue, err := m.oldValue(ctx)
  9404. if err != nil {
  9405. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9406. }
  9407. return oldValue.UserID, nil
  9408. }
  9409. // AddUserID adds u to the "user_id" field.
  9410. func (m *ChatRecordsMutation) AddUserID(u int64) {
  9411. if m.adduser_id != nil {
  9412. *m.adduser_id += u
  9413. } else {
  9414. m.adduser_id = &u
  9415. }
  9416. }
  9417. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9418. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  9419. v := m.adduser_id
  9420. if v == nil {
  9421. return
  9422. }
  9423. return *v, true
  9424. }
  9425. // ResetUserID resets all changes to the "user_id" field.
  9426. func (m *ChatRecordsMutation) ResetUserID() {
  9427. m.user_id = nil
  9428. m.adduser_id = nil
  9429. }
  9430. // SetBotID sets the "bot_id" field.
  9431. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  9432. m.bot_id = &u
  9433. m.addbot_id = nil
  9434. }
  9435. // BotID returns the value of the "bot_id" field in the mutation.
  9436. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  9437. v := m.bot_id
  9438. if v == nil {
  9439. return
  9440. }
  9441. return *v, true
  9442. }
  9443. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  9444. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9446. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9447. if !m.op.Is(OpUpdateOne) {
  9448. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9449. }
  9450. if m.id == nil || m.oldValue == nil {
  9451. return v, errors.New("OldBotID requires an ID field in the mutation")
  9452. }
  9453. oldValue, err := m.oldValue(ctx)
  9454. if err != nil {
  9455. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9456. }
  9457. return oldValue.BotID, nil
  9458. }
  9459. // AddBotID adds u to the "bot_id" field.
  9460. func (m *ChatRecordsMutation) AddBotID(u int64) {
  9461. if m.addbot_id != nil {
  9462. *m.addbot_id += u
  9463. } else {
  9464. m.addbot_id = &u
  9465. }
  9466. }
  9467. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9468. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  9469. v := m.addbot_id
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // ResetBotID resets all changes to the "bot_id" field.
  9476. func (m *ChatRecordsMutation) ResetBotID() {
  9477. m.bot_id = nil
  9478. m.addbot_id = nil
  9479. }
  9480. // SetBotType sets the "bot_type" field.
  9481. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  9482. m.bot_type = &u
  9483. m.addbot_type = nil
  9484. }
  9485. // BotType returns the value of the "bot_type" field in the mutation.
  9486. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  9487. v := m.bot_type
  9488. if v == nil {
  9489. return
  9490. }
  9491. return *v, true
  9492. }
  9493. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  9494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9496. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9497. if !m.op.Is(OpUpdateOne) {
  9498. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9499. }
  9500. if m.id == nil || m.oldValue == nil {
  9501. return v, errors.New("OldBotType requires an ID field in the mutation")
  9502. }
  9503. oldValue, err := m.oldValue(ctx)
  9504. if err != nil {
  9505. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9506. }
  9507. return oldValue.BotType, nil
  9508. }
  9509. // AddBotType adds u to the "bot_type" field.
  9510. func (m *ChatRecordsMutation) AddBotType(u int8) {
  9511. if m.addbot_type != nil {
  9512. *m.addbot_type += u
  9513. } else {
  9514. m.addbot_type = &u
  9515. }
  9516. }
  9517. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9518. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  9519. v := m.addbot_type
  9520. if v == nil {
  9521. return
  9522. }
  9523. return *v, true
  9524. }
  9525. // ResetBotType resets all changes to the "bot_type" field.
  9526. func (m *ChatRecordsMutation) ResetBotType() {
  9527. m.bot_type = nil
  9528. m.addbot_type = nil
  9529. }
  9530. // Where appends a list predicates to the ChatRecordsMutation builder.
  9531. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  9532. m.predicates = append(m.predicates, ps...)
  9533. }
  9534. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  9535. // users can use type-assertion to append predicates that do not depend on any generated package.
  9536. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9537. p := make([]predicate.ChatRecords, len(ps))
  9538. for i := range ps {
  9539. p[i] = ps[i]
  9540. }
  9541. m.Where(p...)
  9542. }
  9543. // Op returns the operation name.
  9544. func (m *ChatRecordsMutation) Op() Op {
  9545. return m.op
  9546. }
  9547. // SetOp allows setting the mutation operation.
  9548. func (m *ChatRecordsMutation) SetOp(op Op) {
  9549. m.op = op
  9550. }
  9551. // Type returns the node type of this mutation (ChatRecords).
  9552. func (m *ChatRecordsMutation) Type() string {
  9553. return m.typ
  9554. }
  9555. // Fields returns all fields that were changed during this mutation. Note that in
  9556. // order to get all numeric fields that were incremented/decremented, call
  9557. // AddedFields().
  9558. func (m *ChatRecordsMutation) Fields() []string {
  9559. fields := make([]string, 0, 9)
  9560. if m.created_at != nil {
  9561. fields = append(fields, chatrecords.FieldCreatedAt)
  9562. }
  9563. if m.updated_at != nil {
  9564. fields = append(fields, chatrecords.FieldUpdatedAt)
  9565. }
  9566. if m.deleted_at != nil {
  9567. fields = append(fields, chatrecords.FieldDeletedAt)
  9568. }
  9569. if m.content != nil {
  9570. fields = append(fields, chatrecords.FieldContent)
  9571. }
  9572. if m.content_type != nil {
  9573. fields = append(fields, chatrecords.FieldContentType)
  9574. }
  9575. if m.session_id != nil {
  9576. fields = append(fields, chatrecords.FieldSessionID)
  9577. }
  9578. if m.user_id != nil {
  9579. fields = append(fields, chatrecords.FieldUserID)
  9580. }
  9581. if m.bot_id != nil {
  9582. fields = append(fields, chatrecords.FieldBotID)
  9583. }
  9584. if m.bot_type != nil {
  9585. fields = append(fields, chatrecords.FieldBotType)
  9586. }
  9587. return fields
  9588. }
  9589. // Field returns the value of a field with the given name. The second boolean
  9590. // return value indicates that this field was not set, or was not defined in the
  9591. // schema.
  9592. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  9593. switch name {
  9594. case chatrecords.FieldCreatedAt:
  9595. return m.CreatedAt()
  9596. case chatrecords.FieldUpdatedAt:
  9597. return m.UpdatedAt()
  9598. case chatrecords.FieldDeletedAt:
  9599. return m.DeletedAt()
  9600. case chatrecords.FieldContent:
  9601. return m.Content()
  9602. case chatrecords.FieldContentType:
  9603. return m.ContentType()
  9604. case chatrecords.FieldSessionID:
  9605. return m.SessionID()
  9606. case chatrecords.FieldUserID:
  9607. return m.UserID()
  9608. case chatrecords.FieldBotID:
  9609. return m.BotID()
  9610. case chatrecords.FieldBotType:
  9611. return m.BotType()
  9612. }
  9613. return nil, false
  9614. }
  9615. // OldField returns the old value of the field from the database. An error is
  9616. // returned if the mutation operation is not UpdateOne, or the query to the
  9617. // database failed.
  9618. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9619. switch name {
  9620. case chatrecords.FieldCreatedAt:
  9621. return m.OldCreatedAt(ctx)
  9622. case chatrecords.FieldUpdatedAt:
  9623. return m.OldUpdatedAt(ctx)
  9624. case chatrecords.FieldDeletedAt:
  9625. return m.OldDeletedAt(ctx)
  9626. case chatrecords.FieldContent:
  9627. return m.OldContent(ctx)
  9628. case chatrecords.FieldContentType:
  9629. return m.OldContentType(ctx)
  9630. case chatrecords.FieldSessionID:
  9631. return m.OldSessionID(ctx)
  9632. case chatrecords.FieldUserID:
  9633. return m.OldUserID(ctx)
  9634. case chatrecords.FieldBotID:
  9635. return m.OldBotID(ctx)
  9636. case chatrecords.FieldBotType:
  9637. return m.OldBotType(ctx)
  9638. }
  9639. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  9640. }
  9641. // SetField sets the value of a field with the given name. It returns an error if
  9642. // the field is not defined in the schema, or if the type mismatched the field
  9643. // type.
  9644. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  9645. switch name {
  9646. case chatrecords.FieldCreatedAt:
  9647. v, ok := value.(time.Time)
  9648. if !ok {
  9649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9650. }
  9651. m.SetCreatedAt(v)
  9652. return nil
  9653. case chatrecords.FieldUpdatedAt:
  9654. v, ok := value.(time.Time)
  9655. if !ok {
  9656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9657. }
  9658. m.SetUpdatedAt(v)
  9659. return nil
  9660. case chatrecords.FieldDeletedAt:
  9661. v, ok := value.(time.Time)
  9662. if !ok {
  9663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9664. }
  9665. m.SetDeletedAt(v)
  9666. return nil
  9667. case chatrecords.FieldContent:
  9668. v, ok := value.(string)
  9669. if !ok {
  9670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9671. }
  9672. m.SetContent(v)
  9673. return nil
  9674. case chatrecords.FieldContentType:
  9675. v, ok := value.(uint8)
  9676. if !ok {
  9677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9678. }
  9679. m.SetContentType(v)
  9680. return nil
  9681. case chatrecords.FieldSessionID:
  9682. v, ok := value.(uint64)
  9683. if !ok {
  9684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9685. }
  9686. m.SetSessionID(v)
  9687. return nil
  9688. case chatrecords.FieldUserID:
  9689. v, ok := value.(uint64)
  9690. if !ok {
  9691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9692. }
  9693. m.SetUserID(v)
  9694. return nil
  9695. case chatrecords.FieldBotID:
  9696. v, ok := value.(uint64)
  9697. if !ok {
  9698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9699. }
  9700. m.SetBotID(v)
  9701. return nil
  9702. case chatrecords.FieldBotType:
  9703. v, ok := value.(uint8)
  9704. if !ok {
  9705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9706. }
  9707. m.SetBotType(v)
  9708. return nil
  9709. }
  9710. return fmt.Errorf("unknown ChatRecords field %s", name)
  9711. }
  9712. // AddedFields returns all numeric fields that were incremented/decremented during
  9713. // this mutation.
  9714. func (m *ChatRecordsMutation) AddedFields() []string {
  9715. var fields []string
  9716. if m.addcontent_type != nil {
  9717. fields = append(fields, chatrecords.FieldContentType)
  9718. }
  9719. if m.addsession_id != nil {
  9720. fields = append(fields, chatrecords.FieldSessionID)
  9721. }
  9722. if m.adduser_id != nil {
  9723. fields = append(fields, chatrecords.FieldUserID)
  9724. }
  9725. if m.addbot_id != nil {
  9726. fields = append(fields, chatrecords.FieldBotID)
  9727. }
  9728. if m.addbot_type != nil {
  9729. fields = append(fields, chatrecords.FieldBotType)
  9730. }
  9731. return fields
  9732. }
  9733. // AddedField returns the numeric value that was incremented/decremented on a field
  9734. // with the given name. The second boolean return value indicates that this field
  9735. // was not set, or was not defined in the schema.
  9736. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9737. switch name {
  9738. case chatrecords.FieldContentType:
  9739. return m.AddedContentType()
  9740. case chatrecords.FieldSessionID:
  9741. return m.AddedSessionID()
  9742. case chatrecords.FieldUserID:
  9743. return m.AddedUserID()
  9744. case chatrecords.FieldBotID:
  9745. return m.AddedBotID()
  9746. case chatrecords.FieldBotType:
  9747. return m.AddedBotType()
  9748. }
  9749. return nil, false
  9750. }
  9751. // AddField adds the value to the field with the given name. It returns an error if
  9752. // the field is not defined in the schema, or if the type mismatched the field
  9753. // type.
  9754. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  9755. switch name {
  9756. case chatrecords.FieldContentType:
  9757. v, ok := value.(int8)
  9758. if !ok {
  9759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9760. }
  9761. m.AddContentType(v)
  9762. return nil
  9763. case chatrecords.FieldSessionID:
  9764. v, ok := value.(int64)
  9765. if !ok {
  9766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9767. }
  9768. m.AddSessionID(v)
  9769. return nil
  9770. case chatrecords.FieldUserID:
  9771. v, ok := value.(int64)
  9772. if !ok {
  9773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9774. }
  9775. m.AddUserID(v)
  9776. return nil
  9777. case chatrecords.FieldBotID:
  9778. v, ok := value.(int64)
  9779. if !ok {
  9780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9781. }
  9782. m.AddBotID(v)
  9783. return nil
  9784. case chatrecords.FieldBotType:
  9785. v, ok := value.(int8)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.AddBotType(v)
  9790. return nil
  9791. }
  9792. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  9793. }
  9794. // ClearedFields returns all nullable fields that were cleared during this
  9795. // mutation.
  9796. func (m *ChatRecordsMutation) ClearedFields() []string {
  9797. var fields []string
  9798. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  9799. fields = append(fields, chatrecords.FieldDeletedAt)
  9800. }
  9801. return fields
  9802. }
  9803. // FieldCleared returns a boolean indicating if a field with the given name was
  9804. // cleared in this mutation.
  9805. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  9806. _, ok := m.clearedFields[name]
  9807. return ok
  9808. }
  9809. // ClearField clears the value of the field with the given name. It returns an
  9810. // error if the field is not defined in the schema.
  9811. func (m *ChatRecordsMutation) ClearField(name string) error {
  9812. switch name {
  9813. case chatrecords.FieldDeletedAt:
  9814. m.ClearDeletedAt()
  9815. return nil
  9816. }
  9817. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  9818. }
  9819. // ResetField resets all changes in the mutation for the field with the given name.
  9820. // It returns an error if the field is not defined in the schema.
  9821. func (m *ChatRecordsMutation) ResetField(name string) error {
  9822. switch name {
  9823. case chatrecords.FieldCreatedAt:
  9824. m.ResetCreatedAt()
  9825. return nil
  9826. case chatrecords.FieldUpdatedAt:
  9827. m.ResetUpdatedAt()
  9828. return nil
  9829. case chatrecords.FieldDeletedAt:
  9830. m.ResetDeletedAt()
  9831. return nil
  9832. case chatrecords.FieldContent:
  9833. m.ResetContent()
  9834. return nil
  9835. case chatrecords.FieldContentType:
  9836. m.ResetContentType()
  9837. return nil
  9838. case chatrecords.FieldSessionID:
  9839. m.ResetSessionID()
  9840. return nil
  9841. case chatrecords.FieldUserID:
  9842. m.ResetUserID()
  9843. return nil
  9844. case chatrecords.FieldBotID:
  9845. m.ResetBotID()
  9846. return nil
  9847. case chatrecords.FieldBotType:
  9848. m.ResetBotType()
  9849. return nil
  9850. }
  9851. return fmt.Errorf("unknown ChatRecords field %s", name)
  9852. }
  9853. // AddedEdges returns all edge names that were set/added in this mutation.
  9854. func (m *ChatRecordsMutation) AddedEdges() []string {
  9855. edges := make([]string, 0, 0)
  9856. return edges
  9857. }
  9858. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9859. // name in this mutation.
  9860. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  9861. return nil
  9862. }
  9863. // RemovedEdges returns all edge names that were removed in this mutation.
  9864. func (m *ChatRecordsMutation) RemovedEdges() []string {
  9865. edges := make([]string, 0, 0)
  9866. return edges
  9867. }
  9868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9869. // the given name in this mutation.
  9870. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  9871. return nil
  9872. }
  9873. // ClearedEdges returns all edge names that were cleared in this mutation.
  9874. func (m *ChatRecordsMutation) ClearedEdges() []string {
  9875. edges := make([]string, 0, 0)
  9876. return edges
  9877. }
  9878. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9879. // was cleared in this mutation.
  9880. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  9881. return false
  9882. }
  9883. // ClearEdge clears the value of the edge with the given name. It returns an error
  9884. // if that edge is not defined in the schema.
  9885. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  9886. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  9887. }
  9888. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9889. // It returns an error if the edge is not defined in the schema.
  9890. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  9891. return fmt.Errorf("unknown ChatRecords edge %s", name)
  9892. }
  9893. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  9894. type ChatSessionMutation struct {
  9895. config
  9896. op Op
  9897. typ string
  9898. id *uint64
  9899. created_at *time.Time
  9900. updated_at *time.Time
  9901. deleted_at *time.Time
  9902. name *string
  9903. user_id *uint64
  9904. adduser_id *int64
  9905. bot_id *uint64
  9906. addbot_id *int64
  9907. bot_type *uint8
  9908. addbot_type *int8
  9909. clearedFields map[string]struct{}
  9910. done bool
  9911. oldValue func(context.Context) (*ChatSession, error)
  9912. predicates []predicate.ChatSession
  9913. }
  9914. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  9915. // chatsessionOption allows management of the mutation configuration using functional options.
  9916. type chatsessionOption func(*ChatSessionMutation)
  9917. // newChatSessionMutation creates new mutation for the ChatSession entity.
  9918. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  9919. m := &ChatSessionMutation{
  9920. config: c,
  9921. op: op,
  9922. typ: TypeChatSession,
  9923. clearedFields: make(map[string]struct{}),
  9924. }
  9925. for _, opt := range opts {
  9926. opt(m)
  9927. }
  9928. return m
  9929. }
  9930. // withChatSessionID sets the ID field of the mutation.
  9931. func withChatSessionID(id uint64) chatsessionOption {
  9932. return func(m *ChatSessionMutation) {
  9933. var (
  9934. err error
  9935. once sync.Once
  9936. value *ChatSession
  9937. )
  9938. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  9939. once.Do(func() {
  9940. if m.done {
  9941. err = errors.New("querying old values post mutation is not allowed")
  9942. } else {
  9943. value, err = m.Client().ChatSession.Get(ctx, id)
  9944. }
  9945. })
  9946. return value, err
  9947. }
  9948. m.id = &id
  9949. }
  9950. }
  9951. // withChatSession sets the old ChatSession of the mutation.
  9952. func withChatSession(node *ChatSession) chatsessionOption {
  9953. return func(m *ChatSessionMutation) {
  9954. m.oldValue = func(context.Context) (*ChatSession, error) {
  9955. return node, nil
  9956. }
  9957. m.id = &node.ID
  9958. }
  9959. }
  9960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9961. // executed in a transaction (ent.Tx), a transactional client is returned.
  9962. func (m ChatSessionMutation) Client() *Client {
  9963. client := &Client{config: m.config}
  9964. client.init()
  9965. return client
  9966. }
  9967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9968. // it returns an error otherwise.
  9969. func (m ChatSessionMutation) Tx() (*Tx, error) {
  9970. if _, ok := m.driver.(*txDriver); !ok {
  9971. return nil, errors.New("ent: mutation is not running in a transaction")
  9972. }
  9973. tx := &Tx{config: m.config}
  9974. tx.init()
  9975. return tx, nil
  9976. }
  9977. // SetID sets the value of the id field. Note that this
  9978. // operation is only accepted on creation of ChatSession entities.
  9979. func (m *ChatSessionMutation) SetID(id uint64) {
  9980. m.id = &id
  9981. }
  9982. // ID returns the ID value in the mutation. Note that the ID is only available
  9983. // if it was provided to the builder or after it was returned from the database.
  9984. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  9985. if m.id == nil {
  9986. return
  9987. }
  9988. return *m.id, true
  9989. }
  9990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9991. // That means, if the mutation is applied within a transaction with an isolation level such
  9992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9993. // or updated by the mutation.
  9994. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  9995. switch {
  9996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9997. id, exists := m.ID()
  9998. if exists {
  9999. return []uint64{id}, nil
  10000. }
  10001. fallthrough
  10002. case m.op.Is(OpUpdate | OpDelete):
  10003. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  10004. default:
  10005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10006. }
  10007. }
  10008. // SetCreatedAt sets the "created_at" field.
  10009. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  10010. m.created_at = &t
  10011. }
  10012. // CreatedAt returns the value of the "created_at" field in the mutation.
  10013. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  10014. v := m.created_at
  10015. if v == nil {
  10016. return
  10017. }
  10018. return *v, true
  10019. }
  10020. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  10021. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10023. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10024. if !m.op.Is(OpUpdateOne) {
  10025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10026. }
  10027. if m.id == nil || m.oldValue == nil {
  10028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10029. }
  10030. oldValue, err := m.oldValue(ctx)
  10031. if err != nil {
  10032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10033. }
  10034. return oldValue.CreatedAt, nil
  10035. }
  10036. // ResetCreatedAt resets all changes to the "created_at" field.
  10037. func (m *ChatSessionMutation) ResetCreatedAt() {
  10038. m.created_at = nil
  10039. }
  10040. // SetUpdatedAt sets the "updated_at" field.
  10041. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  10042. m.updated_at = &t
  10043. }
  10044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10045. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  10046. v := m.updated_at
  10047. if v == nil {
  10048. return
  10049. }
  10050. return *v, true
  10051. }
  10052. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  10053. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10055. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10056. if !m.op.Is(OpUpdateOne) {
  10057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10058. }
  10059. if m.id == nil || m.oldValue == nil {
  10060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10061. }
  10062. oldValue, err := m.oldValue(ctx)
  10063. if err != nil {
  10064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10065. }
  10066. return oldValue.UpdatedAt, nil
  10067. }
  10068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10069. func (m *ChatSessionMutation) ResetUpdatedAt() {
  10070. m.updated_at = nil
  10071. }
  10072. // SetDeletedAt sets the "deleted_at" field.
  10073. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  10074. m.deleted_at = &t
  10075. }
  10076. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10077. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  10078. v := m.deleted_at
  10079. if v == nil {
  10080. return
  10081. }
  10082. return *v, true
  10083. }
  10084. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  10085. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10087. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10088. if !m.op.Is(OpUpdateOne) {
  10089. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10090. }
  10091. if m.id == nil || m.oldValue == nil {
  10092. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10093. }
  10094. oldValue, err := m.oldValue(ctx)
  10095. if err != nil {
  10096. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10097. }
  10098. return oldValue.DeletedAt, nil
  10099. }
  10100. // ClearDeletedAt clears the value of the "deleted_at" field.
  10101. func (m *ChatSessionMutation) ClearDeletedAt() {
  10102. m.deleted_at = nil
  10103. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  10104. }
  10105. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10106. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  10107. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  10108. return ok
  10109. }
  10110. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10111. func (m *ChatSessionMutation) ResetDeletedAt() {
  10112. m.deleted_at = nil
  10113. delete(m.clearedFields, chatsession.FieldDeletedAt)
  10114. }
  10115. // SetName sets the "name" field.
  10116. func (m *ChatSessionMutation) SetName(s string) {
  10117. m.name = &s
  10118. }
  10119. // Name returns the value of the "name" field in the mutation.
  10120. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  10121. v := m.name
  10122. if v == nil {
  10123. return
  10124. }
  10125. return *v, true
  10126. }
  10127. // OldName returns the old "name" field's value of the ChatSession entity.
  10128. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10130. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  10131. if !m.op.Is(OpUpdateOne) {
  10132. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10133. }
  10134. if m.id == nil || m.oldValue == nil {
  10135. return v, errors.New("OldName requires an ID field in the mutation")
  10136. }
  10137. oldValue, err := m.oldValue(ctx)
  10138. if err != nil {
  10139. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10140. }
  10141. return oldValue.Name, nil
  10142. }
  10143. // ResetName resets all changes to the "name" field.
  10144. func (m *ChatSessionMutation) ResetName() {
  10145. m.name = nil
  10146. }
  10147. // SetUserID sets the "user_id" field.
  10148. func (m *ChatSessionMutation) SetUserID(u uint64) {
  10149. m.user_id = &u
  10150. m.adduser_id = nil
  10151. }
  10152. // UserID returns the value of the "user_id" field in the mutation.
  10153. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  10154. v := m.user_id
  10155. if v == nil {
  10156. return
  10157. }
  10158. return *v, true
  10159. }
  10160. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  10161. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10163. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  10164. if !m.op.Is(OpUpdateOne) {
  10165. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10166. }
  10167. if m.id == nil || m.oldValue == nil {
  10168. return v, errors.New("OldUserID requires an ID field in the mutation")
  10169. }
  10170. oldValue, err := m.oldValue(ctx)
  10171. if err != nil {
  10172. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10173. }
  10174. return oldValue.UserID, nil
  10175. }
  10176. // AddUserID adds u to the "user_id" field.
  10177. func (m *ChatSessionMutation) AddUserID(u int64) {
  10178. if m.adduser_id != nil {
  10179. *m.adduser_id += u
  10180. } else {
  10181. m.adduser_id = &u
  10182. }
  10183. }
  10184. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10185. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  10186. v := m.adduser_id
  10187. if v == nil {
  10188. return
  10189. }
  10190. return *v, true
  10191. }
  10192. // ResetUserID resets all changes to the "user_id" field.
  10193. func (m *ChatSessionMutation) ResetUserID() {
  10194. m.user_id = nil
  10195. m.adduser_id = nil
  10196. }
  10197. // SetBotID sets the "bot_id" field.
  10198. func (m *ChatSessionMutation) SetBotID(u uint64) {
  10199. m.bot_id = &u
  10200. m.addbot_id = nil
  10201. }
  10202. // BotID returns the value of the "bot_id" field in the mutation.
  10203. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  10204. v := m.bot_id
  10205. if v == nil {
  10206. return
  10207. }
  10208. return *v, true
  10209. }
  10210. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  10211. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10213. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  10214. if !m.op.Is(OpUpdateOne) {
  10215. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  10216. }
  10217. if m.id == nil || m.oldValue == nil {
  10218. return v, errors.New("OldBotID requires an ID field in the mutation")
  10219. }
  10220. oldValue, err := m.oldValue(ctx)
  10221. if err != nil {
  10222. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  10223. }
  10224. return oldValue.BotID, nil
  10225. }
  10226. // AddBotID adds u to the "bot_id" field.
  10227. func (m *ChatSessionMutation) AddBotID(u int64) {
  10228. if m.addbot_id != nil {
  10229. *m.addbot_id += u
  10230. } else {
  10231. m.addbot_id = &u
  10232. }
  10233. }
  10234. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  10235. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  10236. v := m.addbot_id
  10237. if v == nil {
  10238. return
  10239. }
  10240. return *v, true
  10241. }
  10242. // ResetBotID resets all changes to the "bot_id" field.
  10243. func (m *ChatSessionMutation) ResetBotID() {
  10244. m.bot_id = nil
  10245. m.addbot_id = nil
  10246. }
  10247. // SetBotType sets the "bot_type" field.
  10248. func (m *ChatSessionMutation) SetBotType(u uint8) {
  10249. m.bot_type = &u
  10250. m.addbot_type = nil
  10251. }
  10252. // BotType returns the value of the "bot_type" field in the mutation.
  10253. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  10254. v := m.bot_type
  10255. if v == nil {
  10256. return
  10257. }
  10258. return *v, true
  10259. }
  10260. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  10261. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10263. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  10264. if !m.op.Is(OpUpdateOne) {
  10265. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  10266. }
  10267. if m.id == nil || m.oldValue == nil {
  10268. return v, errors.New("OldBotType requires an ID field in the mutation")
  10269. }
  10270. oldValue, err := m.oldValue(ctx)
  10271. if err != nil {
  10272. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  10273. }
  10274. return oldValue.BotType, nil
  10275. }
  10276. // AddBotType adds u to the "bot_type" field.
  10277. func (m *ChatSessionMutation) AddBotType(u int8) {
  10278. if m.addbot_type != nil {
  10279. *m.addbot_type += u
  10280. } else {
  10281. m.addbot_type = &u
  10282. }
  10283. }
  10284. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  10285. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  10286. v := m.addbot_type
  10287. if v == nil {
  10288. return
  10289. }
  10290. return *v, true
  10291. }
  10292. // ResetBotType resets all changes to the "bot_type" field.
  10293. func (m *ChatSessionMutation) ResetBotType() {
  10294. m.bot_type = nil
  10295. m.addbot_type = nil
  10296. }
  10297. // Where appends a list predicates to the ChatSessionMutation builder.
  10298. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  10299. m.predicates = append(m.predicates, ps...)
  10300. }
  10301. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  10302. // users can use type-assertion to append predicates that do not depend on any generated package.
  10303. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  10304. p := make([]predicate.ChatSession, len(ps))
  10305. for i := range ps {
  10306. p[i] = ps[i]
  10307. }
  10308. m.Where(p...)
  10309. }
  10310. // Op returns the operation name.
  10311. func (m *ChatSessionMutation) Op() Op {
  10312. return m.op
  10313. }
  10314. // SetOp allows setting the mutation operation.
  10315. func (m *ChatSessionMutation) SetOp(op Op) {
  10316. m.op = op
  10317. }
  10318. // Type returns the node type of this mutation (ChatSession).
  10319. func (m *ChatSessionMutation) Type() string {
  10320. return m.typ
  10321. }
  10322. // Fields returns all fields that were changed during this mutation. Note that in
  10323. // order to get all numeric fields that were incremented/decremented, call
  10324. // AddedFields().
  10325. func (m *ChatSessionMutation) Fields() []string {
  10326. fields := make([]string, 0, 7)
  10327. if m.created_at != nil {
  10328. fields = append(fields, chatsession.FieldCreatedAt)
  10329. }
  10330. if m.updated_at != nil {
  10331. fields = append(fields, chatsession.FieldUpdatedAt)
  10332. }
  10333. if m.deleted_at != nil {
  10334. fields = append(fields, chatsession.FieldDeletedAt)
  10335. }
  10336. if m.name != nil {
  10337. fields = append(fields, chatsession.FieldName)
  10338. }
  10339. if m.user_id != nil {
  10340. fields = append(fields, chatsession.FieldUserID)
  10341. }
  10342. if m.bot_id != nil {
  10343. fields = append(fields, chatsession.FieldBotID)
  10344. }
  10345. if m.bot_type != nil {
  10346. fields = append(fields, chatsession.FieldBotType)
  10347. }
  10348. return fields
  10349. }
  10350. // Field returns the value of a field with the given name. The second boolean
  10351. // return value indicates that this field was not set, or was not defined in the
  10352. // schema.
  10353. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  10354. switch name {
  10355. case chatsession.FieldCreatedAt:
  10356. return m.CreatedAt()
  10357. case chatsession.FieldUpdatedAt:
  10358. return m.UpdatedAt()
  10359. case chatsession.FieldDeletedAt:
  10360. return m.DeletedAt()
  10361. case chatsession.FieldName:
  10362. return m.Name()
  10363. case chatsession.FieldUserID:
  10364. return m.UserID()
  10365. case chatsession.FieldBotID:
  10366. return m.BotID()
  10367. case chatsession.FieldBotType:
  10368. return m.BotType()
  10369. }
  10370. return nil, false
  10371. }
  10372. // OldField returns the old value of the field from the database. An error is
  10373. // returned if the mutation operation is not UpdateOne, or the query to the
  10374. // database failed.
  10375. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10376. switch name {
  10377. case chatsession.FieldCreatedAt:
  10378. return m.OldCreatedAt(ctx)
  10379. case chatsession.FieldUpdatedAt:
  10380. return m.OldUpdatedAt(ctx)
  10381. case chatsession.FieldDeletedAt:
  10382. return m.OldDeletedAt(ctx)
  10383. case chatsession.FieldName:
  10384. return m.OldName(ctx)
  10385. case chatsession.FieldUserID:
  10386. return m.OldUserID(ctx)
  10387. case chatsession.FieldBotID:
  10388. return m.OldBotID(ctx)
  10389. case chatsession.FieldBotType:
  10390. return m.OldBotType(ctx)
  10391. }
  10392. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  10393. }
  10394. // SetField sets the value of a field with the given name. It returns an error if
  10395. // the field is not defined in the schema, or if the type mismatched the field
  10396. // type.
  10397. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  10398. switch name {
  10399. case chatsession.FieldCreatedAt:
  10400. v, ok := value.(time.Time)
  10401. if !ok {
  10402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10403. }
  10404. m.SetCreatedAt(v)
  10405. return nil
  10406. case chatsession.FieldUpdatedAt:
  10407. v, ok := value.(time.Time)
  10408. if !ok {
  10409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10410. }
  10411. m.SetUpdatedAt(v)
  10412. return nil
  10413. case chatsession.FieldDeletedAt:
  10414. v, ok := value.(time.Time)
  10415. if !ok {
  10416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10417. }
  10418. m.SetDeletedAt(v)
  10419. return nil
  10420. case chatsession.FieldName:
  10421. v, ok := value.(string)
  10422. if !ok {
  10423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10424. }
  10425. m.SetName(v)
  10426. return nil
  10427. case chatsession.FieldUserID:
  10428. v, ok := value.(uint64)
  10429. if !ok {
  10430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10431. }
  10432. m.SetUserID(v)
  10433. return nil
  10434. case chatsession.FieldBotID:
  10435. v, ok := value.(uint64)
  10436. if !ok {
  10437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10438. }
  10439. m.SetBotID(v)
  10440. return nil
  10441. case chatsession.FieldBotType:
  10442. v, ok := value.(uint8)
  10443. if !ok {
  10444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10445. }
  10446. m.SetBotType(v)
  10447. return nil
  10448. }
  10449. return fmt.Errorf("unknown ChatSession field %s", name)
  10450. }
  10451. // AddedFields returns all numeric fields that were incremented/decremented during
  10452. // this mutation.
  10453. func (m *ChatSessionMutation) AddedFields() []string {
  10454. var fields []string
  10455. if m.adduser_id != nil {
  10456. fields = append(fields, chatsession.FieldUserID)
  10457. }
  10458. if m.addbot_id != nil {
  10459. fields = append(fields, chatsession.FieldBotID)
  10460. }
  10461. if m.addbot_type != nil {
  10462. fields = append(fields, chatsession.FieldBotType)
  10463. }
  10464. return fields
  10465. }
  10466. // AddedField returns the numeric value that was incremented/decremented on a field
  10467. // with the given name. The second boolean return value indicates that this field
  10468. // was not set, or was not defined in the schema.
  10469. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  10470. switch name {
  10471. case chatsession.FieldUserID:
  10472. return m.AddedUserID()
  10473. case chatsession.FieldBotID:
  10474. return m.AddedBotID()
  10475. case chatsession.FieldBotType:
  10476. return m.AddedBotType()
  10477. }
  10478. return nil, false
  10479. }
  10480. // AddField adds the value to the field with the given name. It returns an error if
  10481. // the field is not defined in the schema, or if the type mismatched the field
  10482. // type.
  10483. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  10484. switch name {
  10485. case chatsession.FieldUserID:
  10486. v, ok := value.(int64)
  10487. if !ok {
  10488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10489. }
  10490. m.AddUserID(v)
  10491. return nil
  10492. case chatsession.FieldBotID:
  10493. v, ok := value.(int64)
  10494. if !ok {
  10495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10496. }
  10497. m.AddBotID(v)
  10498. return nil
  10499. case chatsession.FieldBotType:
  10500. v, ok := value.(int8)
  10501. if !ok {
  10502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10503. }
  10504. m.AddBotType(v)
  10505. return nil
  10506. }
  10507. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  10508. }
  10509. // ClearedFields returns all nullable fields that were cleared during this
  10510. // mutation.
  10511. func (m *ChatSessionMutation) ClearedFields() []string {
  10512. var fields []string
  10513. if m.FieldCleared(chatsession.FieldDeletedAt) {
  10514. fields = append(fields, chatsession.FieldDeletedAt)
  10515. }
  10516. return fields
  10517. }
  10518. // FieldCleared returns a boolean indicating if a field with the given name was
  10519. // cleared in this mutation.
  10520. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  10521. _, ok := m.clearedFields[name]
  10522. return ok
  10523. }
  10524. // ClearField clears the value of the field with the given name. It returns an
  10525. // error if the field is not defined in the schema.
  10526. func (m *ChatSessionMutation) ClearField(name string) error {
  10527. switch name {
  10528. case chatsession.FieldDeletedAt:
  10529. m.ClearDeletedAt()
  10530. return nil
  10531. }
  10532. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  10533. }
  10534. // ResetField resets all changes in the mutation for the field with the given name.
  10535. // It returns an error if the field is not defined in the schema.
  10536. func (m *ChatSessionMutation) ResetField(name string) error {
  10537. switch name {
  10538. case chatsession.FieldCreatedAt:
  10539. m.ResetCreatedAt()
  10540. return nil
  10541. case chatsession.FieldUpdatedAt:
  10542. m.ResetUpdatedAt()
  10543. return nil
  10544. case chatsession.FieldDeletedAt:
  10545. m.ResetDeletedAt()
  10546. return nil
  10547. case chatsession.FieldName:
  10548. m.ResetName()
  10549. return nil
  10550. case chatsession.FieldUserID:
  10551. m.ResetUserID()
  10552. return nil
  10553. case chatsession.FieldBotID:
  10554. m.ResetBotID()
  10555. return nil
  10556. case chatsession.FieldBotType:
  10557. m.ResetBotType()
  10558. return nil
  10559. }
  10560. return fmt.Errorf("unknown ChatSession field %s", name)
  10561. }
  10562. // AddedEdges returns all edge names that were set/added in this mutation.
  10563. func (m *ChatSessionMutation) AddedEdges() []string {
  10564. edges := make([]string, 0, 0)
  10565. return edges
  10566. }
  10567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10568. // name in this mutation.
  10569. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  10570. return nil
  10571. }
  10572. // RemovedEdges returns all edge names that were removed in this mutation.
  10573. func (m *ChatSessionMutation) RemovedEdges() []string {
  10574. edges := make([]string, 0, 0)
  10575. return edges
  10576. }
  10577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10578. // the given name in this mutation.
  10579. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  10580. return nil
  10581. }
  10582. // ClearedEdges returns all edge names that were cleared in this mutation.
  10583. func (m *ChatSessionMutation) ClearedEdges() []string {
  10584. edges := make([]string, 0, 0)
  10585. return edges
  10586. }
  10587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10588. // was cleared in this mutation.
  10589. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  10590. return false
  10591. }
  10592. // ClearEdge clears the value of the edge with the given name. It returns an error
  10593. // if that edge is not defined in the schema.
  10594. func (m *ChatSessionMutation) ClearEdge(name string) error {
  10595. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  10596. }
  10597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10598. // It returns an error if the edge is not defined in the schema.
  10599. func (m *ChatSessionMutation) ResetEdge(name string) error {
  10600. return fmt.Errorf("unknown ChatSession edge %s", name)
  10601. }
  10602. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  10603. type CompapiAsynctaskMutation struct {
  10604. config
  10605. op Op
  10606. typ string
  10607. id *uint64
  10608. created_at *time.Time
  10609. updated_at *time.Time
  10610. auth_token *string
  10611. event_type *string
  10612. chat_id *string
  10613. response_chat_item_id *string
  10614. organization_id *uint64
  10615. addorganization_id *int64
  10616. openai_base *string
  10617. openai_key *string
  10618. request_raw *string
  10619. response_raw *string
  10620. callback_url *string
  10621. callback_response_raw *string
  10622. model *string
  10623. task_status *int8
  10624. addtask_status *int8
  10625. retry_count *int8
  10626. addretry_count *int8
  10627. last_error *string
  10628. clearedFields map[string]struct{}
  10629. done bool
  10630. oldValue func(context.Context) (*CompapiAsynctask, error)
  10631. predicates []predicate.CompapiAsynctask
  10632. }
  10633. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  10634. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  10635. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  10636. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  10637. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  10638. m := &CompapiAsynctaskMutation{
  10639. config: c,
  10640. op: op,
  10641. typ: TypeCompapiAsynctask,
  10642. clearedFields: make(map[string]struct{}),
  10643. }
  10644. for _, opt := range opts {
  10645. opt(m)
  10646. }
  10647. return m
  10648. }
  10649. // withCompapiAsynctaskID sets the ID field of the mutation.
  10650. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  10651. return func(m *CompapiAsynctaskMutation) {
  10652. var (
  10653. err error
  10654. once sync.Once
  10655. value *CompapiAsynctask
  10656. )
  10657. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  10658. once.Do(func() {
  10659. if m.done {
  10660. err = errors.New("querying old values post mutation is not allowed")
  10661. } else {
  10662. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  10663. }
  10664. })
  10665. return value, err
  10666. }
  10667. m.id = &id
  10668. }
  10669. }
  10670. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  10671. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  10672. return func(m *CompapiAsynctaskMutation) {
  10673. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  10674. return node, nil
  10675. }
  10676. m.id = &node.ID
  10677. }
  10678. }
  10679. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10680. // executed in a transaction (ent.Tx), a transactional client is returned.
  10681. func (m CompapiAsynctaskMutation) Client() *Client {
  10682. client := &Client{config: m.config}
  10683. client.init()
  10684. return client
  10685. }
  10686. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10687. // it returns an error otherwise.
  10688. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  10689. if _, ok := m.driver.(*txDriver); !ok {
  10690. return nil, errors.New("ent: mutation is not running in a transaction")
  10691. }
  10692. tx := &Tx{config: m.config}
  10693. tx.init()
  10694. return tx, nil
  10695. }
  10696. // SetID sets the value of the id field. Note that this
  10697. // operation is only accepted on creation of CompapiAsynctask entities.
  10698. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  10699. m.id = &id
  10700. }
  10701. // ID returns the ID value in the mutation. Note that the ID is only available
  10702. // if it was provided to the builder or after it was returned from the database.
  10703. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  10704. if m.id == nil {
  10705. return
  10706. }
  10707. return *m.id, true
  10708. }
  10709. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10710. // That means, if the mutation is applied within a transaction with an isolation level such
  10711. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10712. // or updated by the mutation.
  10713. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10714. switch {
  10715. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10716. id, exists := m.ID()
  10717. if exists {
  10718. return []uint64{id}, nil
  10719. }
  10720. fallthrough
  10721. case m.op.Is(OpUpdate | OpDelete):
  10722. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  10723. default:
  10724. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10725. }
  10726. }
  10727. // SetCreatedAt sets the "created_at" field.
  10728. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  10729. m.created_at = &t
  10730. }
  10731. // CreatedAt returns the value of the "created_at" field in the mutation.
  10732. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  10733. v := m.created_at
  10734. if v == nil {
  10735. return
  10736. }
  10737. return *v, true
  10738. }
  10739. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  10740. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10742. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10743. if !m.op.Is(OpUpdateOne) {
  10744. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10745. }
  10746. if m.id == nil || m.oldValue == nil {
  10747. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10748. }
  10749. oldValue, err := m.oldValue(ctx)
  10750. if err != nil {
  10751. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10752. }
  10753. return oldValue.CreatedAt, nil
  10754. }
  10755. // ResetCreatedAt resets all changes to the "created_at" field.
  10756. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  10757. m.created_at = nil
  10758. }
  10759. // SetUpdatedAt sets the "updated_at" field.
  10760. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  10761. m.updated_at = &t
  10762. }
  10763. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10764. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10765. v := m.updated_at
  10766. if v == nil {
  10767. return
  10768. }
  10769. return *v, true
  10770. }
  10771. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  10772. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10774. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10775. if !m.op.Is(OpUpdateOne) {
  10776. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10777. }
  10778. if m.id == nil || m.oldValue == nil {
  10779. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10780. }
  10781. oldValue, err := m.oldValue(ctx)
  10782. if err != nil {
  10783. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10784. }
  10785. return oldValue.UpdatedAt, nil
  10786. }
  10787. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10788. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  10789. m.updated_at = nil
  10790. }
  10791. // SetAuthToken sets the "auth_token" field.
  10792. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  10793. m.auth_token = &s
  10794. }
  10795. // AuthToken returns the value of the "auth_token" field in the mutation.
  10796. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  10797. v := m.auth_token
  10798. if v == nil {
  10799. return
  10800. }
  10801. return *v, true
  10802. }
  10803. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  10804. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10806. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  10807. if !m.op.Is(OpUpdateOne) {
  10808. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  10809. }
  10810. if m.id == nil || m.oldValue == nil {
  10811. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  10812. }
  10813. oldValue, err := m.oldValue(ctx)
  10814. if err != nil {
  10815. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  10816. }
  10817. return oldValue.AuthToken, nil
  10818. }
  10819. // ResetAuthToken resets all changes to the "auth_token" field.
  10820. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  10821. m.auth_token = nil
  10822. }
  10823. // SetEventType sets the "event_type" field.
  10824. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  10825. m.event_type = &s
  10826. }
  10827. // EventType returns the value of the "event_type" field in the mutation.
  10828. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  10829. v := m.event_type
  10830. if v == nil {
  10831. return
  10832. }
  10833. return *v, true
  10834. }
  10835. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  10836. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10838. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  10839. if !m.op.Is(OpUpdateOne) {
  10840. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  10841. }
  10842. if m.id == nil || m.oldValue == nil {
  10843. return v, errors.New("OldEventType requires an ID field in the mutation")
  10844. }
  10845. oldValue, err := m.oldValue(ctx)
  10846. if err != nil {
  10847. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  10848. }
  10849. return oldValue.EventType, nil
  10850. }
  10851. // ResetEventType resets all changes to the "event_type" field.
  10852. func (m *CompapiAsynctaskMutation) ResetEventType() {
  10853. m.event_type = nil
  10854. }
  10855. // SetChatID sets the "chat_id" field.
  10856. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  10857. m.chat_id = &s
  10858. }
  10859. // ChatID returns the value of the "chat_id" field in the mutation.
  10860. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  10861. v := m.chat_id
  10862. if v == nil {
  10863. return
  10864. }
  10865. return *v, true
  10866. }
  10867. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  10868. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10870. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  10871. if !m.op.Is(OpUpdateOne) {
  10872. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  10873. }
  10874. if m.id == nil || m.oldValue == nil {
  10875. return v, errors.New("OldChatID requires an ID field in the mutation")
  10876. }
  10877. oldValue, err := m.oldValue(ctx)
  10878. if err != nil {
  10879. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  10880. }
  10881. return oldValue.ChatID, nil
  10882. }
  10883. // ClearChatID clears the value of the "chat_id" field.
  10884. func (m *CompapiAsynctaskMutation) ClearChatID() {
  10885. m.chat_id = nil
  10886. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  10887. }
  10888. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  10889. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  10890. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  10891. return ok
  10892. }
  10893. // ResetChatID resets all changes to the "chat_id" field.
  10894. func (m *CompapiAsynctaskMutation) ResetChatID() {
  10895. m.chat_id = nil
  10896. delete(m.clearedFields, compapiasynctask.FieldChatID)
  10897. }
  10898. // SetResponseChatItemID sets the "response_chat_item_id" field.
  10899. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  10900. m.response_chat_item_id = &s
  10901. }
  10902. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  10903. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  10904. v := m.response_chat_item_id
  10905. if v == nil {
  10906. return
  10907. }
  10908. return *v, true
  10909. }
  10910. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  10911. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10913. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  10914. if !m.op.Is(OpUpdateOne) {
  10915. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  10916. }
  10917. if m.id == nil || m.oldValue == nil {
  10918. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  10919. }
  10920. oldValue, err := m.oldValue(ctx)
  10921. if err != nil {
  10922. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  10923. }
  10924. return oldValue.ResponseChatItemID, nil
  10925. }
  10926. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  10927. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  10928. m.response_chat_item_id = nil
  10929. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  10930. }
  10931. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  10932. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  10933. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  10934. return ok
  10935. }
  10936. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  10937. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  10938. m.response_chat_item_id = nil
  10939. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  10940. }
  10941. // SetOrganizationID sets the "organization_id" field.
  10942. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  10943. m.organization_id = &u
  10944. m.addorganization_id = nil
  10945. }
  10946. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10947. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  10948. v := m.organization_id
  10949. if v == nil {
  10950. return
  10951. }
  10952. return *v, true
  10953. }
  10954. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  10955. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10957. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10958. if !m.op.Is(OpUpdateOne) {
  10959. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10960. }
  10961. if m.id == nil || m.oldValue == nil {
  10962. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10963. }
  10964. oldValue, err := m.oldValue(ctx)
  10965. if err != nil {
  10966. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10967. }
  10968. return oldValue.OrganizationID, nil
  10969. }
  10970. // AddOrganizationID adds u to the "organization_id" field.
  10971. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  10972. if m.addorganization_id != nil {
  10973. *m.addorganization_id += u
  10974. } else {
  10975. m.addorganization_id = &u
  10976. }
  10977. }
  10978. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10979. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  10980. v := m.addorganization_id
  10981. if v == nil {
  10982. return
  10983. }
  10984. return *v, true
  10985. }
  10986. // ResetOrganizationID resets all changes to the "organization_id" field.
  10987. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  10988. m.organization_id = nil
  10989. m.addorganization_id = nil
  10990. }
  10991. // SetOpenaiBase sets the "openai_base" field.
  10992. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  10993. m.openai_base = &s
  10994. }
  10995. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  10996. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  10997. v := m.openai_base
  10998. if v == nil {
  10999. return
  11000. }
  11001. return *v, true
  11002. }
  11003. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  11004. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11006. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  11007. if !m.op.Is(OpUpdateOne) {
  11008. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  11009. }
  11010. if m.id == nil || m.oldValue == nil {
  11011. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  11012. }
  11013. oldValue, err := m.oldValue(ctx)
  11014. if err != nil {
  11015. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  11016. }
  11017. return oldValue.OpenaiBase, nil
  11018. }
  11019. // ResetOpenaiBase resets all changes to the "openai_base" field.
  11020. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  11021. m.openai_base = nil
  11022. }
  11023. // SetOpenaiKey sets the "openai_key" field.
  11024. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  11025. m.openai_key = &s
  11026. }
  11027. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  11028. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  11029. v := m.openai_key
  11030. if v == nil {
  11031. return
  11032. }
  11033. return *v, true
  11034. }
  11035. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  11036. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11038. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  11039. if !m.op.Is(OpUpdateOne) {
  11040. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  11041. }
  11042. if m.id == nil || m.oldValue == nil {
  11043. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  11044. }
  11045. oldValue, err := m.oldValue(ctx)
  11046. if err != nil {
  11047. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  11048. }
  11049. return oldValue.OpenaiKey, nil
  11050. }
  11051. // ResetOpenaiKey resets all changes to the "openai_key" field.
  11052. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  11053. m.openai_key = nil
  11054. }
  11055. // SetRequestRaw sets the "request_raw" field.
  11056. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  11057. m.request_raw = &s
  11058. }
  11059. // RequestRaw returns the value of the "request_raw" field in the mutation.
  11060. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  11061. v := m.request_raw
  11062. if v == nil {
  11063. return
  11064. }
  11065. return *v, true
  11066. }
  11067. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  11068. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11070. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  11071. if !m.op.Is(OpUpdateOne) {
  11072. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  11073. }
  11074. if m.id == nil || m.oldValue == nil {
  11075. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  11076. }
  11077. oldValue, err := m.oldValue(ctx)
  11078. if err != nil {
  11079. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  11080. }
  11081. return oldValue.RequestRaw, nil
  11082. }
  11083. // ResetRequestRaw resets all changes to the "request_raw" field.
  11084. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  11085. m.request_raw = nil
  11086. }
  11087. // SetResponseRaw sets the "response_raw" field.
  11088. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  11089. m.response_raw = &s
  11090. }
  11091. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  11092. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  11093. v := m.response_raw
  11094. if v == nil {
  11095. return
  11096. }
  11097. return *v, true
  11098. }
  11099. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  11100. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11102. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  11103. if !m.op.Is(OpUpdateOne) {
  11104. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  11105. }
  11106. if m.id == nil || m.oldValue == nil {
  11107. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  11108. }
  11109. oldValue, err := m.oldValue(ctx)
  11110. if err != nil {
  11111. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  11112. }
  11113. return oldValue.ResponseRaw, nil
  11114. }
  11115. // ClearResponseRaw clears the value of the "response_raw" field.
  11116. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  11117. m.response_raw = nil
  11118. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  11119. }
  11120. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  11121. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  11122. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  11123. return ok
  11124. }
  11125. // ResetResponseRaw resets all changes to the "response_raw" field.
  11126. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  11127. m.response_raw = nil
  11128. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  11129. }
  11130. // SetCallbackURL sets the "callback_url" field.
  11131. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  11132. m.callback_url = &s
  11133. }
  11134. // CallbackURL returns the value of the "callback_url" field in the mutation.
  11135. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  11136. v := m.callback_url
  11137. if v == nil {
  11138. return
  11139. }
  11140. return *v, true
  11141. }
  11142. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  11143. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11145. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  11146. if !m.op.Is(OpUpdateOne) {
  11147. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  11148. }
  11149. if m.id == nil || m.oldValue == nil {
  11150. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  11151. }
  11152. oldValue, err := m.oldValue(ctx)
  11153. if err != nil {
  11154. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  11155. }
  11156. return oldValue.CallbackURL, nil
  11157. }
  11158. // ResetCallbackURL resets all changes to the "callback_url" field.
  11159. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  11160. m.callback_url = nil
  11161. }
  11162. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  11163. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  11164. m.callback_response_raw = &s
  11165. }
  11166. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  11167. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  11168. v := m.callback_response_raw
  11169. if v == nil {
  11170. return
  11171. }
  11172. return *v, true
  11173. }
  11174. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  11175. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11177. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  11178. if !m.op.Is(OpUpdateOne) {
  11179. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  11180. }
  11181. if m.id == nil || m.oldValue == nil {
  11182. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  11183. }
  11184. oldValue, err := m.oldValue(ctx)
  11185. if err != nil {
  11186. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  11187. }
  11188. return oldValue.CallbackResponseRaw, nil
  11189. }
  11190. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  11191. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  11192. m.callback_response_raw = nil
  11193. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  11194. }
  11195. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  11196. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  11197. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  11198. return ok
  11199. }
  11200. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  11201. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  11202. m.callback_response_raw = nil
  11203. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  11204. }
  11205. // SetModel sets the "model" field.
  11206. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  11207. m.model = &s
  11208. }
  11209. // Model returns the value of the "model" field in the mutation.
  11210. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  11211. v := m.model
  11212. if v == nil {
  11213. return
  11214. }
  11215. return *v, true
  11216. }
  11217. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  11218. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11220. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  11221. if !m.op.Is(OpUpdateOne) {
  11222. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  11223. }
  11224. if m.id == nil || m.oldValue == nil {
  11225. return v, errors.New("OldModel requires an ID field in the mutation")
  11226. }
  11227. oldValue, err := m.oldValue(ctx)
  11228. if err != nil {
  11229. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  11230. }
  11231. return oldValue.Model, nil
  11232. }
  11233. // ClearModel clears the value of the "model" field.
  11234. func (m *CompapiAsynctaskMutation) ClearModel() {
  11235. m.model = nil
  11236. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  11237. }
  11238. // ModelCleared returns if the "model" field was cleared in this mutation.
  11239. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  11240. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  11241. return ok
  11242. }
  11243. // ResetModel resets all changes to the "model" field.
  11244. func (m *CompapiAsynctaskMutation) ResetModel() {
  11245. m.model = nil
  11246. delete(m.clearedFields, compapiasynctask.FieldModel)
  11247. }
  11248. // SetTaskStatus sets the "task_status" field.
  11249. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  11250. m.task_status = &i
  11251. m.addtask_status = nil
  11252. }
  11253. // TaskStatus returns the value of the "task_status" field in the mutation.
  11254. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  11255. v := m.task_status
  11256. if v == nil {
  11257. return
  11258. }
  11259. return *v, true
  11260. }
  11261. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  11262. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11264. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  11265. if !m.op.Is(OpUpdateOne) {
  11266. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  11267. }
  11268. if m.id == nil || m.oldValue == nil {
  11269. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  11270. }
  11271. oldValue, err := m.oldValue(ctx)
  11272. if err != nil {
  11273. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  11274. }
  11275. return oldValue.TaskStatus, nil
  11276. }
  11277. // AddTaskStatus adds i to the "task_status" field.
  11278. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  11279. if m.addtask_status != nil {
  11280. *m.addtask_status += i
  11281. } else {
  11282. m.addtask_status = &i
  11283. }
  11284. }
  11285. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  11286. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  11287. v := m.addtask_status
  11288. if v == nil {
  11289. return
  11290. }
  11291. return *v, true
  11292. }
  11293. // ClearTaskStatus clears the value of the "task_status" field.
  11294. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  11295. m.task_status = nil
  11296. m.addtask_status = nil
  11297. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  11298. }
  11299. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  11300. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  11301. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  11302. return ok
  11303. }
  11304. // ResetTaskStatus resets all changes to the "task_status" field.
  11305. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  11306. m.task_status = nil
  11307. m.addtask_status = nil
  11308. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  11309. }
  11310. // SetRetryCount sets the "retry_count" field.
  11311. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  11312. m.retry_count = &i
  11313. m.addretry_count = nil
  11314. }
  11315. // RetryCount returns the value of the "retry_count" field in the mutation.
  11316. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  11317. v := m.retry_count
  11318. if v == nil {
  11319. return
  11320. }
  11321. return *v, true
  11322. }
  11323. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  11324. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11326. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  11327. if !m.op.Is(OpUpdateOne) {
  11328. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11329. }
  11330. if m.id == nil || m.oldValue == nil {
  11331. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11332. }
  11333. oldValue, err := m.oldValue(ctx)
  11334. if err != nil {
  11335. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11336. }
  11337. return oldValue.RetryCount, nil
  11338. }
  11339. // AddRetryCount adds i to the "retry_count" field.
  11340. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  11341. if m.addretry_count != nil {
  11342. *m.addretry_count += i
  11343. } else {
  11344. m.addretry_count = &i
  11345. }
  11346. }
  11347. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11348. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  11349. v := m.addretry_count
  11350. if v == nil {
  11351. return
  11352. }
  11353. return *v, true
  11354. }
  11355. // ClearRetryCount clears the value of the "retry_count" field.
  11356. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  11357. m.retry_count = nil
  11358. m.addretry_count = nil
  11359. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  11360. }
  11361. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  11362. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  11363. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  11364. return ok
  11365. }
  11366. // ResetRetryCount resets all changes to the "retry_count" field.
  11367. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  11368. m.retry_count = nil
  11369. m.addretry_count = nil
  11370. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  11371. }
  11372. // SetLastError sets the "last_error" field.
  11373. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  11374. m.last_error = &s
  11375. }
  11376. // LastError returns the value of the "last_error" field in the mutation.
  11377. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  11378. v := m.last_error
  11379. if v == nil {
  11380. return
  11381. }
  11382. return *v, true
  11383. }
  11384. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  11385. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11387. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  11388. if !m.op.Is(OpUpdateOne) {
  11389. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  11390. }
  11391. if m.id == nil || m.oldValue == nil {
  11392. return v, errors.New("OldLastError requires an ID field in the mutation")
  11393. }
  11394. oldValue, err := m.oldValue(ctx)
  11395. if err != nil {
  11396. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  11397. }
  11398. return oldValue.LastError, nil
  11399. }
  11400. // ClearLastError clears the value of the "last_error" field.
  11401. func (m *CompapiAsynctaskMutation) ClearLastError() {
  11402. m.last_error = nil
  11403. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  11404. }
  11405. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  11406. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  11407. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  11408. return ok
  11409. }
  11410. // ResetLastError resets all changes to the "last_error" field.
  11411. func (m *CompapiAsynctaskMutation) ResetLastError() {
  11412. m.last_error = nil
  11413. delete(m.clearedFields, compapiasynctask.FieldLastError)
  11414. }
  11415. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  11416. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  11417. m.predicates = append(m.predicates, ps...)
  11418. }
  11419. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  11420. // users can use type-assertion to append predicates that do not depend on any generated package.
  11421. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11422. p := make([]predicate.CompapiAsynctask, len(ps))
  11423. for i := range ps {
  11424. p[i] = ps[i]
  11425. }
  11426. m.Where(p...)
  11427. }
  11428. // Op returns the operation name.
  11429. func (m *CompapiAsynctaskMutation) Op() Op {
  11430. return m.op
  11431. }
  11432. // SetOp allows setting the mutation operation.
  11433. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  11434. m.op = op
  11435. }
  11436. // Type returns the node type of this mutation (CompapiAsynctask).
  11437. func (m *CompapiAsynctaskMutation) Type() string {
  11438. return m.typ
  11439. }
  11440. // Fields returns all fields that were changed during this mutation. Note that in
  11441. // order to get all numeric fields that were incremented/decremented, call
  11442. // AddedFields().
  11443. func (m *CompapiAsynctaskMutation) Fields() []string {
  11444. fields := make([]string, 0, 17)
  11445. if m.created_at != nil {
  11446. fields = append(fields, compapiasynctask.FieldCreatedAt)
  11447. }
  11448. if m.updated_at != nil {
  11449. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  11450. }
  11451. if m.auth_token != nil {
  11452. fields = append(fields, compapiasynctask.FieldAuthToken)
  11453. }
  11454. if m.event_type != nil {
  11455. fields = append(fields, compapiasynctask.FieldEventType)
  11456. }
  11457. if m.chat_id != nil {
  11458. fields = append(fields, compapiasynctask.FieldChatID)
  11459. }
  11460. if m.response_chat_item_id != nil {
  11461. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11462. }
  11463. if m.organization_id != nil {
  11464. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11465. }
  11466. if m.openai_base != nil {
  11467. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  11468. }
  11469. if m.openai_key != nil {
  11470. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  11471. }
  11472. if m.request_raw != nil {
  11473. fields = append(fields, compapiasynctask.FieldRequestRaw)
  11474. }
  11475. if m.response_raw != nil {
  11476. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11477. }
  11478. if m.callback_url != nil {
  11479. fields = append(fields, compapiasynctask.FieldCallbackURL)
  11480. }
  11481. if m.callback_response_raw != nil {
  11482. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11483. }
  11484. if m.model != nil {
  11485. fields = append(fields, compapiasynctask.FieldModel)
  11486. }
  11487. if m.task_status != nil {
  11488. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11489. }
  11490. if m.retry_count != nil {
  11491. fields = append(fields, compapiasynctask.FieldRetryCount)
  11492. }
  11493. if m.last_error != nil {
  11494. fields = append(fields, compapiasynctask.FieldLastError)
  11495. }
  11496. return fields
  11497. }
  11498. // Field returns the value of a field with the given name. The second boolean
  11499. // return value indicates that this field was not set, or was not defined in the
  11500. // schema.
  11501. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  11502. switch name {
  11503. case compapiasynctask.FieldCreatedAt:
  11504. return m.CreatedAt()
  11505. case compapiasynctask.FieldUpdatedAt:
  11506. return m.UpdatedAt()
  11507. case compapiasynctask.FieldAuthToken:
  11508. return m.AuthToken()
  11509. case compapiasynctask.FieldEventType:
  11510. return m.EventType()
  11511. case compapiasynctask.FieldChatID:
  11512. return m.ChatID()
  11513. case compapiasynctask.FieldResponseChatItemID:
  11514. return m.ResponseChatItemID()
  11515. case compapiasynctask.FieldOrganizationID:
  11516. return m.OrganizationID()
  11517. case compapiasynctask.FieldOpenaiBase:
  11518. return m.OpenaiBase()
  11519. case compapiasynctask.FieldOpenaiKey:
  11520. return m.OpenaiKey()
  11521. case compapiasynctask.FieldRequestRaw:
  11522. return m.RequestRaw()
  11523. case compapiasynctask.FieldResponseRaw:
  11524. return m.ResponseRaw()
  11525. case compapiasynctask.FieldCallbackURL:
  11526. return m.CallbackURL()
  11527. case compapiasynctask.FieldCallbackResponseRaw:
  11528. return m.CallbackResponseRaw()
  11529. case compapiasynctask.FieldModel:
  11530. return m.Model()
  11531. case compapiasynctask.FieldTaskStatus:
  11532. return m.TaskStatus()
  11533. case compapiasynctask.FieldRetryCount:
  11534. return m.RetryCount()
  11535. case compapiasynctask.FieldLastError:
  11536. return m.LastError()
  11537. }
  11538. return nil, false
  11539. }
  11540. // OldField returns the old value of the field from the database. An error is
  11541. // returned if the mutation operation is not UpdateOne, or the query to the
  11542. // database failed.
  11543. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11544. switch name {
  11545. case compapiasynctask.FieldCreatedAt:
  11546. return m.OldCreatedAt(ctx)
  11547. case compapiasynctask.FieldUpdatedAt:
  11548. return m.OldUpdatedAt(ctx)
  11549. case compapiasynctask.FieldAuthToken:
  11550. return m.OldAuthToken(ctx)
  11551. case compapiasynctask.FieldEventType:
  11552. return m.OldEventType(ctx)
  11553. case compapiasynctask.FieldChatID:
  11554. return m.OldChatID(ctx)
  11555. case compapiasynctask.FieldResponseChatItemID:
  11556. return m.OldResponseChatItemID(ctx)
  11557. case compapiasynctask.FieldOrganizationID:
  11558. return m.OldOrganizationID(ctx)
  11559. case compapiasynctask.FieldOpenaiBase:
  11560. return m.OldOpenaiBase(ctx)
  11561. case compapiasynctask.FieldOpenaiKey:
  11562. return m.OldOpenaiKey(ctx)
  11563. case compapiasynctask.FieldRequestRaw:
  11564. return m.OldRequestRaw(ctx)
  11565. case compapiasynctask.FieldResponseRaw:
  11566. return m.OldResponseRaw(ctx)
  11567. case compapiasynctask.FieldCallbackURL:
  11568. return m.OldCallbackURL(ctx)
  11569. case compapiasynctask.FieldCallbackResponseRaw:
  11570. return m.OldCallbackResponseRaw(ctx)
  11571. case compapiasynctask.FieldModel:
  11572. return m.OldModel(ctx)
  11573. case compapiasynctask.FieldTaskStatus:
  11574. return m.OldTaskStatus(ctx)
  11575. case compapiasynctask.FieldRetryCount:
  11576. return m.OldRetryCount(ctx)
  11577. case compapiasynctask.FieldLastError:
  11578. return m.OldLastError(ctx)
  11579. }
  11580. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11581. }
  11582. // SetField sets the value of a field with the given name. It returns an error if
  11583. // the field is not defined in the schema, or if the type mismatched the field
  11584. // type.
  11585. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  11586. switch name {
  11587. case compapiasynctask.FieldCreatedAt:
  11588. v, ok := value.(time.Time)
  11589. if !ok {
  11590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11591. }
  11592. m.SetCreatedAt(v)
  11593. return nil
  11594. case compapiasynctask.FieldUpdatedAt:
  11595. v, ok := value.(time.Time)
  11596. if !ok {
  11597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11598. }
  11599. m.SetUpdatedAt(v)
  11600. return nil
  11601. case compapiasynctask.FieldAuthToken:
  11602. v, ok := value.(string)
  11603. if !ok {
  11604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11605. }
  11606. m.SetAuthToken(v)
  11607. return nil
  11608. case compapiasynctask.FieldEventType:
  11609. v, ok := value.(string)
  11610. if !ok {
  11611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11612. }
  11613. m.SetEventType(v)
  11614. return nil
  11615. case compapiasynctask.FieldChatID:
  11616. v, ok := value.(string)
  11617. if !ok {
  11618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11619. }
  11620. m.SetChatID(v)
  11621. return nil
  11622. case compapiasynctask.FieldResponseChatItemID:
  11623. v, ok := value.(string)
  11624. if !ok {
  11625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11626. }
  11627. m.SetResponseChatItemID(v)
  11628. return nil
  11629. case compapiasynctask.FieldOrganizationID:
  11630. v, ok := value.(uint64)
  11631. if !ok {
  11632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11633. }
  11634. m.SetOrganizationID(v)
  11635. return nil
  11636. case compapiasynctask.FieldOpenaiBase:
  11637. v, ok := value.(string)
  11638. if !ok {
  11639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11640. }
  11641. m.SetOpenaiBase(v)
  11642. return nil
  11643. case compapiasynctask.FieldOpenaiKey:
  11644. v, ok := value.(string)
  11645. if !ok {
  11646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11647. }
  11648. m.SetOpenaiKey(v)
  11649. return nil
  11650. case compapiasynctask.FieldRequestRaw:
  11651. v, ok := value.(string)
  11652. if !ok {
  11653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11654. }
  11655. m.SetRequestRaw(v)
  11656. return nil
  11657. case compapiasynctask.FieldResponseRaw:
  11658. v, ok := value.(string)
  11659. if !ok {
  11660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11661. }
  11662. m.SetResponseRaw(v)
  11663. return nil
  11664. case compapiasynctask.FieldCallbackURL:
  11665. v, ok := value.(string)
  11666. if !ok {
  11667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11668. }
  11669. m.SetCallbackURL(v)
  11670. return nil
  11671. case compapiasynctask.FieldCallbackResponseRaw:
  11672. v, ok := value.(string)
  11673. if !ok {
  11674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11675. }
  11676. m.SetCallbackResponseRaw(v)
  11677. return nil
  11678. case compapiasynctask.FieldModel:
  11679. v, ok := value.(string)
  11680. if !ok {
  11681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11682. }
  11683. m.SetModel(v)
  11684. return nil
  11685. case compapiasynctask.FieldTaskStatus:
  11686. v, ok := value.(int8)
  11687. if !ok {
  11688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11689. }
  11690. m.SetTaskStatus(v)
  11691. return nil
  11692. case compapiasynctask.FieldRetryCount:
  11693. v, ok := value.(int8)
  11694. if !ok {
  11695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11696. }
  11697. m.SetRetryCount(v)
  11698. return nil
  11699. case compapiasynctask.FieldLastError:
  11700. v, ok := value.(string)
  11701. if !ok {
  11702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11703. }
  11704. m.SetLastError(v)
  11705. return nil
  11706. }
  11707. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11708. }
  11709. // AddedFields returns all numeric fields that were incremented/decremented during
  11710. // this mutation.
  11711. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  11712. var fields []string
  11713. if m.addorganization_id != nil {
  11714. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11715. }
  11716. if m.addtask_status != nil {
  11717. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11718. }
  11719. if m.addretry_count != nil {
  11720. fields = append(fields, compapiasynctask.FieldRetryCount)
  11721. }
  11722. return fields
  11723. }
  11724. // AddedField returns the numeric value that was incremented/decremented on a field
  11725. // with the given name. The second boolean return value indicates that this field
  11726. // was not set, or was not defined in the schema.
  11727. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  11728. switch name {
  11729. case compapiasynctask.FieldOrganizationID:
  11730. return m.AddedOrganizationID()
  11731. case compapiasynctask.FieldTaskStatus:
  11732. return m.AddedTaskStatus()
  11733. case compapiasynctask.FieldRetryCount:
  11734. return m.AddedRetryCount()
  11735. }
  11736. return nil, false
  11737. }
  11738. // AddField adds the value to the field with the given name. It returns an error if
  11739. // the field is not defined in the schema, or if the type mismatched the field
  11740. // type.
  11741. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  11742. switch name {
  11743. case compapiasynctask.FieldOrganizationID:
  11744. v, ok := value.(int64)
  11745. if !ok {
  11746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11747. }
  11748. m.AddOrganizationID(v)
  11749. return nil
  11750. case compapiasynctask.FieldTaskStatus:
  11751. v, ok := value.(int8)
  11752. if !ok {
  11753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11754. }
  11755. m.AddTaskStatus(v)
  11756. return nil
  11757. case compapiasynctask.FieldRetryCount:
  11758. v, ok := value.(int8)
  11759. if !ok {
  11760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11761. }
  11762. m.AddRetryCount(v)
  11763. return nil
  11764. }
  11765. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  11766. }
  11767. // ClearedFields returns all nullable fields that were cleared during this
  11768. // mutation.
  11769. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  11770. var fields []string
  11771. if m.FieldCleared(compapiasynctask.FieldChatID) {
  11772. fields = append(fields, compapiasynctask.FieldChatID)
  11773. }
  11774. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  11775. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11776. }
  11777. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  11778. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11779. }
  11780. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  11781. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11782. }
  11783. if m.FieldCleared(compapiasynctask.FieldModel) {
  11784. fields = append(fields, compapiasynctask.FieldModel)
  11785. }
  11786. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  11787. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11788. }
  11789. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  11790. fields = append(fields, compapiasynctask.FieldRetryCount)
  11791. }
  11792. if m.FieldCleared(compapiasynctask.FieldLastError) {
  11793. fields = append(fields, compapiasynctask.FieldLastError)
  11794. }
  11795. return fields
  11796. }
  11797. // FieldCleared returns a boolean indicating if a field with the given name was
  11798. // cleared in this mutation.
  11799. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  11800. _, ok := m.clearedFields[name]
  11801. return ok
  11802. }
  11803. // ClearField clears the value of the field with the given name. It returns an
  11804. // error if the field is not defined in the schema.
  11805. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  11806. switch name {
  11807. case compapiasynctask.FieldChatID:
  11808. m.ClearChatID()
  11809. return nil
  11810. case compapiasynctask.FieldResponseChatItemID:
  11811. m.ClearResponseChatItemID()
  11812. return nil
  11813. case compapiasynctask.FieldResponseRaw:
  11814. m.ClearResponseRaw()
  11815. return nil
  11816. case compapiasynctask.FieldCallbackResponseRaw:
  11817. m.ClearCallbackResponseRaw()
  11818. return nil
  11819. case compapiasynctask.FieldModel:
  11820. m.ClearModel()
  11821. return nil
  11822. case compapiasynctask.FieldTaskStatus:
  11823. m.ClearTaskStatus()
  11824. return nil
  11825. case compapiasynctask.FieldRetryCount:
  11826. m.ClearRetryCount()
  11827. return nil
  11828. case compapiasynctask.FieldLastError:
  11829. m.ClearLastError()
  11830. return nil
  11831. }
  11832. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  11833. }
  11834. // ResetField resets all changes in the mutation for the field with the given name.
  11835. // It returns an error if the field is not defined in the schema.
  11836. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  11837. switch name {
  11838. case compapiasynctask.FieldCreatedAt:
  11839. m.ResetCreatedAt()
  11840. return nil
  11841. case compapiasynctask.FieldUpdatedAt:
  11842. m.ResetUpdatedAt()
  11843. return nil
  11844. case compapiasynctask.FieldAuthToken:
  11845. m.ResetAuthToken()
  11846. return nil
  11847. case compapiasynctask.FieldEventType:
  11848. m.ResetEventType()
  11849. return nil
  11850. case compapiasynctask.FieldChatID:
  11851. m.ResetChatID()
  11852. return nil
  11853. case compapiasynctask.FieldResponseChatItemID:
  11854. m.ResetResponseChatItemID()
  11855. return nil
  11856. case compapiasynctask.FieldOrganizationID:
  11857. m.ResetOrganizationID()
  11858. return nil
  11859. case compapiasynctask.FieldOpenaiBase:
  11860. m.ResetOpenaiBase()
  11861. return nil
  11862. case compapiasynctask.FieldOpenaiKey:
  11863. m.ResetOpenaiKey()
  11864. return nil
  11865. case compapiasynctask.FieldRequestRaw:
  11866. m.ResetRequestRaw()
  11867. return nil
  11868. case compapiasynctask.FieldResponseRaw:
  11869. m.ResetResponseRaw()
  11870. return nil
  11871. case compapiasynctask.FieldCallbackURL:
  11872. m.ResetCallbackURL()
  11873. return nil
  11874. case compapiasynctask.FieldCallbackResponseRaw:
  11875. m.ResetCallbackResponseRaw()
  11876. return nil
  11877. case compapiasynctask.FieldModel:
  11878. m.ResetModel()
  11879. return nil
  11880. case compapiasynctask.FieldTaskStatus:
  11881. m.ResetTaskStatus()
  11882. return nil
  11883. case compapiasynctask.FieldRetryCount:
  11884. m.ResetRetryCount()
  11885. return nil
  11886. case compapiasynctask.FieldLastError:
  11887. m.ResetLastError()
  11888. return nil
  11889. }
  11890. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11891. }
  11892. // AddedEdges returns all edge names that were set/added in this mutation.
  11893. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  11894. edges := make([]string, 0, 0)
  11895. return edges
  11896. }
  11897. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11898. // name in this mutation.
  11899. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  11900. return nil
  11901. }
  11902. // RemovedEdges returns all edge names that were removed in this mutation.
  11903. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  11904. edges := make([]string, 0, 0)
  11905. return edges
  11906. }
  11907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11908. // the given name in this mutation.
  11909. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  11910. return nil
  11911. }
  11912. // ClearedEdges returns all edge names that were cleared in this mutation.
  11913. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  11914. edges := make([]string, 0, 0)
  11915. return edges
  11916. }
  11917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11918. // was cleared in this mutation.
  11919. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  11920. return false
  11921. }
  11922. // ClearEdge clears the value of the edge with the given name. It returns an error
  11923. // if that edge is not defined in the schema.
  11924. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  11925. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  11926. }
  11927. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11928. // It returns an error if the edge is not defined in the schema.
  11929. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  11930. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  11931. }
  11932. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  11933. type ContactMutation struct {
  11934. config
  11935. op Op
  11936. typ string
  11937. id *uint64
  11938. created_at *time.Time
  11939. updated_at *time.Time
  11940. status *uint8
  11941. addstatus *int8
  11942. deleted_at *time.Time
  11943. wx_wxid *string
  11944. _type *int
  11945. add_type *int
  11946. wxid *string
  11947. account *string
  11948. nickname *string
  11949. markname *string
  11950. headimg *string
  11951. sex *int
  11952. addsex *int
  11953. starrole *string
  11954. dontseeit *int
  11955. adddontseeit *int
  11956. dontseeme *int
  11957. adddontseeme *int
  11958. lag *string
  11959. gid *string
  11960. gname *string
  11961. v3 *string
  11962. organization_id *uint64
  11963. addorganization_id *int64
  11964. ctype *uint64
  11965. addctype *int64
  11966. cage *int
  11967. addcage *int
  11968. cname *string
  11969. carea *string
  11970. cbirthday *string
  11971. cbirtharea *string
  11972. cidcard_no *string
  11973. ctitle *string
  11974. cc *string
  11975. phone *string
  11976. clearedFields map[string]struct{}
  11977. contact_relationships map[uint64]struct{}
  11978. removedcontact_relationships map[uint64]struct{}
  11979. clearedcontact_relationships bool
  11980. contact_fields map[uint64]struct{}
  11981. removedcontact_fields map[uint64]struct{}
  11982. clearedcontact_fields bool
  11983. contact_messages map[uint64]struct{}
  11984. removedcontact_messages map[uint64]struct{}
  11985. clearedcontact_messages bool
  11986. done bool
  11987. oldValue func(context.Context) (*Contact, error)
  11988. predicates []predicate.Contact
  11989. }
  11990. var _ ent.Mutation = (*ContactMutation)(nil)
  11991. // contactOption allows management of the mutation configuration using functional options.
  11992. type contactOption func(*ContactMutation)
  11993. // newContactMutation creates new mutation for the Contact entity.
  11994. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  11995. m := &ContactMutation{
  11996. config: c,
  11997. op: op,
  11998. typ: TypeContact,
  11999. clearedFields: make(map[string]struct{}),
  12000. }
  12001. for _, opt := range opts {
  12002. opt(m)
  12003. }
  12004. return m
  12005. }
  12006. // withContactID sets the ID field of the mutation.
  12007. func withContactID(id uint64) contactOption {
  12008. return func(m *ContactMutation) {
  12009. var (
  12010. err error
  12011. once sync.Once
  12012. value *Contact
  12013. )
  12014. m.oldValue = func(ctx context.Context) (*Contact, error) {
  12015. once.Do(func() {
  12016. if m.done {
  12017. err = errors.New("querying old values post mutation is not allowed")
  12018. } else {
  12019. value, err = m.Client().Contact.Get(ctx, id)
  12020. }
  12021. })
  12022. return value, err
  12023. }
  12024. m.id = &id
  12025. }
  12026. }
  12027. // withContact sets the old Contact of the mutation.
  12028. func withContact(node *Contact) contactOption {
  12029. return func(m *ContactMutation) {
  12030. m.oldValue = func(context.Context) (*Contact, error) {
  12031. return node, nil
  12032. }
  12033. m.id = &node.ID
  12034. }
  12035. }
  12036. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12037. // executed in a transaction (ent.Tx), a transactional client is returned.
  12038. func (m ContactMutation) Client() *Client {
  12039. client := &Client{config: m.config}
  12040. client.init()
  12041. return client
  12042. }
  12043. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12044. // it returns an error otherwise.
  12045. func (m ContactMutation) Tx() (*Tx, error) {
  12046. if _, ok := m.driver.(*txDriver); !ok {
  12047. return nil, errors.New("ent: mutation is not running in a transaction")
  12048. }
  12049. tx := &Tx{config: m.config}
  12050. tx.init()
  12051. return tx, nil
  12052. }
  12053. // SetID sets the value of the id field. Note that this
  12054. // operation is only accepted on creation of Contact entities.
  12055. func (m *ContactMutation) SetID(id uint64) {
  12056. m.id = &id
  12057. }
  12058. // ID returns the ID value in the mutation. Note that the ID is only available
  12059. // if it was provided to the builder or after it was returned from the database.
  12060. func (m *ContactMutation) ID() (id uint64, exists bool) {
  12061. if m.id == nil {
  12062. return
  12063. }
  12064. return *m.id, true
  12065. }
  12066. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12067. // That means, if the mutation is applied within a transaction with an isolation level such
  12068. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12069. // or updated by the mutation.
  12070. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  12071. switch {
  12072. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12073. id, exists := m.ID()
  12074. if exists {
  12075. return []uint64{id}, nil
  12076. }
  12077. fallthrough
  12078. case m.op.Is(OpUpdate | OpDelete):
  12079. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  12080. default:
  12081. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12082. }
  12083. }
  12084. // SetCreatedAt sets the "created_at" field.
  12085. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  12086. m.created_at = &t
  12087. }
  12088. // CreatedAt returns the value of the "created_at" field in the mutation.
  12089. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  12090. v := m.created_at
  12091. if v == nil {
  12092. return
  12093. }
  12094. return *v, true
  12095. }
  12096. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  12097. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12099. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12100. if !m.op.Is(OpUpdateOne) {
  12101. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12102. }
  12103. if m.id == nil || m.oldValue == nil {
  12104. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12105. }
  12106. oldValue, err := m.oldValue(ctx)
  12107. if err != nil {
  12108. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12109. }
  12110. return oldValue.CreatedAt, nil
  12111. }
  12112. // ResetCreatedAt resets all changes to the "created_at" field.
  12113. func (m *ContactMutation) ResetCreatedAt() {
  12114. m.created_at = nil
  12115. }
  12116. // SetUpdatedAt sets the "updated_at" field.
  12117. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  12118. m.updated_at = &t
  12119. }
  12120. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12121. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  12122. v := m.updated_at
  12123. if v == nil {
  12124. return
  12125. }
  12126. return *v, true
  12127. }
  12128. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  12129. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12131. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12132. if !m.op.Is(OpUpdateOne) {
  12133. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12134. }
  12135. if m.id == nil || m.oldValue == nil {
  12136. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12137. }
  12138. oldValue, err := m.oldValue(ctx)
  12139. if err != nil {
  12140. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12141. }
  12142. return oldValue.UpdatedAt, nil
  12143. }
  12144. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12145. func (m *ContactMutation) ResetUpdatedAt() {
  12146. m.updated_at = nil
  12147. }
  12148. // SetStatus sets the "status" field.
  12149. func (m *ContactMutation) SetStatus(u uint8) {
  12150. m.status = &u
  12151. m.addstatus = nil
  12152. }
  12153. // Status returns the value of the "status" field in the mutation.
  12154. func (m *ContactMutation) Status() (r uint8, exists bool) {
  12155. v := m.status
  12156. if v == nil {
  12157. return
  12158. }
  12159. return *v, true
  12160. }
  12161. // OldStatus returns the old "status" field's value of the Contact entity.
  12162. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12164. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12165. if !m.op.Is(OpUpdateOne) {
  12166. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12167. }
  12168. if m.id == nil || m.oldValue == nil {
  12169. return v, errors.New("OldStatus requires an ID field in the mutation")
  12170. }
  12171. oldValue, err := m.oldValue(ctx)
  12172. if err != nil {
  12173. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12174. }
  12175. return oldValue.Status, nil
  12176. }
  12177. // AddStatus adds u to the "status" field.
  12178. func (m *ContactMutation) AddStatus(u int8) {
  12179. if m.addstatus != nil {
  12180. *m.addstatus += u
  12181. } else {
  12182. m.addstatus = &u
  12183. }
  12184. }
  12185. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12186. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  12187. v := m.addstatus
  12188. if v == nil {
  12189. return
  12190. }
  12191. return *v, true
  12192. }
  12193. // ClearStatus clears the value of the "status" field.
  12194. func (m *ContactMutation) ClearStatus() {
  12195. m.status = nil
  12196. m.addstatus = nil
  12197. m.clearedFields[contact.FieldStatus] = struct{}{}
  12198. }
  12199. // StatusCleared returns if the "status" field was cleared in this mutation.
  12200. func (m *ContactMutation) StatusCleared() bool {
  12201. _, ok := m.clearedFields[contact.FieldStatus]
  12202. return ok
  12203. }
  12204. // ResetStatus resets all changes to the "status" field.
  12205. func (m *ContactMutation) ResetStatus() {
  12206. m.status = nil
  12207. m.addstatus = nil
  12208. delete(m.clearedFields, contact.FieldStatus)
  12209. }
  12210. // SetDeletedAt sets the "deleted_at" field.
  12211. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  12212. m.deleted_at = &t
  12213. }
  12214. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12215. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  12216. v := m.deleted_at
  12217. if v == nil {
  12218. return
  12219. }
  12220. return *v, true
  12221. }
  12222. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  12223. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12225. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12226. if !m.op.Is(OpUpdateOne) {
  12227. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12228. }
  12229. if m.id == nil || m.oldValue == nil {
  12230. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12231. }
  12232. oldValue, err := m.oldValue(ctx)
  12233. if err != nil {
  12234. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12235. }
  12236. return oldValue.DeletedAt, nil
  12237. }
  12238. // ClearDeletedAt clears the value of the "deleted_at" field.
  12239. func (m *ContactMutation) ClearDeletedAt() {
  12240. m.deleted_at = nil
  12241. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  12242. }
  12243. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12244. func (m *ContactMutation) DeletedAtCleared() bool {
  12245. _, ok := m.clearedFields[contact.FieldDeletedAt]
  12246. return ok
  12247. }
  12248. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12249. func (m *ContactMutation) ResetDeletedAt() {
  12250. m.deleted_at = nil
  12251. delete(m.clearedFields, contact.FieldDeletedAt)
  12252. }
  12253. // SetWxWxid sets the "wx_wxid" field.
  12254. func (m *ContactMutation) SetWxWxid(s string) {
  12255. m.wx_wxid = &s
  12256. }
  12257. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12258. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  12259. v := m.wx_wxid
  12260. if v == nil {
  12261. return
  12262. }
  12263. return *v, true
  12264. }
  12265. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  12266. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12268. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12269. if !m.op.Is(OpUpdateOne) {
  12270. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12271. }
  12272. if m.id == nil || m.oldValue == nil {
  12273. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12274. }
  12275. oldValue, err := m.oldValue(ctx)
  12276. if err != nil {
  12277. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12278. }
  12279. return oldValue.WxWxid, nil
  12280. }
  12281. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12282. func (m *ContactMutation) ResetWxWxid() {
  12283. m.wx_wxid = nil
  12284. }
  12285. // SetType sets the "type" field.
  12286. func (m *ContactMutation) SetType(i int) {
  12287. m._type = &i
  12288. m.add_type = nil
  12289. }
  12290. // GetType returns the value of the "type" field in the mutation.
  12291. func (m *ContactMutation) GetType() (r int, exists bool) {
  12292. v := m._type
  12293. if v == nil {
  12294. return
  12295. }
  12296. return *v, true
  12297. }
  12298. // OldType returns the old "type" field's value of the Contact entity.
  12299. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12301. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  12302. if !m.op.Is(OpUpdateOne) {
  12303. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12304. }
  12305. if m.id == nil || m.oldValue == nil {
  12306. return v, errors.New("OldType requires an ID field in the mutation")
  12307. }
  12308. oldValue, err := m.oldValue(ctx)
  12309. if err != nil {
  12310. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12311. }
  12312. return oldValue.Type, nil
  12313. }
  12314. // AddType adds i to the "type" field.
  12315. func (m *ContactMutation) AddType(i int) {
  12316. if m.add_type != nil {
  12317. *m.add_type += i
  12318. } else {
  12319. m.add_type = &i
  12320. }
  12321. }
  12322. // AddedType returns the value that was added to the "type" field in this mutation.
  12323. func (m *ContactMutation) AddedType() (r int, exists bool) {
  12324. v := m.add_type
  12325. if v == nil {
  12326. return
  12327. }
  12328. return *v, true
  12329. }
  12330. // ClearType clears the value of the "type" field.
  12331. func (m *ContactMutation) ClearType() {
  12332. m._type = nil
  12333. m.add_type = nil
  12334. m.clearedFields[contact.FieldType] = struct{}{}
  12335. }
  12336. // TypeCleared returns if the "type" field was cleared in this mutation.
  12337. func (m *ContactMutation) TypeCleared() bool {
  12338. _, ok := m.clearedFields[contact.FieldType]
  12339. return ok
  12340. }
  12341. // ResetType resets all changes to the "type" field.
  12342. func (m *ContactMutation) ResetType() {
  12343. m._type = nil
  12344. m.add_type = nil
  12345. delete(m.clearedFields, contact.FieldType)
  12346. }
  12347. // SetWxid sets the "wxid" field.
  12348. func (m *ContactMutation) SetWxid(s string) {
  12349. m.wxid = &s
  12350. }
  12351. // Wxid returns the value of the "wxid" field in the mutation.
  12352. func (m *ContactMutation) Wxid() (r string, exists bool) {
  12353. v := m.wxid
  12354. if v == nil {
  12355. return
  12356. }
  12357. return *v, true
  12358. }
  12359. // OldWxid returns the old "wxid" field's value of the Contact entity.
  12360. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12362. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  12363. if !m.op.Is(OpUpdateOne) {
  12364. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12365. }
  12366. if m.id == nil || m.oldValue == nil {
  12367. return v, errors.New("OldWxid requires an ID field in the mutation")
  12368. }
  12369. oldValue, err := m.oldValue(ctx)
  12370. if err != nil {
  12371. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12372. }
  12373. return oldValue.Wxid, nil
  12374. }
  12375. // ResetWxid resets all changes to the "wxid" field.
  12376. func (m *ContactMutation) ResetWxid() {
  12377. m.wxid = nil
  12378. }
  12379. // SetAccount sets the "account" field.
  12380. func (m *ContactMutation) SetAccount(s string) {
  12381. m.account = &s
  12382. }
  12383. // Account returns the value of the "account" field in the mutation.
  12384. func (m *ContactMutation) Account() (r string, exists bool) {
  12385. v := m.account
  12386. if v == nil {
  12387. return
  12388. }
  12389. return *v, true
  12390. }
  12391. // OldAccount returns the old "account" field's value of the Contact entity.
  12392. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12394. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  12395. if !m.op.Is(OpUpdateOne) {
  12396. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12397. }
  12398. if m.id == nil || m.oldValue == nil {
  12399. return v, errors.New("OldAccount requires an ID field in the mutation")
  12400. }
  12401. oldValue, err := m.oldValue(ctx)
  12402. if err != nil {
  12403. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12404. }
  12405. return oldValue.Account, nil
  12406. }
  12407. // ResetAccount resets all changes to the "account" field.
  12408. func (m *ContactMutation) ResetAccount() {
  12409. m.account = nil
  12410. }
  12411. // SetNickname sets the "nickname" field.
  12412. func (m *ContactMutation) SetNickname(s string) {
  12413. m.nickname = &s
  12414. }
  12415. // Nickname returns the value of the "nickname" field in the mutation.
  12416. func (m *ContactMutation) Nickname() (r string, exists bool) {
  12417. v := m.nickname
  12418. if v == nil {
  12419. return
  12420. }
  12421. return *v, true
  12422. }
  12423. // OldNickname returns the old "nickname" field's value of the Contact entity.
  12424. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12426. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  12427. if !m.op.Is(OpUpdateOne) {
  12428. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12429. }
  12430. if m.id == nil || m.oldValue == nil {
  12431. return v, errors.New("OldNickname requires an ID field in the mutation")
  12432. }
  12433. oldValue, err := m.oldValue(ctx)
  12434. if err != nil {
  12435. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12436. }
  12437. return oldValue.Nickname, nil
  12438. }
  12439. // ResetNickname resets all changes to the "nickname" field.
  12440. func (m *ContactMutation) ResetNickname() {
  12441. m.nickname = nil
  12442. }
  12443. // SetMarkname sets the "markname" field.
  12444. func (m *ContactMutation) SetMarkname(s string) {
  12445. m.markname = &s
  12446. }
  12447. // Markname returns the value of the "markname" field in the mutation.
  12448. func (m *ContactMutation) Markname() (r string, exists bool) {
  12449. v := m.markname
  12450. if v == nil {
  12451. return
  12452. }
  12453. return *v, true
  12454. }
  12455. // OldMarkname returns the old "markname" field's value of the Contact entity.
  12456. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12458. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  12459. if !m.op.Is(OpUpdateOne) {
  12460. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  12461. }
  12462. if m.id == nil || m.oldValue == nil {
  12463. return v, errors.New("OldMarkname requires an ID field in the mutation")
  12464. }
  12465. oldValue, err := m.oldValue(ctx)
  12466. if err != nil {
  12467. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  12468. }
  12469. return oldValue.Markname, nil
  12470. }
  12471. // ResetMarkname resets all changes to the "markname" field.
  12472. func (m *ContactMutation) ResetMarkname() {
  12473. m.markname = nil
  12474. }
  12475. // SetHeadimg sets the "headimg" field.
  12476. func (m *ContactMutation) SetHeadimg(s string) {
  12477. m.headimg = &s
  12478. }
  12479. // Headimg returns the value of the "headimg" field in the mutation.
  12480. func (m *ContactMutation) Headimg() (r string, exists bool) {
  12481. v := m.headimg
  12482. if v == nil {
  12483. return
  12484. }
  12485. return *v, true
  12486. }
  12487. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  12488. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12490. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  12491. if !m.op.Is(OpUpdateOne) {
  12492. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  12493. }
  12494. if m.id == nil || m.oldValue == nil {
  12495. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  12496. }
  12497. oldValue, err := m.oldValue(ctx)
  12498. if err != nil {
  12499. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  12500. }
  12501. return oldValue.Headimg, nil
  12502. }
  12503. // ResetHeadimg resets all changes to the "headimg" field.
  12504. func (m *ContactMutation) ResetHeadimg() {
  12505. m.headimg = nil
  12506. }
  12507. // SetSex sets the "sex" field.
  12508. func (m *ContactMutation) SetSex(i int) {
  12509. m.sex = &i
  12510. m.addsex = nil
  12511. }
  12512. // Sex returns the value of the "sex" field in the mutation.
  12513. func (m *ContactMutation) Sex() (r int, exists bool) {
  12514. v := m.sex
  12515. if v == nil {
  12516. return
  12517. }
  12518. return *v, true
  12519. }
  12520. // OldSex returns the old "sex" field's value of the Contact entity.
  12521. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12523. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  12524. if !m.op.Is(OpUpdateOne) {
  12525. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  12526. }
  12527. if m.id == nil || m.oldValue == nil {
  12528. return v, errors.New("OldSex requires an ID field in the mutation")
  12529. }
  12530. oldValue, err := m.oldValue(ctx)
  12531. if err != nil {
  12532. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  12533. }
  12534. return oldValue.Sex, nil
  12535. }
  12536. // AddSex adds i to the "sex" field.
  12537. func (m *ContactMutation) AddSex(i int) {
  12538. if m.addsex != nil {
  12539. *m.addsex += i
  12540. } else {
  12541. m.addsex = &i
  12542. }
  12543. }
  12544. // AddedSex returns the value that was added to the "sex" field in this mutation.
  12545. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  12546. v := m.addsex
  12547. if v == nil {
  12548. return
  12549. }
  12550. return *v, true
  12551. }
  12552. // ResetSex resets all changes to the "sex" field.
  12553. func (m *ContactMutation) ResetSex() {
  12554. m.sex = nil
  12555. m.addsex = nil
  12556. }
  12557. // SetStarrole sets the "starrole" field.
  12558. func (m *ContactMutation) SetStarrole(s string) {
  12559. m.starrole = &s
  12560. }
  12561. // Starrole returns the value of the "starrole" field in the mutation.
  12562. func (m *ContactMutation) Starrole() (r string, exists bool) {
  12563. v := m.starrole
  12564. if v == nil {
  12565. return
  12566. }
  12567. return *v, true
  12568. }
  12569. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  12570. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12572. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  12573. if !m.op.Is(OpUpdateOne) {
  12574. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  12575. }
  12576. if m.id == nil || m.oldValue == nil {
  12577. return v, errors.New("OldStarrole requires an ID field in the mutation")
  12578. }
  12579. oldValue, err := m.oldValue(ctx)
  12580. if err != nil {
  12581. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  12582. }
  12583. return oldValue.Starrole, nil
  12584. }
  12585. // ResetStarrole resets all changes to the "starrole" field.
  12586. func (m *ContactMutation) ResetStarrole() {
  12587. m.starrole = nil
  12588. }
  12589. // SetDontseeit sets the "dontseeit" field.
  12590. func (m *ContactMutation) SetDontseeit(i int) {
  12591. m.dontseeit = &i
  12592. m.adddontseeit = nil
  12593. }
  12594. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  12595. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  12596. v := m.dontseeit
  12597. if v == nil {
  12598. return
  12599. }
  12600. return *v, true
  12601. }
  12602. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  12603. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12605. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  12606. if !m.op.Is(OpUpdateOne) {
  12607. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  12608. }
  12609. if m.id == nil || m.oldValue == nil {
  12610. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  12611. }
  12612. oldValue, err := m.oldValue(ctx)
  12613. if err != nil {
  12614. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  12615. }
  12616. return oldValue.Dontseeit, nil
  12617. }
  12618. // AddDontseeit adds i to the "dontseeit" field.
  12619. func (m *ContactMutation) AddDontseeit(i int) {
  12620. if m.adddontseeit != nil {
  12621. *m.adddontseeit += i
  12622. } else {
  12623. m.adddontseeit = &i
  12624. }
  12625. }
  12626. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  12627. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  12628. v := m.adddontseeit
  12629. if v == nil {
  12630. return
  12631. }
  12632. return *v, true
  12633. }
  12634. // ResetDontseeit resets all changes to the "dontseeit" field.
  12635. func (m *ContactMutation) ResetDontseeit() {
  12636. m.dontseeit = nil
  12637. m.adddontseeit = nil
  12638. }
  12639. // SetDontseeme sets the "dontseeme" field.
  12640. func (m *ContactMutation) SetDontseeme(i int) {
  12641. m.dontseeme = &i
  12642. m.adddontseeme = nil
  12643. }
  12644. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  12645. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  12646. v := m.dontseeme
  12647. if v == nil {
  12648. return
  12649. }
  12650. return *v, true
  12651. }
  12652. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  12653. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12655. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  12656. if !m.op.Is(OpUpdateOne) {
  12657. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  12658. }
  12659. if m.id == nil || m.oldValue == nil {
  12660. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  12661. }
  12662. oldValue, err := m.oldValue(ctx)
  12663. if err != nil {
  12664. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  12665. }
  12666. return oldValue.Dontseeme, nil
  12667. }
  12668. // AddDontseeme adds i to the "dontseeme" field.
  12669. func (m *ContactMutation) AddDontseeme(i int) {
  12670. if m.adddontseeme != nil {
  12671. *m.adddontseeme += i
  12672. } else {
  12673. m.adddontseeme = &i
  12674. }
  12675. }
  12676. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  12677. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  12678. v := m.adddontseeme
  12679. if v == nil {
  12680. return
  12681. }
  12682. return *v, true
  12683. }
  12684. // ResetDontseeme resets all changes to the "dontseeme" field.
  12685. func (m *ContactMutation) ResetDontseeme() {
  12686. m.dontseeme = nil
  12687. m.adddontseeme = nil
  12688. }
  12689. // SetLag sets the "lag" field.
  12690. func (m *ContactMutation) SetLag(s string) {
  12691. m.lag = &s
  12692. }
  12693. // Lag returns the value of the "lag" field in the mutation.
  12694. func (m *ContactMutation) Lag() (r string, exists bool) {
  12695. v := m.lag
  12696. if v == nil {
  12697. return
  12698. }
  12699. return *v, true
  12700. }
  12701. // OldLag returns the old "lag" field's value of the Contact entity.
  12702. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12704. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  12705. if !m.op.Is(OpUpdateOne) {
  12706. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  12707. }
  12708. if m.id == nil || m.oldValue == nil {
  12709. return v, errors.New("OldLag requires an ID field in the mutation")
  12710. }
  12711. oldValue, err := m.oldValue(ctx)
  12712. if err != nil {
  12713. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  12714. }
  12715. return oldValue.Lag, nil
  12716. }
  12717. // ResetLag resets all changes to the "lag" field.
  12718. func (m *ContactMutation) ResetLag() {
  12719. m.lag = nil
  12720. }
  12721. // SetGid sets the "gid" field.
  12722. func (m *ContactMutation) SetGid(s string) {
  12723. m.gid = &s
  12724. }
  12725. // Gid returns the value of the "gid" field in the mutation.
  12726. func (m *ContactMutation) Gid() (r string, exists bool) {
  12727. v := m.gid
  12728. if v == nil {
  12729. return
  12730. }
  12731. return *v, true
  12732. }
  12733. // OldGid returns the old "gid" 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) OldGid(ctx context.Context) (v string, err error) {
  12737. if !m.op.Is(OpUpdateOne) {
  12738. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  12739. }
  12740. if m.id == nil || m.oldValue == nil {
  12741. return v, errors.New("OldGid 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 OldGid: %w", err)
  12746. }
  12747. return oldValue.Gid, nil
  12748. }
  12749. // ResetGid resets all changes to the "gid" field.
  12750. func (m *ContactMutation) ResetGid() {
  12751. m.gid = nil
  12752. }
  12753. // SetGname sets the "gname" field.
  12754. func (m *ContactMutation) SetGname(s string) {
  12755. m.gname = &s
  12756. }
  12757. // Gname returns the value of the "gname" field in the mutation.
  12758. func (m *ContactMutation) Gname() (r string, exists bool) {
  12759. v := m.gname
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // OldGname returns the old "gname" field's value of the Contact entity.
  12766. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12768. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  12769. if !m.op.Is(OpUpdateOne) {
  12770. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  12771. }
  12772. if m.id == nil || m.oldValue == nil {
  12773. return v, errors.New("OldGname requires an ID field in the mutation")
  12774. }
  12775. oldValue, err := m.oldValue(ctx)
  12776. if err != nil {
  12777. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  12778. }
  12779. return oldValue.Gname, nil
  12780. }
  12781. // ResetGname resets all changes to the "gname" field.
  12782. func (m *ContactMutation) ResetGname() {
  12783. m.gname = nil
  12784. }
  12785. // SetV3 sets the "v3" field.
  12786. func (m *ContactMutation) SetV3(s string) {
  12787. m.v3 = &s
  12788. }
  12789. // V3 returns the value of the "v3" field in the mutation.
  12790. func (m *ContactMutation) V3() (r string, exists bool) {
  12791. v := m.v3
  12792. if v == nil {
  12793. return
  12794. }
  12795. return *v, true
  12796. }
  12797. // OldV3 returns the old "v3" field's value of the Contact entity.
  12798. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12800. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  12801. if !m.op.Is(OpUpdateOne) {
  12802. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  12803. }
  12804. if m.id == nil || m.oldValue == nil {
  12805. return v, errors.New("OldV3 requires an ID field in the mutation")
  12806. }
  12807. oldValue, err := m.oldValue(ctx)
  12808. if err != nil {
  12809. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  12810. }
  12811. return oldValue.V3, nil
  12812. }
  12813. // ResetV3 resets all changes to the "v3" field.
  12814. func (m *ContactMutation) ResetV3() {
  12815. m.v3 = nil
  12816. }
  12817. // SetOrganizationID sets the "organization_id" field.
  12818. func (m *ContactMutation) SetOrganizationID(u uint64) {
  12819. m.organization_id = &u
  12820. m.addorganization_id = nil
  12821. }
  12822. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12823. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  12824. v := m.organization_id
  12825. if v == nil {
  12826. return
  12827. }
  12828. return *v, true
  12829. }
  12830. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  12831. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12833. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12834. if !m.op.Is(OpUpdateOne) {
  12835. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12836. }
  12837. if m.id == nil || m.oldValue == nil {
  12838. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12839. }
  12840. oldValue, err := m.oldValue(ctx)
  12841. if err != nil {
  12842. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12843. }
  12844. return oldValue.OrganizationID, nil
  12845. }
  12846. // AddOrganizationID adds u to the "organization_id" field.
  12847. func (m *ContactMutation) AddOrganizationID(u int64) {
  12848. if m.addorganization_id != nil {
  12849. *m.addorganization_id += u
  12850. } else {
  12851. m.addorganization_id = &u
  12852. }
  12853. }
  12854. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12855. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  12856. v := m.addorganization_id
  12857. if v == nil {
  12858. return
  12859. }
  12860. return *v, true
  12861. }
  12862. // ClearOrganizationID clears the value of the "organization_id" field.
  12863. func (m *ContactMutation) ClearOrganizationID() {
  12864. m.organization_id = nil
  12865. m.addorganization_id = nil
  12866. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  12867. }
  12868. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12869. func (m *ContactMutation) OrganizationIDCleared() bool {
  12870. _, ok := m.clearedFields[contact.FieldOrganizationID]
  12871. return ok
  12872. }
  12873. // ResetOrganizationID resets all changes to the "organization_id" field.
  12874. func (m *ContactMutation) ResetOrganizationID() {
  12875. m.organization_id = nil
  12876. m.addorganization_id = nil
  12877. delete(m.clearedFields, contact.FieldOrganizationID)
  12878. }
  12879. // SetCtype sets the "ctype" field.
  12880. func (m *ContactMutation) SetCtype(u uint64) {
  12881. m.ctype = &u
  12882. m.addctype = nil
  12883. }
  12884. // Ctype returns the value of the "ctype" field in the mutation.
  12885. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  12886. v := m.ctype
  12887. if v == nil {
  12888. return
  12889. }
  12890. return *v, true
  12891. }
  12892. // OldCtype returns the old "ctype" field's value of the Contact entity.
  12893. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12895. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  12896. if !m.op.Is(OpUpdateOne) {
  12897. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  12898. }
  12899. if m.id == nil || m.oldValue == nil {
  12900. return v, errors.New("OldCtype requires an ID field in the mutation")
  12901. }
  12902. oldValue, err := m.oldValue(ctx)
  12903. if err != nil {
  12904. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  12905. }
  12906. return oldValue.Ctype, nil
  12907. }
  12908. // AddCtype adds u to the "ctype" field.
  12909. func (m *ContactMutation) AddCtype(u int64) {
  12910. if m.addctype != nil {
  12911. *m.addctype += u
  12912. } else {
  12913. m.addctype = &u
  12914. }
  12915. }
  12916. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  12917. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  12918. v := m.addctype
  12919. if v == nil {
  12920. return
  12921. }
  12922. return *v, true
  12923. }
  12924. // ResetCtype resets all changes to the "ctype" field.
  12925. func (m *ContactMutation) ResetCtype() {
  12926. m.ctype = nil
  12927. m.addctype = nil
  12928. }
  12929. // SetCage sets the "cage" field.
  12930. func (m *ContactMutation) SetCage(i int) {
  12931. m.cage = &i
  12932. m.addcage = nil
  12933. }
  12934. // Cage returns the value of the "cage" field in the mutation.
  12935. func (m *ContactMutation) Cage() (r int, exists bool) {
  12936. v := m.cage
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCage returns the old "cage" field's value of the Contact entity.
  12943. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCage requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  12955. }
  12956. return oldValue.Cage, nil
  12957. }
  12958. // AddCage adds i to the "cage" field.
  12959. func (m *ContactMutation) AddCage(i int) {
  12960. if m.addcage != nil {
  12961. *m.addcage += i
  12962. } else {
  12963. m.addcage = &i
  12964. }
  12965. }
  12966. // AddedCage returns the value that was added to the "cage" field in this mutation.
  12967. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  12968. v := m.addcage
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // ResetCage resets all changes to the "cage" field.
  12975. func (m *ContactMutation) ResetCage() {
  12976. m.cage = nil
  12977. m.addcage = nil
  12978. }
  12979. // SetCname sets the "cname" field.
  12980. func (m *ContactMutation) SetCname(s string) {
  12981. m.cname = &s
  12982. }
  12983. // Cname returns the value of the "cname" field in the mutation.
  12984. func (m *ContactMutation) Cname() (r string, exists bool) {
  12985. v := m.cname
  12986. if v == nil {
  12987. return
  12988. }
  12989. return *v, true
  12990. }
  12991. // OldCname returns the old "cname" field's value of the Contact entity.
  12992. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12994. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  12995. if !m.op.Is(OpUpdateOne) {
  12996. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  12997. }
  12998. if m.id == nil || m.oldValue == nil {
  12999. return v, errors.New("OldCname requires an ID field in the mutation")
  13000. }
  13001. oldValue, err := m.oldValue(ctx)
  13002. if err != nil {
  13003. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  13004. }
  13005. return oldValue.Cname, nil
  13006. }
  13007. // ResetCname resets all changes to the "cname" field.
  13008. func (m *ContactMutation) ResetCname() {
  13009. m.cname = nil
  13010. }
  13011. // SetCarea sets the "carea" field.
  13012. func (m *ContactMutation) SetCarea(s string) {
  13013. m.carea = &s
  13014. }
  13015. // Carea returns the value of the "carea" field in the mutation.
  13016. func (m *ContactMutation) Carea() (r string, exists bool) {
  13017. v := m.carea
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldCarea returns the old "carea" 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) OldCarea(ctx context.Context) (v string, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldCarea 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 OldCarea: %w", err)
  13036. }
  13037. return oldValue.Carea, nil
  13038. }
  13039. // ResetCarea resets all changes to the "carea" field.
  13040. func (m *ContactMutation) ResetCarea() {
  13041. m.carea = nil
  13042. }
  13043. // SetCbirthday sets the "cbirthday" field.
  13044. func (m *ContactMutation) SetCbirthday(s string) {
  13045. m.cbirthday = &s
  13046. }
  13047. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  13048. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  13049. v := m.cbirthday
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  13056. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13058. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  13059. if !m.op.Is(OpUpdateOne) {
  13060. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  13061. }
  13062. if m.id == nil || m.oldValue == nil {
  13063. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  13064. }
  13065. oldValue, err := m.oldValue(ctx)
  13066. if err != nil {
  13067. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  13068. }
  13069. return oldValue.Cbirthday, nil
  13070. }
  13071. // ResetCbirthday resets all changes to the "cbirthday" field.
  13072. func (m *ContactMutation) ResetCbirthday() {
  13073. m.cbirthday = nil
  13074. }
  13075. // SetCbirtharea sets the "cbirtharea" field.
  13076. func (m *ContactMutation) SetCbirtharea(s string) {
  13077. m.cbirtharea = &s
  13078. }
  13079. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  13080. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  13081. v := m.cbirtharea
  13082. if v == nil {
  13083. return
  13084. }
  13085. return *v, true
  13086. }
  13087. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  13088. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13090. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  13091. if !m.op.Is(OpUpdateOne) {
  13092. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  13093. }
  13094. if m.id == nil || m.oldValue == nil {
  13095. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  13096. }
  13097. oldValue, err := m.oldValue(ctx)
  13098. if err != nil {
  13099. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  13100. }
  13101. return oldValue.Cbirtharea, nil
  13102. }
  13103. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  13104. func (m *ContactMutation) ResetCbirtharea() {
  13105. m.cbirtharea = nil
  13106. }
  13107. // SetCidcardNo sets the "cidcard_no" field.
  13108. func (m *ContactMutation) SetCidcardNo(s string) {
  13109. m.cidcard_no = &s
  13110. }
  13111. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  13112. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  13113. v := m.cidcard_no
  13114. if v == nil {
  13115. return
  13116. }
  13117. return *v, true
  13118. }
  13119. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  13120. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13122. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  13123. if !m.op.Is(OpUpdateOne) {
  13124. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  13125. }
  13126. if m.id == nil || m.oldValue == nil {
  13127. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  13128. }
  13129. oldValue, err := m.oldValue(ctx)
  13130. if err != nil {
  13131. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  13132. }
  13133. return oldValue.CidcardNo, nil
  13134. }
  13135. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  13136. func (m *ContactMutation) ResetCidcardNo() {
  13137. m.cidcard_no = nil
  13138. }
  13139. // SetCtitle sets the "ctitle" field.
  13140. func (m *ContactMutation) SetCtitle(s string) {
  13141. m.ctitle = &s
  13142. }
  13143. // Ctitle returns the value of the "ctitle" field in the mutation.
  13144. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  13145. v := m.ctitle
  13146. if v == nil {
  13147. return
  13148. }
  13149. return *v, true
  13150. }
  13151. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  13152. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13154. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  13155. if !m.op.Is(OpUpdateOne) {
  13156. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  13157. }
  13158. if m.id == nil || m.oldValue == nil {
  13159. return v, errors.New("OldCtitle requires an ID field in the mutation")
  13160. }
  13161. oldValue, err := m.oldValue(ctx)
  13162. if err != nil {
  13163. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  13164. }
  13165. return oldValue.Ctitle, nil
  13166. }
  13167. // ResetCtitle resets all changes to the "ctitle" field.
  13168. func (m *ContactMutation) ResetCtitle() {
  13169. m.ctitle = nil
  13170. }
  13171. // SetCc sets the "cc" field.
  13172. func (m *ContactMutation) SetCc(s string) {
  13173. m.cc = &s
  13174. }
  13175. // Cc returns the value of the "cc" field in the mutation.
  13176. func (m *ContactMutation) Cc() (r string, exists bool) {
  13177. v := m.cc
  13178. if v == nil {
  13179. return
  13180. }
  13181. return *v, true
  13182. }
  13183. // OldCc returns the old "cc" field's value of the Contact entity.
  13184. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13186. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  13187. if !m.op.Is(OpUpdateOne) {
  13188. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  13189. }
  13190. if m.id == nil || m.oldValue == nil {
  13191. return v, errors.New("OldCc requires an ID field in the mutation")
  13192. }
  13193. oldValue, err := m.oldValue(ctx)
  13194. if err != nil {
  13195. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  13196. }
  13197. return oldValue.Cc, nil
  13198. }
  13199. // ResetCc resets all changes to the "cc" field.
  13200. func (m *ContactMutation) ResetCc() {
  13201. m.cc = nil
  13202. }
  13203. // SetPhone sets the "phone" field.
  13204. func (m *ContactMutation) SetPhone(s string) {
  13205. m.phone = &s
  13206. }
  13207. // Phone returns the value of the "phone" field in the mutation.
  13208. func (m *ContactMutation) Phone() (r string, exists bool) {
  13209. v := m.phone
  13210. if v == nil {
  13211. return
  13212. }
  13213. return *v, true
  13214. }
  13215. // OldPhone returns the old "phone" field's value of the Contact entity.
  13216. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13218. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  13219. if !m.op.Is(OpUpdateOne) {
  13220. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  13221. }
  13222. if m.id == nil || m.oldValue == nil {
  13223. return v, errors.New("OldPhone requires an ID field in the mutation")
  13224. }
  13225. oldValue, err := m.oldValue(ctx)
  13226. if err != nil {
  13227. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  13228. }
  13229. return oldValue.Phone, nil
  13230. }
  13231. // ResetPhone resets all changes to the "phone" field.
  13232. func (m *ContactMutation) ResetPhone() {
  13233. m.phone = nil
  13234. }
  13235. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  13236. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  13237. if m.contact_relationships == nil {
  13238. m.contact_relationships = make(map[uint64]struct{})
  13239. }
  13240. for i := range ids {
  13241. m.contact_relationships[ids[i]] = struct{}{}
  13242. }
  13243. }
  13244. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  13245. func (m *ContactMutation) ClearContactRelationships() {
  13246. m.clearedcontact_relationships = true
  13247. }
  13248. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  13249. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  13250. return m.clearedcontact_relationships
  13251. }
  13252. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  13253. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  13254. if m.removedcontact_relationships == nil {
  13255. m.removedcontact_relationships = make(map[uint64]struct{})
  13256. }
  13257. for i := range ids {
  13258. delete(m.contact_relationships, ids[i])
  13259. m.removedcontact_relationships[ids[i]] = struct{}{}
  13260. }
  13261. }
  13262. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  13263. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  13264. for id := range m.removedcontact_relationships {
  13265. ids = append(ids, id)
  13266. }
  13267. return
  13268. }
  13269. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  13270. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  13271. for id := range m.contact_relationships {
  13272. ids = append(ids, id)
  13273. }
  13274. return
  13275. }
  13276. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  13277. func (m *ContactMutation) ResetContactRelationships() {
  13278. m.contact_relationships = nil
  13279. m.clearedcontact_relationships = false
  13280. m.removedcontact_relationships = nil
  13281. }
  13282. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  13283. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  13284. if m.contact_fields == nil {
  13285. m.contact_fields = make(map[uint64]struct{})
  13286. }
  13287. for i := range ids {
  13288. m.contact_fields[ids[i]] = struct{}{}
  13289. }
  13290. }
  13291. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  13292. func (m *ContactMutation) ClearContactFields() {
  13293. m.clearedcontact_fields = true
  13294. }
  13295. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  13296. func (m *ContactMutation) ContactFieldsCleared() bool {
  13297. return m.clearedcontact_fields
  13298. }
  13299. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  13300. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  13301. if m.removedcontact_fields == nil {
  13302. m.removedcontact_fields = make(map[uint64]struct{})
  13303. }
  13304. for i := range ids {
  13305. delete(m.contact_fields, ids[i])
  13306. m.removedcontact_fields[ids[i]] = struct{}{}
  13307. }
  13308. }
  13309. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  13310. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  13311. for id := range m.removedcontact_fields {
  13312. ids = append(ids, id)
  13313. }
  13314. return
  13315. }
  13316. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  13317. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  13318. for id := range m.contact_fields {
  13319. ids = append(ids, id)
  13320. }
  13321. return
  13322. }
  13323. // ResetContactFields resets all changes to the "contact_fields" edge.
  13324. func (m *ContactMutation) ResetContactFields() {
  13325. m.contact_fields = nil
  13326. m.clearedcontact_fields = false
  13327. m.removedcontact_fields = nil
  13328. }
  13329. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  13330. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  13331. if m.contact_messages == nil {
  13332. m.contact_messages = make(map[uint64]struct{})
  13333. }
  13334. for i := range ids {
  13335. m.contact_messages[ids[i]] = struct{}{}
  13336. }
  13337. }
  13338. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  13339. func (m *ContactMutation) ClearContactMessages() {
  13340. m.clearedcontact_messages = true
  13341. }
  13342. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  13343. func (m *ContactMutation) ContactMessagesCleared() bool {
  13344. return m.clearedcontact_messages
  13345. }
  13346. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  13347. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  13348. if m.removedcontact_messages == nil {
  13349. m.removedcontact_messages = make(map[uint64]struct{})
  13350. }
  13351. for i := range ids {
  13352. delete(m.contact_messages, ids[i])
  13353. m.removedcontact_messages[ids[i]] = struct{}{}
  13354. }
  13355. }
  13356. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  13357. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  13358. for id := range m.removedcontact_messages {
  13359. ids = append(ids, id)
  13360. }
  13361. return
  13362. }
  13363. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  13364. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  13365. for id := range m.contact_messages {
  13366. ids = append(ids, id)
  13367. }
  13368. return
  13369. }
  13370. // ResetContactMessages resets all changes to the "contact_messages" edge.
  13371. func (m *ContactMutation) ResetContactMessages() {
  13372. m.contact_messages = nil
  13373. m.clearedcontact_messages = false
  13374. m.removedcontact_messages = nil
  13375. }
  13376. // Where appends a list predicates to the ContactMutation builder.
  13377. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  13378. m.predicates = append(m.predicates, ps...)
  13379. }
  13380. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  13381. // users can use type-assertion to append predicates that do not depend on any generated package.
  13382. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  13383. p := make([]predicate.Contact, len(ps))
  13384. for i := range ps {
  13385. p[i] = ps[i]
  13386. }
  13387. m.Where(p...)
  13388. }
  13389. // Op returns the operation name.
  13390. func (m *ContactMutation) Op() Op {
  13391. return m.op
  13392. }
  13393. // SetOp allows setting the mutation operation.
  13394. func (m *ContactMutation) SetOp(op Op) {
  13395. m.op = op
  13396. }
  13397. // Type returns the node type of this mutation (Contact).
  13398. func (m *ContactMutation) Type() string {
  13399. return m.typ
  13400. }
  13401. // Fields returns all fields that were changed during this mutation. Note that in
  13402. // order to get all numeric fields that were incremented/decremented, call
  13403. // AddedFields().
  13404. func (m *ContactMutation) Fields() []string {
  13405. fields := make([]string, 0, 30)
  13406. if m.created_at != nil {
  13407. fields = append(fields, contact.FieldCreatedAt)
  13408. }
  13409. if m.updated_at != nil {
  13410. fields = append(fields, contact.FieldUpdatedAt)
  13411. }
  13412. if m.status != nil {
  13413. fields = append(fields, contact.FieldStatus)
  13414. }
  13415. if m.deleted_at != nil {
  13416. fields = append(fields, contact.FieldDeletedAt)
  13417. }
  13418. if m.wx_wxid != nil {
  13419. fields = append(fields, contact.FieldWxWxid)
  13420. }
  13421. if m._type != nil {
  13422. fields = append(fields, contact.FieldType)
  13423. }
  13424. if m.wxid != nil {
  13425. fields = append(fields, contact.FieldWxid)
  13426. }
  13427. if m.account != nil {
  13428. fields = append(fields, contact.FieldAccount)
  13429. }
  13430. if m.nickname != nil {
  13431. fields = append(fields, contact.FieldNickname)
  13432. }
  13433. if m.markname != nil {
  13434. fields = append(fields, contact.FieldMarkname)
  13435. }
  13436. if m.headimg != nil {
  13437. fields = append(fields, contact.FieldHeadimg)
  13438. }
  13439. if m.sex != nil {
  13440. fields = append(fields, contact.FieldSex)
  13441. }
  13442. if m.starrole != nil {
  13443. fields = append(fields, contact.FieldStarrole)
  13444. }
  13445. if m.dontseeit != nil {
  13446. fields = append(fields, contact.FieldDontseeit)
  13447. }
  13448. if m.dontseeme != nil {
  13449. fields = append(fields, contact.FieldDontseeme)
  13450. }
  13451. if m.lag != nil {
  13452. fields = append(fields, contact.FieldLag)
  13453. }
  13454. if m.gid != nil {
  13455. fields = append(fields, contact.FieldGid)
  13456. }
  13457. if m.gname != nil {
  13458. fields = append(fields, contact.FieldGname)
  13459. }
  13460. if m.v3 != nil {
  13461. fields = append(fields, contact.FieldV3)
  13462. }
  13463. if m.organization_id != nil {
  13464. fields = append(fields, contact.FieldOrganizationID)
  13465. }
  13466. if m.ctype != nil {
  13467. fields = append(fields, contact.FieldCtype)
  13468. }
  13469. if m.cage != nil {
  13470. fields = append(fields, contact.FieldCage)
  13471. }
  13472. if m.cname != nil {
  13473. fields = append(fields, contact.FieldCname)
  13474. }
  13475. if m.carea != nil {
  13476. fields = append(fields, contact.FieldCarea)
  13477. }
  13478. if m.cbirthday != nil {
  13479. fields = append(fields, contact.FieldCbirthday)
  13480. }
  13481. if m.cbirtharea != nil {
  13482. fields = append(fields, contact.FieldCbirtharea)
  13483. }
  13484. if m.cidcard_no != nil {
  13485. fields = append(fields, contact.FieldCidcardNo)
  13486. }
  13487. if m.ctitle != nil {
  13488. fields = append(fields, contact.FieldCtitle)
  13489. }
  13490. if m.cc != nil {
  13491. fields = append(fields, contact.FieldCc)
  13492. }
  13493. if m.phone != nil {
  13494. fields = append(fields, contact.FieldPhone)
  13495. }
  13496. return fields
  13497. }
  13498. // Field returns the value of a field with the given name. The second boolean
  13499. // return value indicates that this field was not set, or was not defined in the
  13500. // schema.
  13501. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  13502. switch name {
  13503. case contact.FieldCreatedAt:
  13504. return m.CreatedAt()
  13505. case contact.FieldUpdatedAt:
  13506. return m.UpdatedAt()
  13507. case contact.FieldStatus:
  13508. return m.Status()
  13509. case contact.FieldDeletedAt:
  13510. return m.DeletedAt()
  13511. case contact.FieldWxWxid:
  13512. return m.WxWxid()
  13513. case contact.FieldType:
  13514. return m.GetType()
  13515. case contact.FieldWxid:
  13516. return m.Wxid()
  13517. case contact.FieldAccount:
  13518. return m.Account()
  13519. case contact.FieldNickname:
  13520. return m.Nickname()
  13521. case contact.FieldMarkname:
  13522. return m.Markname()
  13523. case contact.FieldHeadimg:
  13524. return m.Headimg()
  13525. case contact.FieldSex:
  13526. return m.Sex()
  13527. case contact.FieldStarrole:
  13528. return m.Starrole()
  13529. case contact.FieldDontseeit:
  13530. return m.Dontseeit()
  13531. case contact.FieldDontseeme:
  13532. return m.Dontseeme()
  13533. case contact.FieldLag:
  13534. return m.Lag()
  13535. case contact.FieldGid:
  13536. return m.Gid()
  13537. case contact.FieldGname:
  13538. return m.Gname()
  13539. case contact.FieldV3:
  13540. return m.V3()
  13541. case contact.FieldOrganizationID:
  13542. return m.OrganizationID()
  13543. case contact.FieldCtype:
  13544. return m.Ctype()
  13545. case contact.FieldCage:
  13546. return m.Cage()
  13547. case contact.FieldCname:
  13548. return m.Cname()
  13549. case contact.FieldCarea:
  13550. return m.Carea()
  13551. case contact.FieldCbirthday:
  13552. return m.Cbirthday()
  13553. case contact.FieldCbirtharea:
  13554. return m.Cbirtharea()
  13555. case contact.FieldCidcardNo:
  13556. return m.CidcardNo()
  13557. case contact.FieldCtitle:
  13558. return m.Ctitle()
  13559. case contact.FieldCc:
  13560. return m.Cc()
  13561. case contact.FieldPhone:
  13562. return m.Phone()
  13563. }
  13564. return nil, false
  13565. }
  13566. // OldField returns the old value of the field from the database. An error is
  13567. // returned if the mutation operation is not UpdateOne, or the query to the
  13568. // database failed.
  13569. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13570. switch name {
  13571. case contact.FieldCreatedAt:
  13572. return m.OldCreatedAt(ctx)
  13573. case contact.FieldUpdatedAt:
  13574. return m.OldUpdatedAt(ctx)
  13575. case contact.FieldStatus:
  13576. return m.OldStatus(ctx)
  13577. case contact.FieldDeletedAt:
  13578. return m.OldDeletedAt(ctx)
  13579. case contact.FieldWxWxid:
  13580. return m.OldWxWxid(ctx)
  13581. case contact.FieldType:
  13582. return m.OldType(ctx)
  13583. case contact.FieldWxid:
  13584. return m.OldWxid(ctx)
  13585. case contact.FieldAccount:
  13586. return m.OldAccount(ctx)
  13587. case contact.FieldNickname:
  13588. return m.OldNickname(ctx)
  13589. case contact.FieldMarkname:
  13590. return m.OldMarkname(ctx)
  13591. case contact.FieldHeadimg:
  13592. return m.OldHeadimg(ctx)
  13593. case contact.FieldSex:
  13594. return m.OldSex(ctx)
  13595. case contact.FieldStarrole:
  13596. return m.OldStarrole(ctx)
  13597. case contact.FieldDontseeit:
  13598. return m.OldDontseeit(ctx)
  13599. case contact.FieldDontseeme:
  13600. return m.OldDontseeme(ctx)
  13601. case contact.FieldLag:
  13602. return m.OldLag(ctx)
  13603. case contact.FieldGid:
  13604. return m.OldGid(ctx)
  13605. case contact.FieldGname:
  13606. return m.OldGname(ctx)
  13607. case contact.FieldV3:
  13608. return m.OldV3(ctx)
  13609. case contact.FieldOrganizationID:
  13610. return m.OldOrganizationID(ctx)
  13611. case contact.FieldCtype:
  13612. return m.OldCtype(ctx)
  13613. case contact.FieldCage:
  13614. return m.OldCage(ctx)
  13615. case contact.FieldCname:
  13616. return m.OldCname(ctx)
  13617. case contact.FieldCarea:
  13618. return m.OldCarea(ctx)
  13619. case contact.FieldCbirthday:
  13620. return m.OldCbirthday(ctx)
  13621. case contact.FieldCbirtharea:
  13622. return m.OldCbirtharea(ctx)
  13623. case contact.FieldCidcardNo:
  13624. return m.OldCidcardNo(ctx)
  13625. case contact.FieldCtitle:
  13626. return m.OldCtitle(ctx)
  13627. case contact.FieldCc:
  13628. return m.OldCc(ctx)
  13629. case contact.FieldPhone:
  13630. return m.OldPhone(ctx)
  13631. }
  13632. return nil, fmt.Errorf("unknown Contact field %s", name)
  13633. }
  13634. // SetField sets the value of a field with the given name. It returns an error if
  13635. // the field is not defined in the schema, or if the type mismatched the field
  13636. // type.
  13637. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  13638. switch name {
  13639. case contact.FieldCreatedAt:
  13640. v, ok := value.(time.Time)
  13641. if !ok {
  13642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13643. }
  13644. m.SetCreatedAt(v)
  13645. return nil
  13646. case contact.FieldUpdatedAt:
  13647. v, ok := value.(time.Time)
  13648. if !ok {
  13649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13650. }
  13651. m.SetUpdatedAt(v)
  13652. return nil
  13653. case contact.FieldStatus:
  13654. v, ok := value.(uint8)
  13655. if !ok {
  13656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13657. }
  13658. m.SetStatus(v)
  13659. return nil
  13660. case contact.FieldDeletedAt:
  13661. v, ok := value.(time.Time)
  13662. if !ok {
  13663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13664. }
  13665. m.SetDeletedAt(v)
  13666. return nil
  13667. case contact.FieldWxWxid:
  13668. v, ok := value.(string)
  13669. if !ok {
  13670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13671. }
  13672. m.SetWxWxid(v)
  13673. return nil
  13674. case contact.FieldType:
  13675. v, ok := value.(int)
  13676. if !ok {
  13677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13678. }
  13679. m.SetType(v)
  13680. return nil
  13681. case contact.FieldWxid:
  13682. v, ok := value.(string)
  13683. if !ok {
  13684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13685. }
  13686. m.SetWxid(v)
  13687. return nil
  13688. case contact.FieldAccount:
  13689. v, ok := value.(string)
  13690. if !ok {
  13691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13692. }
  13693. m.SetAccount(v)
  13694. return nil
  13695. case contact.FieldNickname:
  13696. v, ok := value.(string)
  13697. if !ok {
  13698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13699. }
  13700. m.SetNickname(v)
  13701. return nil
  13702. case contact.FieldMarkname:
  13703. v, ok := value.(string)
  13704. if !ok {
  13705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13706. }
  13707. m.SetMarkname(v)
  13708. return nil
  13709. case contact.FieldHeadimg:
  13710. v, ok := value.(string)
  13711. if !ok {
  13712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13713. }
  13714. m.SetHeadimg(v)
  13715. return nil
  13716. case contact.FieldSex:
  13717. v, ok := value.(int)
  13718. if !ok {
  13719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13720. }
  13721. m.SetSex(v)
  13722. return nil
  13723. case contact.FieldStarrole:
  13724. v, ok := value.(string)
  13725. if !ok {
  13726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13727. }
  13728. m.SetStarrole(v)
  13729. return nil
  13730. case contact.FieldDontseeit:
  13731. v, ok := value.(int)
  13732. if !ok {
  13733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13734. }
  13735. m.SetDontseeit(v)
  13736. return nil
  13737. case contact.FieldDontseeme:
  13738. v, ok := value.(int)
  13739. if !ok {
  13740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13741. }
  13742. m.SetDontseeme(v)
  13743. return nil
  13744. case contact.FieldLag:
  13745. v, ok := value.(string)
  13746. if !ok {
  13747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13748. }
  13749. m.SetLag(v)
  13750. return nil
  13751. case contact.FieldGid:
  13752. v, ok := value.(string)
  13753. if !ok {
  13754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13755. }
  13756. m.SetGid(v)
  13757. return nil
  13758. case contact.FieldGname:
  13759. v, ok := value.(string)
  13760. if !ok {
  13761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13762. }
  13763. m.SetGname(v)
  13764. return nil
  13765. case contact.FieldV3:
  13766. v, ok := value.(string)
  13767. if !ok {
  13768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13769. }
  13770. m.SetV3(v)
  13771. return nil
  13772. case contact.FieldOrganizationID:
  13773. v, ok := value.(uint64)
  13774. if !ok {
  13775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13776. }
  13777. m.SetOrganizationID(v)
  13778. return nil
  13779. case contact.FieldCtype:
  13780. v, ok := value.(uint64)
  13781. if !ok {
  13782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13783. }
  13784. m.SetCtype(v)
  13785. return nil
  13786. case contact.FieldCage:
  13787. v, ok := value.(int)
  13788. if !ok {
  13789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13790. }
  13791. m.SetCage(v)
  13792. return nil
  13793. case contact.FieldCname:
  13794. v, ok := value.(string)
  13795. if !ok {
  13796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13797. }
  13798. m.SetCname(v)
  13799. return nil
  13800. case contact.FieldCarea:
  13801. v, ok := value.(string)
  13802. if !ok {
  13803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13804. }
  13805. m.SetCarea(v)
  13806. return nil
  13807. case contact.FieldCbirthday:
  13808. v, ok := value.(string)
  13809. if !ok {
  13810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13811. }
  13812. m.SetCbirthday(v)
  13813. return nil
  13814. case contact.FieldCbirtharea:
  13815. v, ok := value.(string)
  13816. if !ok {
  13817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13818. }
  13819. m.SetCbirtharea(v)
  13820. return nil
  13821. case contact.FieldCidcardNo:
  13822. v, ok := value.(string)
  13823. if !ok {
  13824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13825. }
  13826. m.SetCidcardNo(v)
  13827. return nil
  13828. case contact.FieldCtitle:
  13829. v, ok := value.(string)
  13830. if !ok {
  13831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13832. }
  13833. m.SetCtitle(v)
  13834. return nil
  13835. case contact.FieldCc:
  13836. v, ok := value.(string)
  13837. if !ok {
  13838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13839. }
  13840. m.SetCc(v)
  13841. return nil
  13842. case contact.FieldPhone:
  13843. v, ok := value.(string)
  13844. if !ok {
  13845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13846. }
  13847. m.SetPhone(v)
  13848. return nil
  13849. }
  13850. return fmt.Errorf("unknown Contact field %s", name)
  13851. }
  13852. // AddedFields returns all numeric fields that were incremented/decremented during
  13853. // this mutation.
  13854. func (m *ContactMutation) AddedFields() []string {
  13855. var fields []string
  13856. if m.addstatus != nil {
  13857. fields = append(fields, contact.FieldStatus)
  13858. }
  13859. if m.add_type != nil {
  13860. fields = append(fields, contact.FieldType)
  13861. }
  13862. if m.addsex != nil {
  13863. fields = append(fields, contact.FieldSex)
  13864. }
  13865. if m.adddontseeit != nil {
  13866. fields = append(fields, contact.FieldDontseeit)
  13867. }
  13868. if m.adddontseeme != nil {
  13869. fields = append(fields, contact.FieldDontseeme)
  13870. }
  13871. if m.addorganization_id != nil {
  13872. fields = append(fields, contact.FieldOrganizationID)
  13873. }
  13874. if m.addctype != nil {
  13875. fields = append(fields, contact.FieldCtype)
  13876. }
  13877. if m.addcage != nil {
  13878. fields = append(fields, contact.FieldCage)
  13879. }
  13880. return fields
  13881. }
  13882. // AddedField returns the numeric value that was incremented/decremented on a field
  13883. // with the given name. The second boolean return value indicates that this field
  13884. // was not set, or was not defined in the schema.
  13885. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  13886. switch name {
  13887. case contact.FieldStatus:
  13888. return m.AddedStatus()
  13889. case contact.FieldType:
  13890. return m.AddedType()
  13891. case contact.FieldSex:
  13892. return m.AddedSex()
  13893. case contact.FieldDontseeit:
  13894. return m.AddedDontseeit()
  13895. case contact.FieldDontseeme:
  13896. return m.AddedDontseeme()
  13897. case contact.FieldOrganizationID:
  13898. return m.AddedOrganizationID()
  13899. case contact.FieldCtype:
  13900. return m.AddedCtype()
  13901. case contact.FieldCage:
  13902. return m.AddedCage()
  13903. }
  13904. return nil, false
  13905. }
  13906. // AddField adds the value to the field with the given name. It returns an error if
  13907. // the field is not defined in the schema, or if the type mismatched the field
  13908. // type.
  13909. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  13910. switch name {
  13911. case contact.FieldStatus:
  13912. v, ok := value.(int8)
  13913. if !ok {
  13914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13915. }
  13916. m.AddStatus(v)
  13917. return nil
  13918. case contact.FieldType:
  13919. v, ok := value.(int)
  13920. if !ok {
  13921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13922. }
  13923. m.AddType(v)
  13924. return nil
  13925. case contact.FieldSex:
  13926. v, ok := value.(int)
  13927. if !ok {
  13928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13929. }
  13930. m.AddSex(v)
  13931. return nil
  13932. case contact.FieldDontseeit:
  13933. v, ok := value.(int)
  13934. if !ok {
  13935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13936. }
  13937. m.AddDontseeit(v)
  13938. return nil
  13939. case contact.FieldDontseeme:
  13940. v, ok := value.(int)
  13941. if !ok {
  13942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13943. }
  13944. m.AddDontseeme(v)
  13945. return nil
  13946. case contact.FieldOrganizationID:
  13947. v, ok := value.(int64)
  13948. if !ok {
  13949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13950. }
  13951. m.AddOrganizationID(v)
  13952. return nil
  13953. case contact.FieldCtype:
  13954. v, ok := value.(int64)
  13955. if !ok {
  13956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13957. }
  13958. m.AddCtype(v)
  13959. return nil
  13960. case contact.FieldCage:
  13961. v, ok := value.(int)
  13962. if !ok {
  13963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13964. }
  13965. m.AddCage(v)
  13966. return nil
  13967. }
  13968. return fmt.Errorf("unknown Contact numeric field %s", name)
  13969. }
  13970. // ClearedFields returns all nullable fields that were cleared during this
  13971. // mutation.
  13972. func (m *ContactMutation) ClearedFields() []string {
  13973. var fields []string
  13974. if m.FieldCleared(contact.FieldStatus) {
  13975. fields = append(fields, contact.FieldStatus)
  13976. }
  13977. if m.FieldCleared(contact.FieldDeletedAt) {
  13978. fields = append(fields, contact.FieldDeletedAt)
  13979. }
  13980. if m.FieldCleared(contact.FieldType) {
  13981. fields = append(fields, contact.FieldType)
  13982. }
  13983. if m.FieldCleared(contact.FieldOrganizationID) {
  13984. fields = append(fields, contact.FieldOrganizationID)
  13985. }
  13986. return fields
  13987. }
  13988. // FieldCleared returns a boolean indicating if a field with the given name was
  13989. // cleared in this mutation.
  13990. func (m *ContactMutation) FieldCleared(name string) bool {
  13991. _, ok := m.clearedFields[name]
  13992. return ok
  13993. }
  13994. // ClearField clears the value of the field with the given name. It returns an
  13995. // error if the field is not defined in the schema.
  13996. func (m *ContactMutation) ClearField(name string) error {
  13997. switch name {
  13998. case contact.FieldStatus:
  13999. m.ClearStatus()
  14000. return nil
  14001. case contact.FieldDeletedAt:
  14002. m.ClearDeletedAt()
  14003. return nil
  14004. case contact.FieldType:
  14005. m.ClearType()
  14006. return nil
  14007. case contact.FieldOrganizationID:
  14008. m.ClearOrganizationID()
  14009. return nil
  14010. }
  14011. return fmt.Errorf("unknown Contact nullable field %s", name)
  14012. }
  14013. // ResetField resets all changes in the mutation for the field with the given name.
  14014. // It returns an error if the field is not defined in the schema.
  14015. func (m *ContactMutation) ResetField(name string) error {
  14016. switch name {
  14017. case contact.FieldCreatedAt:
  14018. m.ResetCreatedAt()
  14019. return nil
  14020. case contact.FieldUpdatedAt:
  14021. m.ResetUpdatedAt()
  14022. return nil
  14023. case contact.FieldStatus:
  14024. m.ResetStatus()
  14025. return nil
  14026. case contact.FieldDeletedAt:
  14027. m.ResetDeletedAt()
  14028. return nil
  14029. case contact.FieldWxWxid:
  14030. m.ResetWxWxid()
  14031. return nil
  14032. case contact.FieldType:
  14033. m.ResetType()
  14034. return nil
  14035. case contact.FieldWxid:
  14036. m.ResetWxid()
  14037. return nil
  14038. case contact.FieldAccount:
  14039. m.ResetAccount()
  14040. return nil
  14041. case contact.FieldNickname:
  14042. m.ResetNickname()
  14043. return nil
  14044. case contact.FieldMarkname:
  14045. m.ResetMarkname()
  14046. return nil
  14047. case contact.FieldHeadimg:
  14048. m.ResetHeadimg()
  14049. return nil
  14050. case contact.FieldSex:
  14051. m.ResetSex()
  14052. return nil
  14053. case contact.FieldStarrole:
  14054. m.ResetStarrole()
  14055. return nil
  14056. case contact.FieldDontseeit:
  14057. m.ResetDontseeit()
  14058. return nil
  14059. case contact.FieldDontseeme:
  14060. m.ResetDontseeme()
  14061. return nil
  14062. case contact.FieldLag:
  14063. m.ResetLag()
  14064. return nil
  14065. case contact.FieldGid:
  14066. m.ResetGid()
  14067. return nil
  14068. case contact.FieldGname:
  14069. m.ResetGname()
  14070. return nil
  14071. case contact.FieldV3:
  14072. m.ResetV3()
  14073. return nil
  14074. case contact.FieldOrganizationID:
  14075. m.ResetOrganizationID()
  14076. return nil
  14077. case contact.FieldCtype:
  14078. m.ResetCtype()
  14079. return nil
  14080. case contact.FieldCage:
  14081. m.ResetCage()
  14082. return nil
  14083. case contact.FieldCname:
  14084. m.ResetCname()
  14085. return nil
  14086. case contact.FieldCarea:
  14087. m.ResetCarea()
  14088. return nil
  14089. case contact.FieldCbirthday:
  14090. m.ResetCbirthday()
  14091. return nil
  14092. case contact.FieldCbirtharea:
  14093. m.ResetCbirtharea()
  14094. return nil
  14095. case contact.FieldCidcardNo:
  14096. m.ResetCidcardNo()
  14097. return nil
  14098. case contact.FieldCtitle:
  14099. m.ResetCtitle()
  14100. return nil
  14101. case contact.FieldCc:
  14102. m.ResetCc()
  14103. return nil
  14104. case contact.FieldPhone:
  14105. m.ResetPhone()
  14106. return nil
  14107. }
  14108. return fmt.Errorf("unknown Contact field %s", name)
  14109. }
  14110. // AddedEdges returns all edge names that were set/added in this mutation.
  14111. func (m *ContactMutation) AddedEdges() []string {
  14112. edges := make([]string, 0, 3)
  14113. if m.contact_relationships != nil {
  14114. edges = append(edges, contact.EdgeContactRelationships)
  14115. }
  14116. if m.contact_fields != nil {
  14117. edges = append(edges, contact.EdgeContactFields)
  14118. }
  14119. if m.contact_messages != nil {
  14120. edges = append(edges, contact.EdgeContactMessages)
  14121. }
  14122. return edges
  14123. }
  14124. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14125. // name in this mutation.
  14126. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  14127. switch name {
  14128. case contact.EdgeContactRelationships:
  14129. ids := make([]ent.Value, 0, len(m.contact_relationships))
  14130. for id := range m.contact_relationships {
  14131. ids = append(ids, id)
  14132. }
  14133. return ids
  14134. case contact.EdgeContactFields:
  14135. ids := make([]ent.Value, 0, len(m.contact_fields))
  14136. for id := range m.contact_fields {
  14137. ids = append(ids, id)
  14138. }
  14139. return ids
  14140. case contact.EdgeContactMessages:
  14141. ids := make([]ent.Value, 0, len(m.contact_messages))
  14142. for id := range m.contact_messages {
  14143. ids = append(ids, id)
  14144. }
  14145. return ids
  14146. }
  14147. return nil
  14148. }
  14149. // RemovedEdges returns all edge names that were removed in this mutation.
  14150. func (m *ContactMutation) RemovedEdges() []string {
  14151. edges := make([]string, 0, 3)
  14152. if m.removedcontact_relationships != nil {
  14153. edges = append(edges, contact.EdgeContactRelationships)
  14154. }
  14155. if m.removedcontact_fields != nil {
  14156. edges = append(edges, contact.EdgeContactFields)
  14157. }
  14158. if m.removedcontact_messages != nil {
  14159. edges = append(edges, contact.EdgeContactMessages)
  14160. }
  14161. return edges
  14162. }
  14163. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14164. // the given name in this mutation.
  14165. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  14166. switch name {
  14167. case contact.EdgeContactRelationships:
  14168. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  14169. for id := range m.removedcontact_relationships {
  14170. ids = append(ids, id)
  14171. }
  14172. return ids
  14173. case contact.EdgeContactFields:
  14174. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  14175. for id := range m.removedcontact_fields {
  14176. ids = append(ids, id)
  14177. }
  14178. return ids
  14179. case contact.EdgeContactMessages:
  14180. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  14181. for id := range m.removedcontact_messages {
  14182. ids = append(ids, id)
  14183. }
  14184. return ids
  14185. }
  14186. return nil
  14187. }
  14188. // ClearedEdges returns all edge names that were cleared in this mutation.
  14189. func (m *ContactMutation) ClearedEdges() []string {
  14190. edges := make([]string, 0, 3)
  14191. if m.clearedcontact_relationships {
  14192. edges = append(edges, contact.EdgeContactRelationships)
  14193. }
  14194. if m.clearedcontact_fields {
  14195. edges = append(edges, contact.EdgeContactFields)
  14196. }
  14197. if m.clearedcontact_messages {
  14198. edges = append(edges, contact.EdgeContactMessages)
  14199. }
  14200. return edges
  14201. }
  14202. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14203. // was cleared in this mutation.
  14204. func (m *ContactMutation) EdgeCleared(name string) bool {
  14205. switch name {
  14206. case contact.EdgeContactRelationships:
  14207. return m.clearedcontact_relationships
  14208. case contact.EdgeContactFields:
  14209. return m.clearedcontact_fields
  14210. case contact.EdgeContactMessages:
  14211. return m.clearedcontact_messages
  14212. }
  14213. return false
  14214. }
  14215. // ClearEdge clears the value of the edge with the given name. It returns an error
  14216. // if that edge is not defined in the schema.
  14217. func (m *ContactMutation) ClearEdge(name string) error {
  14218. switch name {
  14219. }
  14220. return fmt.Errorf("unknown Contact unique edge %s", name)
  14221. }
  14222. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14223. // It returns an error if the edge is not defined in the schema.
  14224. func (m *ContactMutation) ResetEdge(name string) error {
  14225. switch name {
  14226. case contact.EdgeContactRelationships:
  14227. m.ResetContactRelationships()
  14228. return nil
  14229. case contact.EdgeContactFields:
  14230. m.ResetContactFields()
  14231. return nil
  14232. case contact.EdgeContactMessages:
  14233. m.ResetContactMessages()
  14234. return nil
  14235. }
  14236. return fmt.Errorf("unknown Contact edge %s", name)
  14237. }
  14238. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  14239. type ContactFieldMutation struct {
  14240. config
  14241. op Op
  14242. typ string
  14243. id *uint64
  14244. created_at *time.Time
  14245. updated_at *time.Time
  14246. status *uint8
  14247. addstatus *int8
  14248. deleted_at *time.Time
  14249. form_id *string
  14250. value *[]string
  14251. appendvalue []string
  14252. clearedFields map[string]struct{}
  14253. field_contact *uint64
  14254. clearedfield_contact bool
  14255. done bool
  14256. oldValue func(context.Context) (*ContactField, error)
  14257. predicates []predicate.ContactField
  14258. }
  14259. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  14260. // contactfieldOption allows management of the mutation configuration using functional options.
  14261. type contactfieldOption func(*ContactFieldMutation)
  14262. // newContactFieldMutation creates new mutation for the ContactField entity.
  14263. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  14264. m := &ContactFieldMutation{
  14265. config: c,
  14266. op: op,
  14267. typ: TypeContactField,
  14268. clearedFields: make(map[string]struct{}),
  14269. }
  14270. for _, opt := range opts {
  14271. opt(m)
  14272. }
  14273. return m
  14274. }
  14275. // withContactFieldID sets the ID field of the mutation.
  14276. func withContactFieldID(id uint64) contactfieldOption {
  14277. return func(m *ContactFieldMutation) {
  14278. var (
  14279. err error
  14280. once sync.Once
  14281. value *ContactField
  14282. )
  14283. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  14284. once.Do(func() {
  14285. if m.done {
  14286. err = errors.New("querying old values post mutation is not allowed")
  14287. } else {
  14288. value, err = m.Client().ContactField.Get(ctx, id)
  14289. }
  14290. })
  14291. return value, err
  14292. }
  14293. m.id = &id
  14294. }
  14295. }
  14296. // withContactField sets the old ContactField of the mutation.
  14297. func withContactField(node *ContactField) contactfieldOption {
  14298. return func(m *ContactFieldMutation) {
  14299. m.oldValue = func(context.Context) (*ContactField, error) {
  14300. return node, nil
  14301. }
  14302. m.id = &node.ID
  14303. }
  14304. }
  14305. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14306. // executed in a transaction (ent.Tx), a transactional client is returned.
  14307. func (m ContactFieldMutation) Client() *Client {
  14308. client := &Client{config: m.config}
  14309. client.init()
  14310. return client
  14311. }
  14312. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14313. // it returns an error otherwise.
  14314. func (m ContactFieldMutation) Tx() (*Tx, error) {
  14315. if _, ok := m.driver.(*txDriver); !ok {
  14316. return nil, errors.New("ent: mutation is not running in a transaction")
  14317. }
  14318. tx := &Tx{config: m.config}
  14319. tx.init()
  14320. return tx, nil
  14321. }
  14322. // SetID sets the value of the id field. Note that this
  14323. // operation is only accepted on creation of ContactField entities.
  14324. func (m *ContactFieldMutation) SetID(id uint64) {
  14325. m.id = &id
  14326. }
  14327. // ID returns the ID value in the mutation. Note that the ID is only available
  14328. // if it was provided to the builder or after it was returned from the database.
  14329. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  14330. if m.id == nil {
  14331. return
  14332. }
  14333. return *m.id, true
  14334. }
  14335. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14336. // That means, if the mutation is applied within a transaction with an isolation level such
  14337. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14338. // or updated by the mutation.
  14339. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  14340. switch {
  14341. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14342. id, exists := m.ID()
  14343. if exists {
  14344. return []uint64{id}, nil
  14345. }
  14346. fallthrough
  14347. case m.op.Is(OpUpdate | OpDelete):
  14348. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  14349. default:
  14350. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14351. }
  14352. }
  14353. // SetCreatedAt sets the "created_at" field.
  14354. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  14355. m.created_at = &t
  14356. }
  14357. // CreatedAt returns the value of the "created_at" field in the mutation.
  14358. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  14359. v := m.created_at
  14360. if v == nil {
  14361. return
  14362. }
  14363. return *v, true
  14364. }
  14365. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  14366. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14368. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14369. if !m.op.Is(OpUpdateOne) {
  14370. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14371. }
  14372. if m.id == nil || m.oldValue == nil {
  14373. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14374. }
  14375. oldValue, err := m.oldValue(ctx)
  14376. if err != nil {
  14377. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14378. }
  14379. return oldValue.CreatedAt, nil
  14380. }
  14381. // ResetCreatedAt resets all changes to the "created_at" field.
  14382. func (m *ContactFieldMutation) ResetCreatedAt() {
  14383. m.created_at = nil
  14384. }
  14385. // SetUpdatedAt sets the "updated_at" field.
  14386. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  14387. m.updated_at = &t
  14388. }
  14389. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14390. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  14391. v := m.updated_at
  14392. if v == nil {
  14393. return
  14394. }
  14395. return *v, true
  14396. }
  14397. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  14398. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14400. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14401. if !m.op.Is(OpUpdateOne) {
  14402. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14403. }
  14404. if m.id == nil || m.oldValue == nil {
  14405. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14406. }
  14407. oldValue, err := m.oldValue(ctx)
  14408. if err != nil {
  14409. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14410. }
  14411. return oldValue.UpdatedAt, nil
  14412. }
  14413. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14414. func (m *ContactFieldMutation) ResetUpdatedAt() {
  14415. m.updated_at = nil
  14416. }
  14417. // SetStatus sets the "status" field.
  14418. func (m *ContactFieldMutation) SetStatus(u uint8) {
  14419. m.status = &u
  14420. m.addstatus = nil
  14421. }
  14422. // Status returns the value of the "status" field in the mutation.
  14423. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  14424. v := m.status
  14425. if v == nil {
  14426. return
  14427. }
  14428. return *v, true
  14429. }
  14430. // OldStatus returns the old "status" field's value of the ContactField entity.
  14431. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14433. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14434. if !m.op.Is(OpUpdateOne) {
  14435. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14436. }
  14437. if m.id == nil || m.oldValue == nil {
  14438. return v, errors.New("OldStatus requires an ID field in the mutation")
  14439. }
  14440. oldValue, err := m.oldValue(ctx)
  14441. if err != nil {
  14442. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14443. }
  14444. return oldValue.Status, nil
  14445. }
  14446. // AddStatus adds u to the "status" field.
  14447. func (m *ContactFieldMutation) AddStatus(u int8) {
  14448. if m.addstatus != nil {
  14449. *m.addstatus += u
  14450. } else {
  14451. m.addstatus = &u
  14452. }
  14453. }
  14454. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14455. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  14456. v := m.addstatus
  14457. if v == nil {
  14458. return
  14459. }
  14460. return *v, true
  14461. }
  14462. // ClearStatus clears the value of the "status" field.
  14463. func (m *ContactFieldMutation) ClearStatus() {
  14464. m.status = nil
  14465. m.addstatus = nil
  14466. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  14467. }
  14468. // StatusCleared returns if the "status" field was cleared in this mutation.
  14469. func (m *ContactFieldMutation) StatusCleared() bool {
  14470. _, ok := m.clearedFields[contactfield.FieldStatus]
  14471. return ok
  14472. }
  14473. // ResetStatus resets all changes to the "status" field.
  14474. func (m *ContactFieldMutation) ResetStatus() {
  14475. m.status = nil
  14476. m.addstatus = nil
  14477. delete(m.clearedFields, contactfield.FieldStatus)
  14478. }
  14479. // SetDeletedAt sets the "deleted_at" field.
  14480. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  14481. m.deleted_at = &t
  14482. }
  14483. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14484. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  14485. v := m.deleted_at
  14486. if v == nil {
  14487. return
  14488. }
  14489. return *v, true
  14490. }
  14491. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  14492. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14494. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14495. if !m.op.Is(OpUpdateOne) {
  14496. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14497. }
  14498. if m.id == nil || m.oldValue == nil {
  14499. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14500. }
  14501. oldValue, err := m.oldValue(ctx)
  14502. if err != nil {
  14503. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14504. }
  14505. return oldValue.DeletedAt, nil
  14506. }
  14507. // ClearDeletedAt clears the value of the "deleted_at" field.
  14508. func (m *ContactFieldMutation) ClearDeletedAt() {
  14509. m.deleted_at = nil
  14510. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  14511. }
  14512. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14513. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  14514. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  14515. return ok
  14516. }
  14517. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14518. func (m *ContactFieldMutation) ResetDeletedAt() {
  14519. m.deleted_at = nil
  14520. delete(m.clearedFields, contactfield.FieldDeletedAt)
  14521. }
  14522. // SetContactID sets the "contact_id" field.
  14523. func (m *ContactFieldMutation) SetContactID(u uint64) {
  14524. m.field_contact = &u
  14525. }
  14526. // ContactID returns the value of the "contact_id" field in the mutation.
  14527. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  14528. v := m.field_contact
  14529. if v == nil {
  14530. return
  14531. }
  14532. return *v, true
  14533. }
  14534. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  14535. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14537. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14538. if !m.op.Is(OpUpdateOne) {
  14539. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14540. }
  14541. if m.id == nil || m.oldValue == nil {
  14542. return v, errors.New("OldContactID requires an ID field in the mutation")
  14543. }
  14544. oldValue, err := m.oldValue(ctx)
  14545. if err != nil {
  14546. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14547. }
  14548. return oldValue.ContactID, nil
  14549. }
  14550. // ResetContactID resets all changes to the "contact_id" field.
  14551. func (m *ContactFieldMutation) ResetContactID() {
  14552. m.field_contact = nil
  14553. }
  14554. // SetFormID sets the "form_id" field.
  14555. func (m *ContactFieldMutation) SetFormID(s string) {
  14556. m.form_id = &s
  14557. }
  14558. // FormID returns the value of the "form_id" field in the mutation.
  14559. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  14560. v := m.form_id
  14561. if v == nil {
  14562. return
  14563. }
  14564. return *v, true
  14565. }
  14566. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  14567. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14569. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  14570. if !m.op.Is(OpUpdateOne) {
  14571. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  14572. }
  14573. if m.id == nil || m.oldValue == nil {
  14574. return v, errors.New("OldFormID requires an ID field in the mutation")
  14575. }
  14576. oldValue, err := m.oldValue(ctx)
  14577. if err != nil {
  14578. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  14579. }
  14580. return oldValue.FormID, nil
  14581. }
  14582. // ResetFormID resets all changes to the "form_id" field.
  14583. func (m *ContactFieldMutation) ResetFormID() {
  14584. m.form_id = nil
  14585. }
  14586. // SetValue sets the "value" field.
  14587. func (m *ContactFieldMutation) SetValue(s []string) {
  14588. m.value = &s
  14589. m.appendvalue = nil
  14590. }
  14591. // Value returns the value of the "value" field in the mutation.
  14592. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  14593. v := m.value
  14594. if v == nil {
  14595. return
  14596. }
  14597. return *v, true
  14598. }
  14599. // OldValue returns the old "value" field's value of the ContactField entity.
  14600. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14602. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  14603. if !m.op.Is(OpUpdateOne) {
  14604. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  14605. }
  14606. if m.id == nil || m.oldValue == nil {
  14607. return v, errors.New("OldValue requires an ID field in the mutation")
  14608. }
  14609. oldValue, err := m.oldValue(ctx)
  14610. if err != nil {
  14611. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  14612. }
  14613. return oldValue.Value, nil
  14614. }
  14615. // AppendValue adds s to the "value" field.
  14616. func (m *ContactFieldMutation) AppendValue(s []string) {
  14617. m.appendvalue = append(m.appendvalue, s...)
  14618. }
  14619. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  14620. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  14621. if len(m.appendvalue) == 0 {
  14622. return nil, false
  14623. }
  14624. return m.appendvalue, true
  14625. }
  14626. // ResetValue resets all changes to the "value" field.
  14627. func (m *ContactFieldMutation) ResetValue() {
  14628. m.value = nil
  14629. m.appendvalue = nil
  14630. }
  14631. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  14632. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  14633. m.field_contact = &id
  14634. }
  14635. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  14636. func (m *ContactFieldMutation) ClearFieldContact() {
  14637. m.clearedfield_contact = true
  14638. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  14639. }
  14640. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  14641. func (m *ContactFieldMutation) FieldContactCleared() bool {
  14642. return m.clearedfield_contact
  14643. }
  14644. // FieldContactID returns the "field_contact" edge ID in the mutation.
  14645. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  14646. if m.field_contact != nil {
  14647. return *m.field_contact, true
  14648. }
  14649. return
  14650. }
  14651. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  14652. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14653. // FieldContactID instead. It exists only for internal usage by the builders.
  14654. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  14655. if id := m.field_contact; id != nil {
  14656. ids = append(ids, *id)
  14657. }
  14658. return
  14659. }
  14660. // ResetFieldContact resets all changes to the "field_contact" edge.
  14661. func (m *ContactFieldMutation) ResetFieldContact() {
  14662. m.field_contact = nil
  14663. m.clearedfield_contact = false
  14664. }
  14665. // Where appends a list predicates to the ContactFieldMutation builder.
  14666. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  14667. m.predicates = append(m.predicates, ps...)
  14668. }
  14669. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  14670. // users can use type-assertion to append predicates that do not depend on any generated package.
  14671. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  14672. p := make([]predicate.ContactField, len(ps))
  14673. for i := range ps {
  14674. p[i] = ps[i]
  14675. }
  14676. m.Where(p...)
  14677. }
  14678. // Op returns the operation name.
  14679. func (m *ContactFieldMutation) Op() Op {
  14680. return m.op
  14681. }
  14682. // SetOp allows setting the mutation operation.
  14683. func (m *ContactFieldMutation) SetOp(op Op) {
  14684. m.op = op
  14685. }
  14686. // Type returns the node type of this mutation (ContactField).
  14687. func (m *ContactFieldMutation) Type() string {
  14688. return m.typ
  14689. }
  14690. // Fields returns all fields that were changed during this mutation. Note that in
  14691. // order to get all numeric fields that were incremented/decremented, call
  14692. // AddedFields().
  14693. func (m *ContactFieldMutation) Fields() []string {
  14694. fields := make([]string, 0, 7)
  14695. if m.created_at != nil {
  14696. fields = append(fields, contactfield.FieldCreatedAt)
  14697. }
  14698. if m.updated_at != nil {
  14699. fields = append(fields, contactfield.FieldUpdatedAt)
  14700. }
  14701. if m.status != nil {
  14702. fields = append(fields, contactfield.FieldStatus)
  14703. }
  14704. if m.deleted_at != nil {
  14705. fields = append(fields, contactfield.FieldDeletedAt)
  14706. }
  14707. if m.field_contact != nil {
  14708. fields = append(fields, contactfield.FieldContactID)
  14709. }
  14710. if m.form_id != nil {
  14711. fields = append(fields, contactfield.FieldFormID)
  14712. }
  14713. if m.value != nil {
  14714. fields = append(fields, contactfield.FieldValue)
  14715. }
  14716. return fields
  14717. }
  14718. // Field returns the value of a field with the given name. The second boolean
  14719. // return value indicates that this field was not set, or was not defined in the
  14720. // schema.
  14721. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  14722. switch name {
  14723. case contactfield.FieldCreatedAt:
  14724. return m.CreatedAt()
  14725. case contactfield.FieldUpdatedAt:
  14726. return m.UpdatedAt()
  14727. case contactfield.FieldStatus:
  14728. return m.Status()
  14729. case contactfield.FieldDeletedAt:
  14730. return m.DeletedAt()
  14731. case contactfield.FieldContactID:
  14732. return m.ContactID()
  14733. case contactfield.FieldFormID:
  14734. return m.FormID()
  14735. case contactfield.FieldValue:
  14736. return m.Value()
  14737. }
  14738. return nil, false
  14739. }
  14740. // OldField returns the old value of the field from the database. An error is
  14741. // returned if the mutation operation is not UpdateOne, or the query to the
  14742. // database failed.
  14743. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14744. switch name {
  14745. case contactfield.FieldCreatedAt:
  14746. return m.OldCreatedAt(ctx)
  14747. case contactfield.FieldUpdatedAt:
  14748. return m.OldUpdatedAt(ctx)
  14749. case contactfield.FieldStatus:
  14750. return m.OldStatus(ctx)
  14751. case contactfield.FieldDeletedAt:
  14752. return m.OldDeletedAt(ctx)
  14753. case contactfield.FieldContactID:
  14754. return m.OldContactID(ctx)
  14755. case contactfield.FieldFormID:
  14756. return m.OldFormID(ctx)
  14757. case contactfield.FieldValue:
  14758. return m.OldValue(ctx)
  14759. }
  14760. return nil, fmt.Errorf("unknown ContactField field %s", name)
  14761. }
  14762. // SetField sets the value of a field with the given name. It returns an error if
  14763. // the field is not defined in the schema, or if the type mismatched the field
  14764. // type.
  14765. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  14766. switch name {
  14767. case contactfield.FieldCreatedAt:
  14768. v, ok := value.(time.Time)
  14769. if !ok {
  14770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14771. }
  14772. m.SetCreatedAt(v)
  14773. return nil
  14774. case contactfield.FieldUpdatedAt:
  14775. v, ok := value.(time.Time)
  14776. if !ok {
  14777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14778. }
  14779. m.SetUpdatedAt(v)
  14780. return nil
  14781. case contactfield.FieldStatus:
  14782. v, ok := value.(uint8)
  14783. if !ok {
  14784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14785. }
  14786. m.SetStatus(v)
  14787. return nil
  14788. case contactfield.FieldDeletedAt:
  14789. v, ok := value.(time.Time)
  14790. if !ok {
  14791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14792. }
  14793. m.SetDeletedAt(v)
  14794. return nil
  14795. case contactfield.FieldContactID:
  14796. v, ok := value.(uint64)
  14797. if !ok {
  14798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14799. }
  14800. m.SetContactID(v)
  14801. return nil
  14802. case contactfield.FieldFormID:
  14803. v, ok := value.(string)
  14804. if !ok {
  14805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14806. }
  14807. m.SetFormID(v)
  14808. return nil
  14809. case contactfield.FieldValue:
  14810. v, ok := value.([]string)
  14811. if !ok {
  14812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14813. }
  14814. m.SetValue(v)
  14815. return nil
  14816. }
  14817. return fmt.Errorf("unknown ContactField field %s", name)
  14818. }
  14819. // AddedFields returns all numeric fields that were incremented/decremented during
  14820. // this mutation.
  14821. func (m *ContactFieldMutation) AddedFields() []string {
  14822. var fields []string
  14823. if m.addstatus != nil {
  14824. fields = append(fields, contactfield.FieldStatus)
  14825. }
  14826. return fields
  14827. }
  14828. // AddedField returns the numeric value that was incremented/decremented on a field
  14829. // with the given name. The second boolean return value indicates that this field
  14830. // was not set, or was not defined in the schema.
  14831. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  14832. switch name {
  14833. case contactfield.FieldStatus:
  14834. return m.AddedStatus()
  14835. }
  14836. return nil, false
  14837. }
  14838. // AddField adds the value to the field with the given name. It returns an error if
  14839. // the field is not defined in the schema, or if the type mismatched the field
  14840. // type.
  14841. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  14842. switch name {
  14843. case contactfield.FieldStatus:
  14844. v, ok := value.(int8)
  14845. if !ok {
  14846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14847. }
  14848. m.AddStatus(v)
  14849. return nil
  14850. }
  14851. return fmt.Errorf("unknown ContactField numeric field %s", name)
  14852. }
  14853. // ClearedFields returns all nullable fields that were cleared during this
  14854. // mutation.
  14855. func (m *ContactFieldMutation) ClearedFields() []string {
  14856. var fields []string
  14857. if m.FieldCleared(contactfield.FieldStatus) {
  14858. fields = append(fields, contactfield.FieldStatus)
  14859. }
  14860. if m.FieldCleared(contactfield.FieldDeletedAt) {
  14861. fields = append(fields, contactfield.FieldDeletedAt)
  14862. }
  14863. return fields
  14864. }
  14865. // FieldCleared returns a boolean indicating if a field with the given name was
  14866. // cleared in this mutation.
  14867. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  14868. _, ok := m.clearedFields[name]
  14869. return ok
  14870. }
  14871. // ClearField clears the value of the field with the given name. It returns an
  14872. // error if the field is not defined in the schema.
  14873. func (m *ContactFieldMutation) ClearField(name string) error {
  14874. switch name {
  14875. case contactfield.FieldStatus:
  14876. m.ClearStatus()
  14877. return nil
  14878. case contactfield.FieldDeletedAt:
  14879. m.ClearDeletedAt()
  14880. return nil
  14881. }
  14882. return fmt.Errorf("unknown ContactField nullable field %s", name)
  14883. }
  14884. // ResetField resets all changes in the mutation for the field with the given name.
  14885. // It returns an error if the field is not defined in the schema.
  14886. func (m *ContactFieldMutation) ResetField(name string) error {
  14887. switch name {
  14888. case contactfield.FieldCreatedAt:
  14889. m.ResetCreatedAt()
  14890. return nil
  14891. case contactfield.FieldUpdatedAt:
  14892. m.ResetUpdatedAt()
  14893. return nil
  14894. case contactfield.FieldStatus:
  14895. m.ResetStatus()
  14896. return nil
  14897. case contactfield.FieldDeletedAt:
  14898. m.ResetDeletedAt()
  14899. return nil
  14900. case contactfield.FieldContactID:
  14901. m.ResetContactID()
  14902. return nil
  14903. case contactfield.FieldFormID:
  14904. m.ResetFormID()
  14905. return nil
  14906. case contactfield.FieldValue:
  14907. m.ResetValue()
  14908. return nil
  14909. }
  14910. return fmt.Errorf("unknown ContactField field %s", name)
  14911. }
  14912. // AddedEdges returns all edge names that were set/added in this mutation.
  14913. func (m *ContactFieldMutation) AddedEdges() []string {
  14914. edges := make([]string, 0, 1)
  14915. if m.field_contact != nil {
  14916. edges = append(edges, contactfield.EdgeFieldContact)
  14917. }
  14918. return edges
  14919. }
  14920. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14921. // name in this mutation.
  14922. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  14923. switch name {
  14924. case contactfield.EdgeFieldContact:
  14925. if id := m.field_contact; id != nil {
  14926. return []ent.Value{*id}
  14927. }
  14928. }
  14929. return nil
  14930. }
  14931. // RemovedEdges returns all edge names that were removed in this mutation.
  14932. func (m *ContactFieldMutation) RemovedEdges() []string {
  14933. edges := make([]string, 0, 1)
  14934. return edges
  14935. }
  14936. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14937. // the given name in this mutation.
  14938. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  14939. return nil
  14940. }
  14941. // ClearedEdges returns all edge names that were cleared in this mutation.
  14942. func (m *ContactFieldMutation) ClearedEdges() []string {
  14943. edges := make([]string, 0, 1)
  14944. if m.clearedfield_contact {
  14945. edges = append(edges, contactfield.EdgeFieldContact)
  14946. }
  14947. return edges
  14948. }
  14949. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14950. // was cleared in this mutation.
  14951. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  14952. switch name {
  14953. case contactfield.EdgeFieldContact:
  14954. return m.clearedfield_contact
  14955. }
  14956. return false
  14957. }
  14958. // ClearEdge clears the value of the edge with the given name. It returns an error
  14959. // if that edge is not defined in the schema.
  14960. func (m *ContactFieldMutation) ClearEdge(name string) error {
  14961. switch name {
  14962. case contactfield.EdgeFieldContact:
  14963. m.ClearFieldContact()
  14964. return nil
  14965. }
  14966. return fmt.Errorf("unknown ContactField unique edge %s", name)
  14967. }
  14968. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14969. // It returns an error if the edge is not defined in the schema.
  14970. func (m *ContactFieldMutation) ResetEdge(name string) error {
  14971. switch name {
  14972. case contactfield.EdgeFieldContact:
  14973. m.ResetFieldContact()
  14974. return nil
  14975. }
  14976. return fmt.Errorf("unknown ContactField edge %s", name)
  14977. }
  14978. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  14979. type ContactFieldTemplateMutation struct {
  14980. config
  14981. op Op
  14982. typ string
  14983. id *uint64
  14984. created_at *time.Time
  14985. updated_at *time.Time
  14986. status *uint8
  14987. addstatus *int8
  14988. deleted_at *time.Time
  14989. organization_id *uint64
  14990. addorganization_id *int64
  14991. template *[]custom_types.ContactFieldTemplate
  14992. appendtemplate []custom_types.ContactFieldTemplate
  14993. clearedFields map[string]struct{}
  14994. done bool
  14995. oldValue func(context.Context) (*ContactFieldTemplate, error)
  14996. predicates []predicate.ContactFieldTemplate
  14997. }
  14998. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  14999. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  15000. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  15001. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  15002. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  15003. m := &ContactFieldTemplateMutation{
  15004. config: c,
  15005. op: op,
  15006. typ: TypeContactFieldTemplate,
  15007. clearedFields: make(map[string]struct{}),
  15008. }
  15009. for _, opt := range opts {
  15010. opt(m)
  15011. }
  15012. return m
  15013. }
  15014. // withContactFieldTemplateID sets the ID field of the mutation.
  15015. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  15016. return func(m *ContactFieldTemplateMutation) {
  15017. var (
  15018. err error
  15019. once sync.Once
  15020. value *ContactFieldTemplate
  15021. )
  15022. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  15023. once.Do(func() {
  15024. if m.done {
  15025. err = errors.New("querying old values post mutation is not allowed")
  15026. } else {
  15027. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  15028. }
  15029. })
  15030. return value, err
  15031. }
  15032. m.id = &id
  15033. }
  15034. }
  15035. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  15036. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  15037. return func(m *ContactFieldTemplateMutation) {
  15038. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  15039. return node, nil
  15040. }
  15041. m.id = &node.ID
  15042. }
  15043. }
  15044. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15045. // executed in a transaction (ent.Tx), a transactional client is returned.
  15046. func (m ContactFieldTemplateMutation) Client() *Client {
  15047. client := &Client{config: m.config}
  15048. client.init()
  15049. return client
  15050. }
  15051. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15052. // it returns an error otherwise.
  15053. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  15054. if _, ok := m.driver.(*txDriver); !ok {
  15055. return nil, errors.New("ent: mutation is not running in a transaction")
  15056. }
  15057. tx := &Tx{config: m.config}
  15058. tx.init()
  15059. return tx, nil
  15060. }
  15061. // SetID sets the value of the id field. Note that this
  15062. // operation is only accepted on creation of ContactFieldTemplate entities.
  15063. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  15064. m.id = &id
  15065. }
  15066. // ID returns the ID value in the mutation. Note that the ID is only available
  15067. // if it was provided to the builder or after it was returned from the database.
  15068. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  15069. if m.id == nil {
  15070. return
  15071. }
  15072. return *m.id, true
  15073. }
  15074. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15075. // That means, if the mutation is applied within a transaction with an isolation level such
  15076. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15077. // or updated by the mutation.
  15078. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  15079. switch {
  15080. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15081. id, exists := m.ID()
  15082. if exists {
  15083. return []uint64{id}, nil
  15084. }
  15085. fallthrough
  15086. case m.op.Is(OpUpdate | OpDelete):
  15087. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  15088. default:
  15089. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15090. }
  15091. }
  15092. // SetCreatedAt sets the "created_at" field.
  15093. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  15094. m.created_at = &t
  15095. }
  15096. // CreatedAt returns the value of the "created_at" field in the mutation.
  15097. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  15098. v := m.created_at
  15099. if v == nil {
  15100. return
  15101. }
  15102. return *v, true
  15103. }
  15104. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  15105. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15107. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15108. if !m.op.Is(OpUpdateOne) {
  15109. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15110. }
  15111. if m.id == nil || m.oldValue == nil {
  15112. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15113. }
  15114. oldValue, err := m.oldValue(ctx)
  15115. if err != nil {
  15116. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15117. }
  15118. return oldValue.CreatedAt, nil
  15119. }
  15120. // ResetCreatedAt resets all changes to the "created_at" field.
  15121. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  15122. m.created_at = nil
  15123. }
  15124. // SetUpdatedAt sets the "updated_at" field.
  15125. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  15126. m.updated_at = &t
  15127. }
  15128. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15129. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  15130. v := m.updated_at
  15131. if v == nil {
  15132. return
  15133. }
  15134. return *v, true
  15135. }
  15136. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  15137. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15139. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15140. if !m.op.Is(OpUpdateOne) {
  15141. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15142. }
  15143. if m.id == nil || m.oldValue == nil {
  15144. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15145. }
  15146. oldValue, err := m.oldValue(ctx)
  15147. if err != nil {
  15148. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15149. }
  15150. return oldValue.UpdatedAt, nil
  15151. }
  15152. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15153. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  15154. m.updated_at = nil
  15155. }
  15156. // SetStatus sets the "status" field.
  15157. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  15158. m.status = &u
  15159. m.addstatus = nil
  15160. }
  15161. // Status returns the value of the "status" field in the mutation.
  15162. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  15163. v := m.status
  15164. if v == nil {
  15165. return
  15166. }
  15167. return *v, true
  15168. }
  15169. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  15170. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15172. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15173. if !m.op.Is(OpUpdateOne) {
  15174. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15175. }
  15176. if m.id == nil || m.oldValue == nil {
  15177. return v, errors.New("OldStatus requires an ID field in the mutation")
  15178. }
  15179. oldValue, err := m.oldValue(ctx)
  15180. if err != nil {
  15181. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15182. }
  15183. return oldValue.Status, nil
  15184. }
  15185. // AddStatus adds u to the "status" field.
  15186. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  15187. if m.addstatus != nil {
  15188. *m.addstatus += u
  15189. } else {
  15190. m.addstatus = &u
  15191. }
  15192. }
  15193. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15194. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  15195. v := m.addstatus
  15196. if v == nil {
  15197. return
  15198. }
  15199. return *v, true
  15200. }
  15201. // ClearStatus clears the value of the "status" field.
  15202. func (m *ContactFieldTemplateMutation) ClearStatus() {
  15203. m.status = nil
  15204. m.addstatus = nil
  15205. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  15206. }
  15207. // StatusCleared returns if the "status" field was cleared in this mutation.
  15208. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  15209. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  15210. return ok
  15211. }
  15212. // ResetStatus resets all changes to the "status" field.
  15213. func (m *ContactFieldTemplateMutation) ResetStatus() {
  15214. m.status = nil
  15215. m.addstatus = nil
  15216. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  15217. }
  15218. // SetDeletedAt sets the "deleted_at" field.
  15219. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  15220. m.deleted_at = &t
  15221. }
  15222. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15223. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  15224. v := m.deleted_at
  15225. if v == nil {
  15226. return
  15227. }
  15228. return *v, true
  15229. }
  15230. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  15231. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15233. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15234. if !m.op.Is(OpUpdateOne) {
  15235. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15236. }
  15237. if m.id == nil || m.oldValue == nil {
  15238. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15239. }
  15240. oldValue, err := m.oldValue(ctx)
  15241. if err != nil {
  15242. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15243. }
  15244. return oldValue.DeletedAt, nil
  15245. }
  15246. // ClearDeletedAt clears the value of the "deleted_at" field.
  15247. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  15248. m.deleted_at = nil
  15249. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  15250. }
  15251. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15252. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  15253. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  15254. return ok
  15255. }
  15256. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15257. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  15258. m.deleted_at = nil
  15259. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  15260. }
  15261. // SetOrganizationID sets the "organization_id" field.
  15262. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  15263. m.organization_id = &u
  15264. m.addorganization_id = nil
  15265. }
  15266. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15267. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  15268. v := m.organization_id
  15269. if v == nil {
  15270. return
  15271. }
  15272. return *v, true
  15273. }
  15274. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  15275. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15277. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15278. if !m.op.Is(OpUpdateOne) {
  15279. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15280. }
  15281. if m.id == nil || m.oldValue == nil {
  15282. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15283. }
  15284. oldValue, err := m.oldValue(ctx)
  15285. if err != nil {
  15286. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15287. }
  15288. return oldValue.OrganizationID, nil
  15289. }
  15290. // AddOrganizationID adds u to the "organization_id" field.
  15291. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  15292. if m.addorganization_id != nil {
  15293. *m.addorganization_id += u
  15294. } else {
  15295. m.addorganization_id = &u
  15296. }
  15297. }
  15298. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15299. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  15300. v := m.addorganization_id
  15301. if v == nil {
  15302. return
  15303. }
  15304. return *v, true
  15305. }
  15306. // ResetOrganizationID resets all changes to the "organization_id" field.
  15307. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  15308. m.organization_id = nil
  15309. m.addorganization_id = nil
  15310. }
  15311. // SetTemplate sets the "template" field.
  15312. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  15313. m.template = &ctft
  15314. m.appendtemplate = nil
  15315. }
  15316. // Template returns the value of the "template" field in the mutation.
  15317. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  15318. v := m.template
  15319. if v == nil {
  15320. return
  15321. }
  15322. return *v, true
  15323. }
  15324. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  15325. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15327. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  15328. if !m.op.Is(OpUpdateOne) {
  15329. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  15330. }
  15331. if m.id == nil || m.oldValue == nil {
  15332. return v, errors.New("OldTemplate requires an ID field in the mutation")
  15333. }
  15334. oldValue, err := m.oldValue(ctx)
  15335. if err != nil {
  15336. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  15337. }
  15338. return oldValue.Template, nil
  15339. }
  15340. // AppendTemplate adds ctft to the "template" field.
  15341. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  15342. m.appendtemplate = append(m.appendtemplate, ctft...)
  15343. }
  15344. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  15345. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  15346. if len(m.appendtemplate) == 0 {
  15347. return nil, false
  15348. }
  15349. return m.appendtemplate, true
  15350. }
  15351. // ResetTemplate resets all changes to the "template" field.
  15352. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  15353. m.template = nil
  15354. m.appendtemplate = nil
  15355. }
  15356. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  15357. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  15358. m.predicates = append(m.predicates, ps...)
  15359. }
  15360. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  15361. // users can use type-assertion to append predicates that do not depend on any generated package.
  15362. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  15363. p := make([]predicate.ContactFieldTemplate, len(ps))
  15364. for i := range ps {
  15365. p[i] = ps[i]
  15366. }
  15367. m.Where(p...)
  15368. }
  15369. // Op returns the operation name.
  15370. func (m *ContactFieldTemplateMutation) Op() Op {
  15371. return m.op
  15372. }
  15373. // SetOp allows setting the mutation operation.
  15374. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  15375. m.op = op
  15376. }
  15377. // Type returns the node type of this mutation (ContactFieldTemplate).
  15378. func (m *ContactFieldTemplateMutation) Type() string {
  15379. return m.typ
  15380. }
  15381. // Fields returns all fields that were changed during this mutation. Note that in
  15382. // order to get all numeric fields that were incremented/decremented, call
  15383. // AddedFields().
  15384. func (m *ContactFieldTemplateMutation) Fields() []string {
  15385. fields := make([]string, 0, 6)
  15386. if m.created_at != nil {
  15387. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  15388. }
  15389. if m.updated_at != nil {
  15390. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  15391. }
  15392. if m.status != nil {
  15393. fields = append(fields, contactfieldtemplate.FieldStatus)
  15394. }
  15395. if m.deleted_at != nil {
  15396. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15397. }
  15398. if m.organization_id != nil {
  15399. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15400. }
  15401. if m.template != nil {
  15402. fields = append(fields, contactfieldtemplate.FieldTemplate)
  15403. }
  15404. return fields
  15405. }
  15406. // Field returns the value of a field with the given name. The second boolean
  15407. // return value indicates that this field was not set, or was not defined in the
  15408. // schema.
  15409. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  15410. switch name {
  15411. case contactfieldtemplate.FieldCreatedAt:
  15412. return m.CreatedAt()
  15413. case contactfieldtemplate.FieldUpdatedAt:
  15414. return m.UpdatedAt()
  15415. case contactfieldtemplate.FieldStatus:
  15416. return m.Status()
  15417. case contactfieldtemplate.FieldDeletedAt:
  15418. return m.DeletedAt()
  15419. case contactfieldtemplate.FieldOrganizationID:
  15420. return m.OrganizationID()
  15421. case contactfieldtemplate.FieldTemplate:
  15422. return m.Template()
  15423. }
  15424. return nil, false
  15425. }
  15426. // OldField returns the old value of the field from the database. An error is
  15427. // returned if the mutation operation is not UpdateOne, or the query to the
  15428. // database failed.
  15429. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15430. switch name {
  15431. case contactfieldtemplate.FieldCreatedAt:
  15432. return m.OldCreatedAt(ctx)
  15433. case contactfieldtemplate.FieldUpdatedAt:
  15434. return m.OldUpdatedAt(ctx)
  15435. case contactfieldtemplate.FieldStatus:
  15436. return m.OldStatus(ctx)
  15437. case contactfieldtemplate.FieldDeletedAt:
  15438. return m.OldDeletedAt(ctx)
  15439. case contactfieldtemplate.FieldOrganizationID:
  15440. return m.OldOrganizationID(ctx)
  15441. case contactfieldtemplate.FieldTemplate:
  15442. return m.OldTemplate(ctx)
  15443. }
  15444. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15445. }
  15446. // SetField sets the value of a field with the given name. It returns an error if
  15447. // the field is not defined in the schema, or if the type mismatched the field
  15448. // type.
  15449. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  15450. switch name {
  15451. case contactfieldtemplate.FieldCreatedAt:
  15452. v, ok := value.(time.Time)
  15453. if !ok {
  15454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15455. }
  15456. m.SetCreatedAt(v)
  15457. return nil
  15458. case contactfieldtemplate.FieldUpdatedAt:
  15459. v, ok := value.(time.Time)
  15460. if !ok {
  15461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15462. }
  15463. m.SetUpdatedAt(v)
  15464. return nil
  15465. case contactfieldtemplate.FieldStatus:
  15466. v, ok := value.(uint8)
  15467. if !ok {
  15468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15469. }
  15470. m.SetStatus(v)
  15471. return nil
  15472. case contactfieldtemplate.FieldDeletedAt:
  15473. v, ok := value.(time.Time)
  15474. if !ok {
  15475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15476. }
  15477. m.SetDeletedAt(v)
  15478. return nil
  15479. case contactfieldtemplate.FieldOrganizationID:
  15480. v, ok := value.(uint64)
  15481. if !ok {
  15482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15483. }
  15484. m.SetOrganizationID(v)
  15485. return nil
  15486. case contactfieldtemplate.FieldTemplate:
  15487. v, ok := value.([]custom_types.ContactFieldTemplate)
  15488. if !ok {
  15489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15490. }
  15491. m.SetTemplate(v)
  15492. return nil
  15493. }
  15494. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15495. }
  15496. // AddedFields returns all numeric fields that were incremented/decremented during
  15497. // this mutation.
  15498. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  15499. var fields []string
  15500. if m.addstatus != nil {
  15501. fields = append(fields, contactfieldtemplate.FieldStatus)
  15502. }
  15503. if m.addorganization_id != nil {
  15504. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15505. }
  15506. return fields
  15507. }
  15508. // AddedField returns the numeric value that was incremented/decremented on a field
  15509. // with the given name. The second boolean return value indicates that this field
  15510. // was not set, or was not defined in the schema.
  15511. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  15512. switch name {
  15513. case contactfieldtemplate.FieldStatus:
  15514. return m.AddedStatus()
  15515. case contactfieldtemplate.FieldOrganizationID:
  15516. return m.AddedOrganizationID()
  15517. }
  15518. return nil, false
  15519. }
  15520. // AddField adds the value to the field with the given name. It returns an error if
  15521. // the field is not defined in the schema, or if the type mismatched the field
  15522. // type.
  15523. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  15524. switch name {
  15525. case contactfieldtemplate.FieldStatus:
  15526. v, ok := value.(int8)
  15527. if !ok {
  15528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15529. }
  15530. m.AddStatus(v)
  15531. return nil
  15532. case contactfieldtemplate.FieldOrganizationID:
  15533. v, ok := value.(int64)
  15534. if !ok {
  15535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15536. }
  15537. m.AddOrganizationID(v)
  15538. return nil
  15539. }
  15540. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  15541. }
  15542. // ClearedFields returns all nullable fields that were cleared during this
  15543. // mutation.
  15544. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  15545. var fields []string
  15546. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  15547. fields = append(fields, contactfieldtemplate.FieldStatus)
  15548. }
  15549. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  15550. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15551. }
  15552. return fields
  15553. }
  15554. // FieldCleared returns a boolean indicating if a field with the given name was
  15555. // cleared in this mutation.
  15556. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  15557. _, ok := m.clearedFields[name]
  15558. return ok
  15559. }
  15560. // ClearField clears the value of the field with the given name. It returns an
  15561. // error if the field is not defined in the schema.
  15562. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  15563. switch name {
  15564. case contactfieldtemplate.FieldStatus:
  15565. m.ClearStatus()
  15566. return nil
  15567. case contactfieldtemplate.FieldDeletedAt:
  15568. m.ClearDeletedAt()
  15569. return nil
  15570. }
  15571. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  15572. }
  15573. // ResetField resets all changes in the mutation for the field with the given name.
  15574. // It returns an error if the field is not defined in the schema.
  15575. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  15576. switch name {
  15577. case contactfieldtemplate.FieldCreatedAt:
  15578. m.ResetCreatedAt()
  15579. return nil
  15580. case contactfieldtemplate.FieldUpdatedAt:
  15581. m.ResetUpdatedAt()
  15582. return nil
  15583. case contactfieldtemplate.FieldStatus:
  15584. m.ResetStatus()
  15585. return nil
  15586. case contactfieldtemplate.FieldDeletedAt:
  15587. m.ResetDeletedAt()
  15588. return nil
  15589. case contactfieldtemplate.FieldOrganizationID:
  15590. m.ResetOrganizationID()
  15591. return nil
  15592. case contactfieldtemplate.FieldTemplate:
  15593. m.ResetTemplate()
  15594. return nil
  15595. }
  15596. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15597. }
  15598. // AddedEdges returns all edge names that were set/added in this mutation.
  15599. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  15600. edges := make([]string, 0, 0)
  15601. return edges
  15602. }
  15603. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15604. // name in this mutation.
  15605. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  15606. return nil
  15607. }
  15608. // RemovedEdges returns all edge names that were removed in this mutation.
  15609. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  15610. edges := make([]string, 0, 0)
  15611. return edges
  15612. }
  15613. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15614. // the given name in this mutation.
  15615. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  15616. return nil
  15617. }
  15618. // ClearedEdges returns all edge names that were cleared in this mutation.
  15619. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  15620. edges := make([]string, 0, 0)
  15621. return edges
  15622. }
  15623. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15624. // was cleared in this mutation.
  15625. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  15626. return false
  15627. }
  15628. // ClearEdge clears the value of the edge with the given name. It returns an error
  15629. // if that edge is not defined in the schema.
  15630. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  15631. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  15632. }
  15633. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15634. // It returns an error if the edge is not defined in the schema.
  15635. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  15636. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  15637. }
  15638. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  15639. type CreditBalanceMutation struct {
  15640. config
  15641. op Op
  15642. typ string
  15643. id *uint64
  15644. created_at *time.Time
  15645. updated_at *time.Time
  15646. deleted_at *time.Time
  15647. user_id *string
  15648. balance *float64
  15649. addbalance *float64
  15650. status *int
  15651. addstatus *int
  15652. organization_id *uint64
  15653. addorganization_id *int64
  15654. clearedFields map[string]struct{}
  15655. done bool
  15656. oldValue func(context.Context) (*CreditBalance, error)
  15657. predicates []predicate.CreditBalance
  15658. }
  15659. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  15660. // creditbalanceOption allows management of the mutation configuration using functional options.
  15661. type creditbalanceOption func(*CreditBalanceMutation)
  15662. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  15663. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  15664. m := &CreditBalanceMutation{
  15665. config: c,
  15666. op: op,
  15667. typ: TypeCreditBalance,
  15668. clearedFields: make(map[string]struct{}),
  15669. }
  15670. for _, opt := range opts {
  15671. opt(m)
  15672. }
  15673. return m
  15674. }
  15675. // withCreditBalanceID sets the ID field of the mutation.
  15676. func withCreditBalanceID(id uint64) creditbalanceOption {
  15677. return func(m *CreditBalanceMutation) {
  15678. var (
  15679. err error
  15680. once sync.Once
  15681. value *CreditBalance
  15682. )
  15683. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  15684. once.Do(func() {
  15685. if m.done {
  15686. err = errors.New("querying old values post mutation is not allowed")
  15687. } else {
  15688. value, err = m.Client().CreditBalance.Get(ctx, id)
  15689. }
  15690. })
  15691. return value, err
  15692. }
  15693. m.id = &id
  15694. }
  15695. }
  15696. // withCreditBalance sets the old CreditBalance of the mutation.
  15697. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  15698. return func(m *CreditBalanceMutation) {
  15699. m.oldValue = func(context.Context) (*CreditBalance, error) {
  15700. return node, nil
  15701. }
  15702. m.id = &node.ID
  15703. }
  15704. }
  15705. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15706. // executed in a transaction (ent.Tx), a transactional client is returned.
  15707. func (m CreditBalanceMutation) Client() *Client {
  15708. client := &Client{config: m.config}
  15709. client.init()
  15710. return client
  15711. }
  15712. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15713. // it returns an error otherwise.
  15714. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  15715. if _, ok := m.driver.(*txDriver); !ok {
  15716. return nil, errors.New("ent: mutation is not running in a transaction")
  15717. }
  15718. tx := &Tx{config: m.config}
  15719. tx.init()
  15720. return tx, nil
  15721. }
  15722. // SetID sets the value of the id field. Note that this
  15723. // operation is only accepted on creation of CreditBalance entities.
  15724. func (m *CreditBalanceMutation) SetID(id uint64) {
  15725. m.id = &id
  15726. }
  15727. // ID returns the ID value in the mutation. Note that the ID is only available
  15728. // if it was provided to the builder or after it was returned from the database.
  15729. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  15730. if m.id == nil {
  15731. return
  15732. }
  15733. return *m.id, true
  15734. }
  15735. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15736. // That means, if the mutation is applied within a transaction with an isolation level such
  15737. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15738. // or updated by the mutation.
  15739. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15740. switch {
  15741. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15742. id, exists := m.ID()
  15743. if exists {
  15744. return []uint64{id}, nil
  15745. }
  15746. fallthrough
  15747. case m.op.Is(OpUpdate | OpDelete):
  15748. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  15749. default:
  15750. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15751. }
  15752. }
  15753. // SetCreatedAt sets the "created_at" field.
  15754. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  15755. m.created_at = &t
  15756. }
  15757. // CreatedAt returns the value of the "created_at" field in the mutation.
  15758. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  15759. v := m.created_at
  15760. if v == nil {
  15761. return
  15762. }
  15763. return *v, true
  15764. }
  15765. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  15766. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15768. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15769. if !m.op.Is(OpUpdateOne) {
  15770. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15771. }
  15772. if m.id == nil || m.oldValue == nil {
  15773. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15774. }
  15775. oldValue, err := m.oldValue(ctx)
  15776. if err != nil {
  15777. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15778. }
  15779. return oldValue.CreatedAt, nil
  15780. }
  15781. // ResetCreatedAt resets all changes to the "created_at" field.
  15782. func (m *CreditBalanceMutation) ResetCreatedAt() {
  15783. m.created_at = nil
  15784. }
  15785. // SetUpdatedAt sets the "updated_at" field.
  15786. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  15787. m.updated_at = &t
  15788. }
  15789. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15790. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  15791. v := m.updated_at
  15792. if v == nil {
  15793. return
  15794. }
  15795. return *v, true
  15796. }
  15797. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  15798. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15800. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15801. if !m.op.Is(OpUpdateOne) {
  15802. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15803. }
  15804. if m.id == nil || m.oldValue == nil {
  15805. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15806. }
  15807. oldValue, err := m.oldValue(ctx)
  15808. if err != nil {
  15809. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15810. }
  15811. return oldValue.UpdatedAt, nil
  15812. }
  15813. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15814. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  15815. m.updated_at = nil
  15816. }
  15817. // SetDeletedAt sets the "deleted_at" field.
  15818. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  15819. m.deleted_at = &t
  15820. }
  15821. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15822. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  15823. v := m.deleted_at
  15824. if v == nil {
  15825. return
  15826. }
  15827. return *v, true
  15828. }
  15829. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  15830. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15832. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15833. if !m.op.Is(OpUpdateOne) {
  15834. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15835. }
  15836. if m.id == nil || m.oldValue == nil {
  15837. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15838. }
  15839. oldValue, err := m.oldValue(ctx)
  15840. if err != nil {
  15841. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15842. }
  15843. return oldValue.DeletedAt, nil
  15844. }
  15845. // ClearDeletedAt clears the value of the "deleted_at" field.
  15846. func (m *CreditBalanceMutation) ClearDeletedAt() {
  15847. m.deleted_at = nil
  15848. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  15849. }
  15850. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15851. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  15852. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  15853. return ok
  15854. }
  15855. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15856. func (m *CreditBalanceMutation) ResetDeletedAt() {
  15857. m.deleted_at = nil
  15858. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  15859. }
  15860. // SetUserID sets the "user_id" field.
  15861. func (m *CreditBalanceMutation) SetUserID(s string) {
  15862. m.user_id = &s
  15863. }
  15864. // UserID returns the value of the "user_id" field in the mutation.
  15865. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  15866. v := m.user_id
  15867. if v == nil {
  15868. return
  15869. }
  15870. return *v, true
  15871. }
  15872. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  15873. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15875. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  15876. if !m.op.Is(OpUpdateOne) {
  15877. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15878. }
  15879. if m.id == nil || m.oldValue == nil {
  15880. return v, errors.New("OldUserID requires an ID field in the mutation")
  15881. }
  15882. oldValue, err := m.oldValue(ctx)
  15883. if err != nil {
  15884. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15885. }
  15886. return oldValue.UserID, nil
  15887. }
  15888. // ClearUserID clears the value of the "user_id" field.
  15889. func (m *CreditBalanceMutation) ClearUserID() {
  15890. m.user_id = nil
  15891. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  15892. }
  15893. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15894. func (m *CreditBalanceMutation) UserIDCleared() bool {
  15895. _, ok := m.clearedFields[creditbalance.FieldUserID]
  15896. return ok
  15897. }
  15898. // ResetUserID resets all changes to the "user_id" field.
  15899. func (m *CreditBalanceMutation) ResetUserID() {
  15900. m.user_id = nil
  15901. delete(m.clearedFields, creditbalance.FieldUserID)
  15902. }
  15903. // SetBalance sets the "balance" field.
  15904. func (m *CreditBalanceMutation) SetBalance(f float64) {
  15905. m.balance = &f
  15906. m.addbalance = nil
  15907. }
  15908. // Balance returns the value of the "balance" field in the mutation.
  15909. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  15910. v := m.balance
  15911. if v == nil {
  15912. return
  15913. }
  15914. return *v, true
  15915. }
  15916. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  15917. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15919. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  15920. if !m.op.Is(OpUpdateOne) {
  15921. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  15922. }
  15923. if m.id == nil || m.oldValue == nil {
  15924. return v, errors.New("OldBalance requires an ID field in the mutation")
  15925. }
  15926. oldValue, err := m.oldValue(ctx)
  15927. if err != nil {
  15928. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  15929. }
  15930. return oldValue.Balance, nil
  15931. }
  15932. // AddBalance adds f to the "balance" field.
  15933. func (m *CreditBalanceMutation) AddBalance(f float64) {
  15934. if m.addbalance != nil {
  15935. *m.addbalance += f
  15936. } else {
  15937. m.addbalance = &f
  15938. }
  15939. }
  15940. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  15941. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  15942. v := m.addbalance
  15943. if v == nil {
  15944. return
  15945. }
  15946. return *v, true
  15947. }
  15948. // ResetBalance resets all changes to the "balance" field.
  15949. func (m *CreditBalanceMutation) ResetBalance() {
  15950. m.balance = nil
  15951. m.addbalance = nil
  15952. }
  15953. // SetStatus sets the "status" field.
  15954. func (m *CreditBalanceMutation) SetStatus(i int) {
  15955. m.status = &i
  15956. m.addstatus = nil
  15957. }
  15958. // Status returns the value of the "status" field in the mutation.
  15959. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  15960. v := m.status
  15961. if v == nil {
  15962. return
  15963. }
  15964. return *v, true
  15965. }
  15966. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  15967. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15969. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  15970. if !m.op.Is(OpUpdateOne) {
  15971. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15972. }
  15973. if m.id == nil || m.oldValue == nil {
  15974. return v, errors.New("OldStatus requires an ID field in the mutation")
  15975. }
  15976. oldValue, err := m.oldValue(ctx)
  15977. if err != nil {
  15978. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15979. }
  15980. return oldValue.Status, nil
  15981. }
  15982. // AddStatus adds i to the "status" field.
  15983. func (m *CreditBalanceMutation) AddStatus(i int) {
  15984. if m.addstatus != nil {
  15985. *m.addstatus += i
  15986. } else {
  15987. m.addstatus = &i
  15988. }
  15989. }
  15990. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15991. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  15992. v := m.addstatus
  15993. if v == nil {
  15994. return
  15995. }
  15996. return *v, true
  15997. }
  15998. // ClearStatus clears the value of the "status" field.
  15999. func (m *CreditBalanceMutation) ClearStatus() {
  16000. m.status = nil
  16001. m.addstatus = nil
  16002. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  16003. }
  16004. // StatusCleared returns if the "status" field was cleared in this mutation.
  16005. func (m *CreditBalanceMutation) StatusCleared() bool {
  16006. _, ok := m.clearedFields[creditbalance.FieldStatus]
  16007. return ok
  16008. }
  16009. // ResetStatus resets all changes to the "status" field.
  16010. func (m *CreditBalanceMutation) ResetStatus() {
  16011. m.status = nil
  16012. m.addstatus = nil
  16013. delete(m.clearedFields, creditbalance.FieldStatus)
  16014. }
  16015. // SetOrganizationID sets the "organization_id" field.
  16016. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  16017. m.organization_id = &u
  16018. m.addorganization_id = nil
  16019. }
  16020. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16021. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  16022. v := m.organization_id
  16023. if v == nil {
  16024. return
  16025. }
  16026. return *v, true
  16027. }
  16028. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  16029. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16031. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16032. if !m.op.Is(OpUpdateOne) {
  16033. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16034. }
  16035. if m.id == nil || m.oldValue == nil {
  16036. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16037. }
  16038. oldValue, err := m.oldValue(ctx)
  16039. if err != nil {
  16040. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16041. }
  16042. return oldValue.OrganizationID, nil
  16043. }
  16044. // AddOrganizationID adds u to the "organization_id" field.
  16045. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  16046. if m.addorganization_id != nil {
  16047. *m.addorganization_id += u
  16048. } else {
  16049. m.addorganization_id = &u
  16050. }
  16051. }
  16052. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16053. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  16054. v := m.addorganization_id
  16055. if v == nil {
  16056. return
  16057. }
  16058. return *v, true
  16059. }
  16060. // ClearOrganizationID clears the value of the "organization_id" field.
  16061. func (m *CreditBalanceMutation) ClearOrganizationID() {
  16062. m.organization_id = nil
  16063. m.addorganization_id = nil
  16064. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  16065. }
  16066. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16067. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  16068. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  16069. return ok
  16070. }
  16071. // ResetOrganizationID resets all changes to the "organization_id" field.
  16072. func (m *CreditBalanceMutation) ResetOrganizationID() {
  16073. m.organization_id = nil
  16074. m.addorganization_id = nil
  16075. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  16076. }
  16077. // Where appends a list predicates to the CreditBalanceMutation builder.
  16078. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  16079. m.predicates = append(m.predicates, ps...)
  16080. }
  16081. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  16082. // users can use type-assertion to append predicates that do not depend on any generated package.
  16083. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  16084. p := make([]predicate.CreditBalance, len(ps))
  16085. for i := range ps {
  16086. p[i] = ps[i]
  16087. }
  16088. m.Where(p...)
  16089. }
  16090. // Op returns the operation name.
  16091. func (m *CreditBalanceMutation) Op() Op {
  16092. return m.op
  16093. }
  16094. // SetOp allows setting the mutation operation.
  16095. func (m *CreditBalanceMutation) SetOp(op Op) {
  16096. m.op = op
  16097. }
  16098. // Type returns the node type of this mutation (CreditBalance).
  16099. func (m *CreditBalanceMutation) Type() string {
  16100. return m.typ
  16101. }
  16102. // Fields returns all fields that were changed during this mutation. Note that in
  16103. // order to get all numeric fields that were incremented/decremented, call
  16104. // AddedFields().
  16105. func (m *CreditBalanceMutation) Fields() []string {
  16106. fields := make([]string, 0, 7)
  16107. if m.created_at != nil {
  16108. fields = append(fields, creditbalance.FieldCreatedAt)
  16109. }
  16110. if m.updated_at != nil {
  16111. fields = append(fields, creditbalance.FieldUpdatedAt)
  16112. }
  16113. if m.deleted_at != nil {
  16114. fields = append(fields, creditbalance.FieldDeletedAt)
  16115. }
  16116. if m.user_id != nil {
  16117. fields = append(fields, creditbalance.FieldUserID)
  16118. }
  16119. if m.balance != nil {
  16120. fields = append(fields, creditbalance.FieldBalance)
  16121. }
  16122. if m.status != nil {
  16123. fields = append(fields, creditbalance.FieldStatus)
  16124. }
  16125. if m.organization_id != nil {
  16126. fields = append(fields, creditbalance.FieldOrganizationID)
  16127. }
  16128. return fields
  16129. }
  16130. // Field returns the value of a field with the given name. The second boolean
  16131. // return value indicates that this field was not set, or was not defined in the
  16132. // schema.
  16133. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  16134. switch name {
  16135. case creditbalance.FieldCreatedAt:
  16136. return m.CreatedAt()
  16137. case creditbalance.FieldUpdatedAt:
  16138. return m.UpdatedAt()
  16139. case creditbalance.FieldDeletedAt:
  16140. return m.DeletedAt()
  16141. case creditbalance.FieldUserID:
  16142. return m.UserID()
  16143. case creditbalance.FieldBalance:
  16144. return m.Balance()
  16145. case creditbalance.FieldStatus:
  16146. return m.Status()
  16147. case creditbalance.FieldOrganizationID:
  16148. return m.OrganizationID()
  16149. }
  16150. return nil, false
  16151. }
  16152. // OldField returns the old value of the field from the database. An error is
  16153. // returned if the mutation operation is not UpdateOne, or the query to the
  16154. // database failed.
  16155. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16156. switch name {
  16157. case creditbalance.FieldCreatedAt:
  16158. return m.OldCreatedAt(ctx)
  16159. case creditbalance.FieldUpdatedAt:
  16160. return m.OldUpdatedAt(ctx)
  16161. case creditbalance.FieldDeletedAt:
  16162. return m.OldDeletedAt(ctx)
  16163. case creditbalance.FieldUserID:
  16164. return m.OldUserID(ctx)
  16165. case creditbalance.FieldBalance:
  16166. return m.OldBalance(ctx)
  16167. case creditbalance.FieldStatus:
  16168. return m.OldStatus(ctx)
  16169. case creditbalance.FieldOrganizationID:
  16170. return m.OldOrganizationID(ctx)
  16171. }
  16172. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  16173. }
  16174. // SetField sets the value of a field with the given name. It returns an error if
  16175. // the field is not defined in the schema, or if the type mismatched the field
  16176. // type.
  16177. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  16178. switch name {
  16179. case creditbalance.FieldCreatedAt:
  16180. v, ok := value.(time.Time)
  16181. if !ok {
  16182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16183. }
  16184. m.SetCreatedAt(v)
  16185. return nil
  16186. case creditbalance.FieldUpdatedAt:
  16187. v, ok := value.(time.Time)
  16188. if !ok {
  16189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16190. }
  16191. m.SetUpdatedAt(v)
  16192. return nil
  16193. case creditbalance.FieldDeletedAt:
  16194. v, ok := value.(time.Time)
  16195. if !ok {
  16196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16197. }
  16198. m.SetDeletedAt(v)
  16199. return nil
  16200. case creditbalance.FieldUserID:
  16201. v, ok := value.(string)
  16202. if !ok {
  16203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16204. }
  16205. m.SetUserID(v)
  16206. return nil
  16207. case creditbalance.FieldBalance:
  16208. v, ok := value.(float64)
  16209. if !ok {
  16210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16211. }
  16212. m.SetBalance(v)
  16213. return nil
  16214. case creditbalance.FieldStatus:
  16215. v, ok := value.(int)
  16216. if !ok {
  16217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16218. }
  16219. m.SetStatus(v)
  16220. return nil
  16221. case creditbalance.FieldOrganizationID:
  16222. v, ok := value.(uint64)
  16223. if !ok {
  16224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16225. }
  16226. m.SetOrganizationID(v)
  16227. return nil
  16228. }
  16229. return fmt.Errorf("unknown CreditBalance field %s", name)
  16230. }
  16231. // AddedFields returns all numeric fields that were incremented/decremented during
  16232. // this mutation.
  16233. func (m *CreditBalanceMutation) AddedFields() []string {
  16234. var fields []string
  16235. if m.addbalance != nil {
  16236. fields = append(fields, creditbalance.FieldBalance)
  16237. }
  16238. if m.addstatus != nil {
  16239. fields = append(fields, creditbalance.FieldStatus)
  16240. }
  16241. if m.addorganization_id != nil {
  16242. fields = append(fields, creditbalance.FieldOrganizationID)
  16243. }
  16244. return fields
  16245. }
  16246. // AddedField returns the numeric value that was incremented/decremented on a field
  16247. // with the given name. The second boolean return value indicates that this field
  16248. // was not set, or was not defined in the schema.
  16249. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  16250. switch name {
  16251. case creditbalance.FieldBalance:
  16252. return m.AddedBalance()
  16253. case creditbalance.FieldStatus:
  16254. return m.AddedStatus()
  16255. case creditbalance.FieldOrganizationID:
  16256. return m.AddedOrganizationID()
  16257. }
  16258. return nil, false
  16259. }
  16260. // AddField adds the value to the field with the given name. It returns an error if
  16261. // the field is not defined in the schema, or if the type mismatched the field
  16262. // type.
  16263. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  16264. switch name {
  16265. case creditbalance.FieldBalance:
  16266. v, ok := value.(float64)
  16267. if !ok {
  16268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16269. }
  16270. m.AddBalance(v)
  16271. return nil
  16272. case creditbalance.FieldStatus:
  16273. v, ok := value.(int)
  16274. if !ok {
  16275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16276. }
  16277. m.AddStatus(v)
  16278. return nil
  16279. case creditbalance.FieldOrganizationID:
  16280. v, ok := value.(int64)
  16281. if !ok {
  16282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16283. }
  16284. m.AddOrganizationID(v)
  16285. return nil
  16286. }
  16287. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  16288. }
  16289. // ClearedFields returns all nullable fields that were cleared during this
  16290. // mutation.
  16291. func (m *CreditBalanceMutation) ClearedFields() []string {
  16292. var fields []string
  16293. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  16294. fields = append(fields, creditbalance.FieldDeletedAt)
  16295. }
  16296. if m.FieldCleared(creditbalance.FieldUserID) {
  16297. fields = append(fields, creditbalance.FieldUserID)
  16298. }
  16299. if m.FieldCleared(creditbalance.FieldStatus) {
  16300. fields = append(fields, creditbalance.FieldStatus)
  16301. }
  16302. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  16303. fields = append(fields, creditbalance.FieldOrganizationID)
  16304. }
  16305. return fields
  16306. }
  16307. // FieldCleared returns a boolean indicating if a field with the given name was
  16308. // cleared in this mutation.
  16309. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  16310. _, ok := m.clearedFields[name]
  16311. return ok
  16312. }
  16313. // ClearField clears the value of the field with the given name. It returns an
  16314. // error if the field is not defined in the schema.
  16315. func (m *CreditBalanceMutation) ClearField(name string) error {
  16316. switch name {
  16317. case creditbalance.FieldDeletedAt:
  16318. m.ClearDeletedAt()
  16319. return nil
  16320. case creditbalance.FieldUserID:
  16321. m.ClearUserID()
  16322. return nil
  16323. case creditbalance.FieldStatus:
  16324. m.ClearStatus()
  16325. return nil
  16326. case creditbalance.FieldOrganizationID:
  16327. m.ClearOrganizationID()
  16328. return nil
  16329. }
  16330. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  16331. }
  16332. // ResetField resets all changes in the mutation for the field with the given name.
  16333. // It returns an error if the field is not defined in the schema.
  16334. func (m *CreditBalanceMutation) ResetField(name string) error {
  16335. switch name {
  16336. case creditbalance.FieldCreatedAt:
  16337. m.ResetCreatedAt()
  16338. return nil
  16339. case creditbalance.FieldUpdatedAt:
  16340. m.ResetUpdatedAt()
  16341. return nil
  16342. case creditbalance.FieldDeletedAt:
  16343. m.ResetDeletedAt()
  16344. return nil
  16345. case creditbalance.FieldUserID:
  16346. m.ResetUserID()
  16347. return nil
  16348. case creditbalance.FieldBalance:
  16349. m.ResetBalance()
  16350. return nil
  16351. case creditbalance.FieldStatus:
  16352. m.ResetStatus()
  16353. return nil
  16354. case creditbalance.FieldOrganizationID:
  16355. m.ResetOrganizationID()
  16356. return nil
  16357. }
  16358. return fmt.Errorf("unknown CreditBalance field %s", name)
  16359. }
  16360. // AddedEdges returns all edge names that were set/added in this mutation.
  16361. func (m *CreditBalanceMutation) AddedEdges() []string {
  16362. edges := make([]string, 0, 0)
  16363. return edges
  16364. }
  16365. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16366. // name in this mutation.
  16367. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  16368. return nil
  16369. }
  16370. // RemovedEdges returns all edge names that were removed in this mutation.
  16371. func (m *CreditBalanceMutation) RemovedEdges() []string {
  16372. edges := make([]string, 0, 0)
  16373. return edges
  16374. }
  16375. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16376. // the given name in this mutation.
  16377. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  16378. return nil
  16379. }
  16380. // ClearedEdges returns all edge names that were cleared in this mutation.
  16381. func (m *CreditBalanceMutation) ClearedEdges() []string {
  16382. edges := make([]string, 0, 0)
  16383. return edges
  16384. }
  16385. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16386. // was cleared in this mutation.
  16387. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  16388. return false
  16389. }
  16390. // ClearEdge clears the value of the edge with the given name. It returns an error
  16391. // if that edge is not defined in the schema.
  16392. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  16393. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  16394. }
  16395. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16396. // It returns an error if the edge is not defined in the schema.
  16397. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  16398. return fmt.Errorf("unknown CreditBalance edge %s", name)
  16399. }
  16400. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  16401. type CreditUsageMutation struct {
  16402. config
  16403. op Op
  16404. typ string
  16405. id *uint64
  16406. created_at *time.Time
  16407. updated_at *time.Time
  16408. deleted_at *time.Time
  16409. user_id *string
  16410. number *float64
  16411. addnumber *float64
  16412. pay_number *float64
  16413. addpay_number *float64
  16414. before_number *float64
  16415. addbefore_number *float64
  16416. after_number *float64
  16417. addafter_number *float64
  16418. pay_method *int
  16419. addpay_method *int
  16420. status *int
  16421. addstatus *int
  16422. ntype *int
  16423. addntype *int
  16424. table *string
  16425. organization_id *uint64
  16426. addorganization_id *int64
  16427. nid *uint64
  16428. addnid *int64
  16429. reason *string
  16430. operator *string
  16431. clearedFields map[string]struct{}
  16432. done bool
  16433. oldValue func(context.Context) (*CreditUsage, error)
  16434. predicates []predicate.CreditUsage
  16435. }
  16436. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  16437. // creditusageOption allows management of the mutation configuration using functional options.
  16438. type creditusageOption func(*CreditUsageMutation)
  16439. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  16440. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  16441. m := &CreditUsageMutation{
  16442. config: c,
  16443. op: op,
  16444. typ: TypeCreditUsage,
  16445. clearedFields: make(map[string]struct{}),
  16446. }
  16447. for _, opt := range opts {
  16448. opt(m)
  16449. }
  16450. return m
  16451. }
  16452. // withCreditUsageID sets the ID field of the mutation.
  16453. func withCreditUsageID(id uint64) creditusageOption {
  16454. return func(m *CreditUsageMutation) {
  16455. var (
  16456. err error
  16457. once sync.Once
  16458. value *CreditUsage
  16459. )
  16460. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  16461. once.Do(func() {
  16462. if m.done {
  16463. err = errors.New("querying old values post mutation is not allowed")
  16464. } else {
  16465. value, err = m.Client().CreditUsage.Get(ctx, id)
  16466. }
  16467. })
  16468. return value, err
  16469. }
  16470. m.id = &id
  16471. }
  16472. }
  16473. // withCreditUsage sets the old CreditUsage of the mutation.
  16474. func withCreditUsage(node *CreditUsage) creditusageOption {
  16475. return func(m *CreditUsageMutation) {
  16476. m.oldValue = func(context.Context) (*CreditUsage, error) {
  16477. return node, nil
  16478. }
  16479. m.id = &node.ID
  16480. }
  16481. }
  16482. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16483. // executed in a transaction (ent.Tx), a transactional client is returned.
  16484. func (m CreditUsageMutation) Client() *Client {
  16485. client := &Client{config: m.config}
  16486. client.init()
  16487. return client
  16488. }
  16489. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16490. // it returns an error otherwise.
  16491. func (m CreditUsageMutation) Tx() (*Tx, error) {
  16492. if _, ok := m.driver.(*txDriver); !ok {
  16493. return nil, errors.New("ent: mutation is not running in a transaction")
  16494. }
  16495. tx := &Tx{config: m.config}
  16496. tx.init()
  16497. return tx, nil
  16498. }
  16499. // SetID sets the value of the id field. Note that this
  16500. // operation is only accepted on creation of CreditUsage entities.
  16501. func (m *CreditUsageMutation) SetID(id uint64) {
  16502. m.id = &id
  16503. }
  16504. // ID returns the ID value in the mutation. Note that the ID is only available
  16505. // if it was provided to the builder or after it was returned from the database.
  16506. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  16507. if m.id == nil {
  16508. return
  16509. }
  16510. return *m.id, true
  16511. }
  16512. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16513. // That means, if the mutation is applied within a transaction with an isolation level such
  16514. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16515. // or updated by the mutation.
  16516. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16517. switch {
  16518. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16519. id, exists := m.ID()
  16520. if exists {
  16521. return []uint64{id}, nil
  16522. }
  16523. fallthrough
  16524. case m.op.Is(OpUpdate | OpDelete):
  16525. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  16526. default:
  16527. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16528. }
  16529. }
  16530. // SetCreatedAt sets the "created_at" field.
  16531. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  16532. m.created_at = &t
  16533. }
  16534. // CreatedAt returns the value of the "created_at" field in the mutation.
  16535. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  16536. v := m.created_at
  16537. if v == nil {
  16538. return
  16539. }
  16540. return *v, true
  16541. }
  16542. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  16543. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16545. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16546. if !m.op.Is(OpUpdateOne) {
  16547. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16548. }
  16549. if m.id == nil || m.oldValue == nil {
  16550. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16551. }
  16552. oldValue, err := m.oldValue(ctx)
  16553. if err != nil {
  16554. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16555. }
  16556. return oldValue.CreatedAt, nil
  16557. }
  16558. // ResetCreatedAt resets all changes to the "created_at" field.
  16559. func (m *CreditUsageMutation) ResetCreatedAt() {
  16560. m.created_at = nil
  16561. }
  16562. // SetUpdatedAt sets the "updated_at" field.
  16563. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  16564. m.updated_at = &t
  16565. }
  16566. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16567. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  16568. v := m.updated_at
  16569. if v == nil {
  16570. return
  16571. }
  16572. return *v, true
  16573. }
  16574. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  16575. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16577. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16578. if !m.op.Is(OpUpdateOne) {
  16579. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16580. }
  16581. if m.id == nil || m.oldValue == nil {
  16582. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16583. }
  16584. oldValue, err := m.oldValue(ctx)
  16585. if err != nil {
  16586. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16587. }
  16588. return oldValue.UpdatedAt, nil
  16589. }
  16590. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16591. func (m *CreditUsageMutation) ResetUpdatedAt() {
  16592. m.updated_at = nil
  16593. }
  16594. // SetDeletedAt sets the "deleted_at" field.
  16595. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  16596. m.deleted_at = &t
  16597. }
  16598. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16599. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  16600. v := m.deleted_at
  16601. if v == nil {
  16602. return
  16603. }
  16604. return *v, true
  16605. }
  16606. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  16607. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16609. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16610. if !m.op.Is(OpUpdateOne) {
  16611. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16612. }
  16613. if m.id == nil || m.oldValue == nil {
  16614. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16615. }
  16616. oldValue, err := m.oldValue(ctx)
  16617. if err != nil {
  16618. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16619. }
  16620. return oldValue.DeletedAt, nil
  16621. }
  16622. // ClearDeletedAt clears the value of the "deleted_at" field.
  16623. func (m *CreditUsageMutation) ClearDeletedAt() {
  16624. m.deleted_at = nil
  16625. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  16626. }
  16627. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16628. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  16629. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  16630. return ok
  16631. }
  16632. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16633. func (m *CreditUsageMutation) ResetDeletedAt() {
  16634. m.deleted_at = nil
  16635. delete(m.clearedFields, creditusage.FieldDeletedAt)
  16636. }
  16637. // SetUserID sets the "user_id" field.
  16638. func (m *CreditUsageMutation) SetUserID(s string) {
  16639. m.user_id = &s
  16640. }
  16641. // UserID returns the value of the "user_id" field in the mutation.
  16642. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  16643. v := m.user_id
  16644. if v == nil {
  16645. return
  16646. }
  16647. return *v, true
  16648. }
  16649. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  16650. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16652. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  16653. if !m.op.Is(OpUpdateOne) {
  16654. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16655. }
  16656. if m.id == nil || m.oldValue == nil {
  16657. return v, errors.New("OldUserID requires an ID field in the mutation")
  16658. }
  16659. oldValue, err := m.oldValue(ctx)
  16660. if err != nil {
  16661. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16662. }
  16663. return oldValue.UserID, nil
  16664. }
  16665. // ClearUserID clears the value of the "user_id" field.
  16666. func (m *CreditUsageMutation) ClearUserID() {
  16667. m.user_id = nil
  16668. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  16669. }
  16670. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16671. func (m *CreditUsageMutation) UserIDCleared() bool {
  16672. _, ok := m.clearedFields[creditusage.FieldUserID]
  16673. return ok
  16674. }
  16675. // ResetUserID resets all changes to the "user_id" field.
  16676. func (m *CreditUsageMutation) ResetUserID() {
  16677. m.user_id = nil
  16678. delete(m.clearedFields, creditusage.FieldUserID)
  16679. }
  16680. // SetNumber sets the "number" field.
  16681. func (m *CreditUsageMutation) SetNumber(f float64) {
  16682. m.number = &f
  16683. m.addnumber = nil
  16684. }
  16685. // Number returns the value of the "number" field in the mutation.
  16686. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  16687. v := m.number
  16688. if v == nil {
  16689. return
  16690. }
  16691. return *v, true
  16692. }
  16693. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  16694. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16696. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  16697. if !m.op.Is(OpUpdateOne) {
  16698. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  16699. }
  16700. if m.id == nil || m.oldValue == nil {
  16701. return v, errors.New("OldNumber requires an ID field in the mutation")
  16702. }
  16703. oldValue, err := m.oldValue(ctx)
  16704. if err != nil {
  16705. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  16706. }
  16707. return oldValue.Number, nil
  16708. }
  16709. // AddNumber adds f to the "number" field.
  16710. func (m *CreditUsageMutation) AddNumber(f float64) {
  16711. if m.addnumber != nil {
  16712. *m.addnumber += f
  16713. } else {
  16714. m.addnumber = &f
  16715. }
  16716. }
  16717. // AddedNumber returns the value that was added to the "number" field in this mutation.
  16718. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  16719. v := m.addnumber
  16720. if v == nil {
  16721. return
  16722. }
  16723. return *v, true
  16724. }
  16725. // ResetNumber resets all changes to the "number" field.
  16726. func (m *CreditUsageMutation) ResetNumber() {
  16727. m.number = nil
  16728. m.addnumber = nil
  16729. }
  16730. // SetPayNumber sets the "pay_number" field.
  16731. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  16732. m.pay_number = &f
  16733. m.addpay_number = nil
  16734. }
  16735. // PayNumber returns the value of the "pay_number" field in the mutation.
  16736. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  16737. v := m.pay_number
  16738. if v == nil {
  16739. return
  16740. }
  16741. return *v, true
  16742. }
  16743. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  16744. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16746. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  16747. if !m.op.Is(OpUpdateOne) {
  16748. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  16749. }
  16750. if m.id == nil || m.oldValue == nil {
  16751. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  16752. }
  16753. oldValue, err := m.oldValue(ctx)
  16754. if err != nil {
  16755. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  16756. }
  16757. return oldValue.PayNumber, nil
  16758. }
  16759. // AddPayNumber adds f to the "pay_number" field.
  16760. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  16761. if m.addpay_number != nil {
  16762. *m.addpay_number += f
  16763. } else {
  16764. m.addpay_number = &f
  16765. }
  16766. }
  16767. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  16768. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  16769. v := m.addpay_number
  16770. if v == nil {
  16771. return
  16772. }
  16773. return *v, true
  16774. }
  16775. // ClearPayNumber clears the value of the "pay_number" field.
  16776. func (m *CreditUsageMutation) ClearPayNumber() {
  16777. m.pay_number = nil
  16778. m.addpay_number = nil
  16779. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  16780. }
  16781. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  16782. func (m *CreditUsageMutation) PayNumberCleared() bool {
  16783. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  16784. return ok
  16785. }
  16786. // ResetPayNumber resets all changes to the "pay_number" field.
  16787. func (m *CreditUsageMutation) ResetPayNumber() {
  16788. m.pay_number = nil
  16789. m.addpay_number = nil
  16790. delete(m.clearedFields, creditusage.FieldPayNumber)
  16791. }
  16792. // SetBeforeNumber sets the "before_number" field.
  16793. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  16794. m.before_number = &f
  16795. m.addbefore_number = nil
  16796. }
  16797. // BeforeNumber returns the value of the "before_number" field in the mutation.
  16798. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  16799. v := m.before_number
  16800. if v == nil {
  16801. return
  16802. }
  16803. return *v, true
  16804. }
  16805. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  16806. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16808. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  16809. if !m.op.Is(OpUpdateOne) {
  16810. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  16811. }
  16812. if m.id == nil || m.oldValue == nil {
  16813. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  16814. }
  16815. oldValue, err := m.oldValue(ctx)
  16816. if err != nil {
  16817. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  16818. }
  16819. return oldValue.BeforeNumber, nil
  16820. }
  16821. // AddBeforeNumber adds f to the "before_number" field.
  16822. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  16823. if m.addbefore_number != nil {
  16824. *m.addbefore_number += f
  16825. } else {
  16826. m.addbefore_number = &f
  16827. }
  16828. }
  16829. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  16830. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  16831. v := m.addbefore_number
  16832. if v == nil {
  16833. return
  16834. }
  16835. return *v, true
  16836. }
  16837. // ClearBeforeNumber clears the value of the "before_number" field.
  16838. func (m *CreditUsageMutation) ClearBeforeNumber() {
  16839. m.before_number = nil
  16840. m.addbefore_number = nil
  16841. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  16842. }
  16843. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  16844. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  16845. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  16846. return ok
  16847. }
  16848. // ResetBeforeNumber resets all changes to the "before_number" field.
  16849. func (m *CreditUsageMutation) ResetBeforeNumber() {
  16850. m.before_number = nil
  16851. m.addbefore_number = nil
  16852. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  16853. }
  16854. // SetAfterNumber sets the "after_number" field.
  16855. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  16856. m.after_number = &f
  16857. m.addafter_number = nil
  16858. }
  16859. // AfterNumber returns the value of the "after_number" field in the mutation.
  16860. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  16861. v := m.after_number
  16862. if v == nil {
  16863. return
  16864. }
  16865. return *v, true
  16866. }
  16867. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  16868. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16870. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  16871. if !m.op.Is(OpUpdateOne) {
  16872. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  16873. }
  16874. if m.id == nil || m.oldValue == nil {
  16875. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  16876. }
  16877. oldValue, err := m.oldValue(ctx)
  16878. if err != nil {
  16879. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  16880. }
  16881. return oldValue.AfterNumber, nil
  16882. }
  16883. // AddAfterNumber adds f to the "after_number" field.
  16884. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  16885. if m.addafter_number != nil {
  16886. *m.addafter_number += f
  16887. } else {
  16888. m.addafter_number = &f
  16889. }
  16890. }
  16891. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  16892. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  16893. v := m.addafter_number
  16894. if v == nil {
  16895. return
  16896. }
  16897. return *v, true
  16898. }
  16899. // ClearAfterNumber clears the value of the "after_number" field.
  16900. func (m *CreditUsageMutation) ClearAfterNumber() {
  16901. m.after_number = nil
  16902. m.addafter_number = nil
  16903. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  16904. }
  16905. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  16906. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  16907. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  16908. return ok
  16909. }
  16910. // ResetAfterNumber resets all changes to the "after_number" field.
  16911. func (m *CreditUsageMutation) ResetAfterNumber() {
  16912. m.after_number = nil
  16913. m.addafter_number = nil
  16914. delete(m.clearedFields, creditusage.FieldAfterNumber)
  16915. }
  16916. // SetPayMethod sets the "pay_method" field.
  16917. func (m *CreditUsageMutation) SetPayMethod(i int) {
  16918. m.pay_method = &i
  16919. m.addpay_method = nil
  16920. }
  16921. // PayMethod returns the value of the "pay_method" field in the mutation.
  16922. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  16923. v := m.pay_method
  16924. if v == nil {
  16925. return
  16926. }
  16927. return *v, true
  16928. }
  16929. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  16930. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16932. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  16933. if !m.op.Is(OpUpdateOne) {
  16934. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  16935. }
  16936. if m.id == nil || m.oldValue == nil {
  16937. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  16938. }
  16939. oldValue, err := m.oldValue(ctx)
  16940. if err != nil {
  16941. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  16942. }
  16943. return oldValue.PayMethod, nil
  16944. }
  16945. // AddPayMethod adds i to the "pay_method" field.
  16946. func (m *CreditUsageMutation) AddPayMethod(i int) {
  16947. if m.addpay_method != nil {
  16948. *m.addpay_method += i
  16949. } else {
  16950. m.addpay_method = &i
  16951. }
  16952. }
  16953. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  16954. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  16955. v := m.addpay_method
  16956. if v == nil {
  16957. return
  16958. }
  16959. return *v, true
  16960. }
  16961. // ClearPayMethod clears the value of the "pay_method" field.
  16962. func (m *CreditUsageMutation) ClearPayMethod() {
  16963. m.pay_method = nil
  16964. m.addpay_method = nil
  16965. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  16966. }
  16967. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  16968. func (m *CreditUsageMutation) PayMethodCleared() bool {
  16969. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  16970. return ok
  16971. }
  16972. // ResetPayMethod resets all changes to the "pay_method" field.
  16973. func (m *CreditUsageMutation) ResetPayMethod() {
  16974. m.pay_method = nil
  16975. m.addpay_method = nil
  16976. delete(m.clearedFields, creditusage.FieldPayMethod)
  16977. }
  16978. // SetStatus sets the "status" field.
  16979. func (m *CreditUsageMutation) SetStatus(i int) {
  16980. m.status = &i
  16981. m.addstatus = nil
  16982. }
  16983. // Status returns the value of the "status" field in the mutation.
  16984. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  16985. v := m.status
  16986. if v == nil {
  16987. return
  16988. }
  16989. return *v, true
  16990. }
  16991. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  16992. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16994. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  16995. if !m.op.Is(OpUpdateOne) {
  16996. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16997. }
  16998. if m.id == nil || m.oldValue == nil {
  16999. return v, errors.New("OldStatus requires an ID field in the mutation")
  17000. }
  17001. oldValue, err := m.oldValue(ctx)
  17002. if err != nil {
  17003. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17004. }
  17005. return oldValue.Status, nil
  17006. }
  17007. // AddStatus adds i to the "status" field.
  17008. func (m *CreditUsageMutation) AddStatus(i int) {
  17009. if m.addstatus != nil {
  17010. *m.addstatus += i
  17011. } else {
  17012. m.addstatus = &i
  17013. }
  17014. }
  17015. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17016. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  17017. v := m.addstatus
  17018. if v == nil {
  17019. return
  17020. }
  17021. return *v, true
  17022. }
  17023. // ClearStatus clears the value of the "status" field.
  17024. func (m *CreditUsageMutation) ClearStatus() {
  17025. m.status = nil
  17026. m.addstatus = nil
  17027. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  17028. }
  17029. // StatusCleared returns if the "status" field was cleared in this mutation.
  17030. func (m *CreditUsageMutation) StatusCleared() bool {
  17031. _, ok := m.clearedFields[creditusage.FieldStatus]
  17032. return ok
  17033. }
  17034. // ResetStatus resets all changes to the "status" field.
  17035. func (m *CreditUsageMutation) ResetStatus() {
  17036. m.status = nil
  17037. m.addstatus = nil
  17038. delete(m.clearedFields, creditusage.FieldStatus)
  17039. }
  17040. // SetNtype sets the "ntype" field.
  17041. func (m *CreditUsageMutation) SetNtype(i int) {
  17042. m.ntype = &i
  17043. m.addntype = nil
  17044. }
  17045. // Ntype returns the value of the "ntype" field in the mutation.
  17046. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  17047. v := m.ntype
  17048. if v == nil {
  17049. return
  17050. }
  17051. return *v, true
  17052. }
  17053. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  17054. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17056. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  17057. if !m.op.Is(OpUpdateOne) {
  17058. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  17059. }
  17060. if m.id == nil || m.oldValue == nil {
  17061. return v, errors.New("OldNtype requires an ID field in the mutation")
  17062. }
  17063. oldValue, err := m.oldValue(ctx)
  17064. if err != nil {
  17065. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  17066. }
  17067. return oldValue.Ntype, nil
  17068. }
  17069. // AddNtype adds i to the "ntype" field.
  17070. func (m *CreditUsageMutation) AddNtype(i int) {
  17071. if m.addntype != nil {
  17072. *m.addntype += i
  17073. } else {
  17074. m.addntype = &i
  17075. }
  17076. }
  17077. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  17078. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  17079. v := m.addntype
  17080. if v == nil {
  17081. return
  17082. }
  17083. return *v, true
  17084. }
  17085. // ResetNtype resets all changes to the "ntype" field.
  17086. func (m *CreditUsageMutation) ResetNtype() {
  17087. m.ntype = nil
  17088. m.addntype = nil
  17089. }
  17090. // SetTable sets the "table" field.
  17091. func (m *CreditUsageMutation) SetTable(s string) {
  17092. m.table = &s
  17093. }
  17094. // Table returns the value of the "table" field in the mutation.
  17095. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  17096. v := m.table
  17097. if v == nil {
  17098. return
  17099. }
  17100. return *v, true
  17101. }
  17102. // OldTable returns the old "table" field's value of the CreditUsage entity.
  17103. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17105. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  17106. if !m.op.Is(OpUpdateOne) {
  17107. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  17108. }
  17109. if m.id == nil || m.oldValue == nil {
  17110. return v, errors.New("OldTable requires an ID field in the mutation")
  17111. }
  17112. oldValue, err := m.oldValue(ctx)
  17113. if err != nil {
  17114. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  17115. }
  17116. return oldValue.Table, nil
  17117. }
  17118. // ResetTable resets all changes to the "table" field.
  17119. func (m *CreditUsageMutation) ResetTable() {
  17120. m.table = nil
  17121. }
  17122. // SetOrganizationID sets the "organization_id" field.
  17123. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  17124. m.organization_id = &u
  17125. m.addorganization_id = nil
  17126. }
  17127. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17128. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  17129. v := m.organization_id
  17130. if v == nil {
  17131. return
  17132. }
  17133. return *v, true
  17134. }
  17135. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  17136. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17138. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17139. if !m.op.Is(OpUpdateOne) {
  17140. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17141. }
  17142. if m.id == nil || m.oldValue == nil {
  17143. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17144. }
  17145. oldValue, err := m.oldValue(ctx)
  17146. if err != nil {
  17147. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17148. }
  17149. return oldValue.OrganizationID, nil
  17150. }
  17151. // AddOrganizationID adds u to the "organization_id" field.
  17152. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  17153. if m.addorganization_id != nil {
  17154. *m.addorganization_id += u
  17155. } else {
  17156. m.addorganization_id = &u
  17157. }
  17158. }
  17159. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17160. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  17161. v := m.addorganization_id
  17162. if v == nil {
  17163. return
  17164. }
  17165. return *v, true
  17166. }
  17167. // ClearOrganizationID clears the value of the "organization_id" field.
  17168. func (m *CreditUsageMutation) ClearOrganizationID() {
  17169. m.organization_id = nil
  17170. m.addorganization_id = nil
  17171. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  17172. }
  17173. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17174. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  17175. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  17176. return ok
  17177. }
  17178. // ResetOrganizationID resets all changes to the "organization_id" field.
  17179. func (m *CreditUsageMutation) ResetOrganizationID() {
  17180. m.organization_id = nil
  17181. m.addorganization_id = nil
  17182. delete(m.clearedFields, creditusage.FieldOrganizationID)
  17183. }
  17184. // SetNid sets the "nid" field.
  17185. func (m *CreditUsageMutation) SetNid(u uint64) {
  17186. m.nid = &u
  17187. m.addnid = nil
  17188. }
  17189. // Nid returns the value of the "nid" field in the mutation.
  17190. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  17191. v := m.nid
  17192. if v == nil {
  17193. return
  17194. }
  17195. return *v, true
  17196. }
  17197. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  17198. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17200. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  17201. if !m.op.Is(OpUpdateOne) {
  17202. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  17203. }
  17204. if m.id == nil || m.oldValue == nil {
  17205. return v, errors.New("OldNid requires an ID field in the mutation")
  17206. }
  17207. oldValue, err := m.oldValue(ctx)
  17208. if err != nil {
  17209. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  17210. }
  17211. return oldValue.Nid, nil
  17212. }
  17213. // AddNid adds u to the "nid" field.
  17214. func (m *CreditUsageMutation) AddNid(u int64) {
  17215. if m.addnid != nil {
  17216. *m.addnid += u
  17217. } else {
  17218. m.addnid = &u
  17219. }
  17220. }
  17221. // AddedNid returns the value that was added to the "nid" field in this mutation.
  17222. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  17223. v := m.addnid
  17224. if v == nil {
  17225. return
  17226. }
  17227. return *v, true
  17228. }
  17229. // ResetNid resets all changes to the "nid" field.
  17230. func (m *CreditUsageMutation) ResetNid() {
  17231. m.nid = nil
  17232. m.addnid = nil
  17233. }
  17234. // SetReason sets the "reason" field.
  17235. func (m *CreditUsageMutation) SetReason(s string) {
  17236. m.reason = &s
  17237. }
  17238. // Reason returns the value of the "reason" field in the mutation.
  17239. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  17240. v := m.reason
  17241. if v == nil {
  17242. return
  17243. }
  17244. return *v, true
  17245. }
  17246. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  17247. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17249. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  17250. if !m.op.Is(OpUpdateOne) {
  17251. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  17252. }
  17253. if m.id == nil || m.oldValue == nil {
  17254. return v, errors.New("OldReason requires an ID field in the mutation")
  17255. }
  17256. oldValue, err := m.oldValue(ctx)
  17257. if err != nil {
  17258. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  17259. }
  17260. return oldValue.Reason, nil
  17261. }
  17262. // ResetReason resets all changes to the "reason" field.
  17263. func (m *CreditUsageMutation) ResetReason() {
  17264. m.reason = nil
  17265. }
  17266. // SetOperator sets the "operator" field.
  17267. func (m *CreditUsageMutation) SetOperator(s string) {
  17268. m.operator = &s
  17269. }
  17270. // Operator returns the value of the "operator" field in the mutation.
  17271. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  17272. v := m.operator
  17273. if v == nil {
  17274. return
  17275. }
  17276. return *v, true
  17277. }
  17278. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  17279. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17281. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  17282. if !m.op.Is(OpUpdateOne) {
  17283. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  17284. }
  17285. if m.id == nil || m.oldValue == nil {
  17286. return v, errors.New("OldOperator requires an ID field in the mutation")
  17287. }
  17288. oldValue, err := m.oldValue(ctx)
  17289. if err != nil {
  17290. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  17291. }
  17292. return oldValue.Operator, nil
  17293. }
  17294. // ResetOperator resets all changes to the "operator" field.
  17295. func (m *CreditUsageMutation) ResetOperator() {
  17296. m.operator = nil
  17297. }
  17298. // Where appends a list predicates to the CreditUsageMutation builder.
  17299. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  17300. m.predicates = append(m.predicates, ps...)
  17301. }
  17302. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  17303. // users can use type-assertion to append predicates that do not depend on any generated package.
  17304. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  17305. p := make([]predicate.CreditUsage, len(ps))
  17306. for i := range ps {
  17307. p[i] = ps[i]
  17308. }
  17309. m.Where(p...)
  17310. }
  17311. // Op returns the operation name.
  17312. func (m *CreditUsageMutation) Op() Op {
  17313. return m.op
  17314. }
  17315. // SetOp allows setting the mutation operation.
  17316. func (m *CreditUsageMutation) SetOp(op Op) {
  17317. m.op = op
  17318. }
  17319. // Type returns the node type of this mutation (CreditUsage).
  17320. func (m *CreditUsageMutation) Type() string {
  17321. return m.typ
  17322. }
  17323. // Fields returns all fields that were changed during this mutation. Note that in
  17324. // order to get all numeric fields that were incremented/decremented, call
  17325. // AddedFields().
  17326. func (m *CreditUsageMutation) Fields() []string {
  17327. fields := make([]string, 0, 16)
  17328. if m.created_at != nil {
  17329. fields = append(fields, creditusage.FieldCreatedAt)
  17330. }
  17331. if m.updated_at != nil {
  17332. fields = append(fields, creditusage.FieldUpdatedAt)
  17333. }
  17334. if m.deleted_at != nil {
  17335. fields = append(fields, creditusage.FieldDeletedAt)
  17336. }
  17337. if m.user_id != nil {
  17338. fields = append(fields, creditusage.FieldUserID)
  17339. }
  17340. if m.number != nil {
  17341. fields = append(fields, creditusage.FieldNumber)
  17342. }
  17343. if m.pay_number != nil {
  17344. fields = append(fields, creditusage.FieldPayNumber)
  17345. }
  17346. if m.before_number != nil {
  17347. fields = append(fields, creditusage.FieldBeforeNumber)
  17348. }
  17349. if m.after_number != nil {
  17350. fields = append(fields, creditusage.FieldAfterNumber)
  17351. }
  17352. if m.pay_method != nil {
  17353. fields = append(fields, creditusage.FieldPayMethod)
  17354. }
  17355. if m.status != nil {
  17356. fields = append(fields, creditusage.FieldStatus)
  17357. }
  17358. if m.ntype != nil {
  17359. fields = append(fields, creditusage.FieldNtype)
  17360. }
  17361. if m.table != nil {
  17362. fields = append(fields, creditusage.FieldTable)
  17363. }
  17364. if m.organization_id != nil {
  17365. fields = append(fields, creditusage.FieldOrganizationID)
  17366. }
  17367. if m.nid != nil {
  17368. fields = append(fields, creditusage.FieldNid)
  17369. }
  17370. if m.reason != nil {
  17371. fields = append(fields, creditusage.FieldReason)
  17372. }
  17373. if m.operator != nil {
  17374. fields = append(fields, creditusage.FieldOperator)
  17375. }
  17376. return fields
  17377. }
  17378. // Field returns the value of a field with the given name. The second boolean
  17379. // return value indicates that this field was not set, or was not defined in the
  17380. // schema.
  17381. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  17382. switch name {
  17383. case creditusage.FieldCreatedAt:
  17384. return m.CreatedAt()
  17385. case creditusage.FieldUpdatedAt:
  17386. return m.UpdatedAt()
  17387. case creditusage.FieldDeletedAt:
  17388. return m.DeletedAt()
  17389. case creditusage.FieldUserID:
  17390. return m.UserID()
  17391. case creditusage.FieldNumber:
  17392. return m.Number()
  17393. case creditusage.FieldPayNumber:
  17394. return m.PayNumber()
  17395. case creditusage.FieldBeforeNumber:
  17396. return m.BeforeNumber()
  17397. case creditusage.FieldAfterNumber:
  17398. return m.AfterNumber()
  17399. case creditusage.FieldPayMethod:
  17400. return m.PayMethod()
  17401. case creditusage.FieldStatus:
  17402. return m.Status()
  17403. case creditusage.FieldNtype:
  17404. return m.Ntype()
  17405. case creditusage.FieldTable:
  17406. return m.Table()
  17407. case creditusage.FieldOrganizationID:
  17408. return m.OrganizationID()
  17409. case creditusage.FieldNid:
  17410. return m.Nid()
  17411. case creditusage.FieldReason:
  17412. return m.Reason()
  17413. case creditusage.FieldOperator:
  17414. return m.Operator()
  17415. }
  17416. return nil, false
  17417. }
  17418. // OldField returns the old value of the field from the database. An error is
  17419. // returned if the mutation operation is not UpdateOne, or the query to the
  17420. // database failed.
  17421. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17422. switch name {
  17423. case creditusage.FieldCreatedAt:
  17424. return m.OldCreatedAt(ctx)
  17425. case creditusage.FieldUpdatedAt:
  17426. return m.OldUpdatedAt(ctx)
  17427. case creditusage.FieldDeletedAt:
  17428. return m.OldDeletedAt(ctx)
  17429. case creditusage.FieldUserID:
  17430. return m.OldUserID(ctx)
  17431. case creditusage.FieldNumber:
  17432. return m.OldNumber(ctx)
  17433. case creditusage.FieldPayNumber:
  17434. return m.OldPayNumber(ctx)
  17435. case creditusage.FieldBeforeNumber:
  17436. return m.OldBeforeNumber(ctx)
  17437. case creditusage.FieldAfterNumber:
  17438. return m.OldAfterNumber(ctx)
  17439. case creditusage.FieldPayMethod:
  17440. return m.OldPayMethod(ctx)
  17441. case creditusage.FieldStatus:
  17442. return m.OldStatus(ctx)
  17443. case creditusage.FieldNtype:
  17444. return m.OldNtype(ctx)
  17445. case creditusage.FieldTable:
  17446. return m.OldTable(ctx)
  17447. case creditusage.FieldOrganizationID:
  17448. return m.OldOrganizationID(ctx)
  17449. case creditusage.FieldNid:
  17450. return m.OldNid(ctx)
  17451. case creditusage.FieldReason:
  17452. return m.OldReason(ctx)
  17453. case creditusage.FieldOperator:
  17454. return m.OldOperator(ctx)
  17455. }
  17456. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  17457. }
  17458. // SetField sets the value of a field with the given name. It returns an error if
  17459. // the field is not defined in the schema, or if the type mismatched the field
  17460. // type.
  17461. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  17462. switch name {
  17463. case creditusage.FieldCreatedAt:
  17464. v, ok := value.(time.Time)
  17465. if !ok {
  17466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17467. }
  17468. m.SetCreatedAt(v)
  17469. return nil
  17470. case creditusage.FieldUpdatedAt:
  17471. v, ok := value.(time.Time)
  17472. if !ok {
  17473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17474. }
  17475. m.SetUpdatedAt(v)
  17476. return nil
  17477. case creditusage.FieldDeletedAt:
  17478. v, ok := value.(time.Time)
  17479. if !ok {
  17480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17481. }
  17482. m.SetDeletedAt(v)
  17483. return nil
  17484. case creditusage.FieldUserID:
  17485. v, ok := value.(string)
  17486. if !ok {
  17487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17488. }
  17489. m.SetUserID(v)
  17490. return nil
  17491. case creditusage.FieldNumber:
  17492. v, ok := value.(float64)
  17493. if !ok {
  17494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17495. }
  17496. m.SetNumber(v)
  17497. return nil
  17498. case creditusage.FieldPayNumber:
  17499. v, ok := value.(float64)
  17500. if !ok {
  17501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17502. }
  17503. m.SetPayNumber(v)
  17504. return nil
  17505. case creditusage.FieldBeforeNumber:
  17506. v, ok := value.(float64)
  17507. if !ok {
  17508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17509. }
  17510. m.SetBeforeNumber(v)
  17511. return nil
  17512. case creditusage.FieldAfterNumber:
  17513. v, ok := value.(float64)
  17514. if !ok {
  17515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17516. }
  17517. m.SetAfterNumber(v)
  17518. return nil
  17519. case creditusage.FieldPayMethod:
  17520. v, ok := value.(int)
  17521. if !ok {
  17522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17523. }
  17524. m.SetPayMethod(v)
  17525. return nil
  17526. case creditusage.FieldStatus:
  17527. v, ok := value.(int)
  17528. if !ok {
  17529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17530. }
  17531. m.SetStatus(v)
  17532. return nil
  17533. case creditusage.FieldNtype:
  17534. v, ok := value.(int)
  17535. if !ok {
  17536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17537. }
  17538. m.SetNtype(v)
  17539. return nil
  17540. case creditusage.FieldTable:
  17541. v, ok := value.(string)
  17542. if !ok {
  17543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17544. }
  17545. m.SetTable(v)
  17546. return nil
  17547. case creditusage.FieldOrganizationID:
  17548. v, ok := value.(uint64)
  17549. if !ok {
  17550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17551. }
  17552. m.SetOrganizationID(v)
  17553. return nil
  17554. case creditusage.FieldNid:
  17555. v, ok := value.(uint64)
  17556. if !ok {
  17557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17558. }
  17559. m.SetNid(v)
  17560. return nil
  17561. case creditusage.FieldReason:
  17562. v, ok := value.(string)
  17563. if !ok {
  17564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17565. }
  17566. m.SetReason(v)
  17567. return nil
  17568. case creditusage.FieldOperator:
  17569. v, ok := value.(string)
  17570. if !ok {
  17571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17572. }
  17573. m.SetOperator(v)
  17574. return nil
  17575. }
  17576. return fmt.Errorf("unknown CreditUsage field %s", name)
  17577. }
  17578. // AddedFields returns all numeric fields that were incremented/decremented during
  17579. // this mutation.
  17580. func (m *CreditUsageMutation) AddedFields() []string {
  17581. var fields []string
  17582. if m.addnumber != nil {
  17583. fields = append(fields, creditusage.FieldNumber)
  17584. }
  17585. if m.addpay_number != nil {
  17586. fields = append(fields, creditusage.FieldPayNumber)
  17587. }
  17588. if m.addbefore_number != nil {
  17589. fields = append(fields, creditusage.FieldBeforeNumber)
  17590. }
  17591. if m.addafter_number != nil {
  17592. fields = append(fields, creditusage.FieldAfterNumber)
  17593. }
  17594. if m.addpay_method != nil {
  17595. fields = append(fields, creditusage.FieldPayMethod)
  17596. }
  17597. if m.addstatus != nil {
  17598. fields = append(fields, creditusage.FieldStatus)
  17599. }
  17600. if m.addntype != nil {
  17601. fields = append(fields, creditusage.FieldNtype)
  17602. }
  17603. if m.addorganization_id != nil {
  17604. fields = append(fields, creditusage.FieldOrganizationID)
  17605. }
  17606. if m.addnid != nil {
  17607. fields = append(fields, creditusage.FieldNid)
  17608. }
  17609. return fields
  17610. }
  17611. // AddedField returns the numeric value that was incremented/decremented on a field
  17612. // with the given name. The second boolean return value indicates that this field
  17613. // was not set, or was not defined in the schema.
  17614. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  17615. switch name {
  17616. case creditusage.FieldNumber:
  17617. return m.AddedNumber()
  17618. case creditusage.FieldPayNumber:
  17619. return m.AddedPayNumber()
  17620. case creditusage.FieldBeforeNumber:
  17621. return m.AddedBeforeNumber()
  17622. case creditusage.FieldAfterNumber:
  17623. return m.AddedAfterNumber()
  17624. case creditusage.FieldPayMethod:
  17625. return m.AddedPayMethod()
  17626. case creditusage.FieldStatus:
  17627. return m.AddedStatus()
  17628. case creditusage.FieldNtype:
  17629. return m.AddedNtype()
  17630. case creditusage.FieldOrganizationID:
  17631. return m.AddedOrganizationID()
  17632. case creditusage.FieldNid:
  17633. return m.AddedNid()
  17634. }
  17635. return nil, false
  17636. }
  17637. // AddField adds the value to the field with the given name. It returns an error if
  17638. // the field is not defined in the schema, or if the type mismatched the field
  17639. // type.
  17640. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  17641. switch name {
  17642. case creditusage.FieldNumber:
  17643. v, ok := value.(float64)
  17644. if !ok {
  17645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17646. }
  17647. m.AddNumber(v)
  17648. return nil
  17649. case creditusage.FieldPayNumber:
  17650. v, ok := value.(float64)
  17651. if !ok {
  17652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17653. }
  17654. m.AddPayNumber(v)
  17655. return nil
  17656. case creditusage.FieldBeforeNumber:
  17657. v, ok := value.(float64)
  17658. if !ok {
  17659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17660. }
  17661. m.AddBeforeNumber(v)
  17662. return nil
  17663. case creditusage.FieldAfterNumber:
  17664. v, ok := value.(float64)
  17665. if !ok {
  17666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17667. }
  17668. m.AddAfterNumber(v)
  17669. return nil
  17670. case creditusage.FieldPayMethod:
  17671. v, ok := value.(int)
  17672. if !ok {
  17673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17674. }
  17675. m.AddPayMethod(v)
  17676. return nil
  17677. case creditusage.FieldStatus:
  17678. v, ok := value.(int)
  17679. if !ok {
  17680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17681. }
  17682. m.AddStatus(v)
  17683. return nil
  17684. case creditusage.FieldNtype:
  17685. v, ok := value.(int)
  17686. if !ok {
  17687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17688. }
  17689. m.AddNtype(v)
  17690. return nil
  17691. case creditusage.FieldOrganizationID:
  17692. v, ok := value.(int64)
  17693. if !ok {
  17694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17695. }
  17696. m.AddOrganizationID(v)
  17697. return nil
  17698. case creditusage.FieldNid:
  17699. v, ok := value.(int64)
  17700. if !ok {
  17701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17702. }
  17703. m.AddNid(v)
  17704. return nil
  17705. }
  17706. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  17707. }
  17708. // ClearedFields returns all nullable fields that were cleared during this
  17709. // mutation.
  17710. func (m *CreditUsageMutation) ClearedFields() []string {
  17711. var fields []string
  17712. if m.FieldCleared(creditusage.FieldDeletedAt) {
  17713. fields = append(fields, creditusage.FieldDeletedAt)
  17714. }
  17715. if m.FieldCleared(creditusage.FieldUserID) {
  17716. fields = append(fields, creditusage.FieldUserID)
  17717. }
  17718. if m.FieldCleared(creditusage.FieldPayNumber) {
  17719. fields = append(fields, creditusage.FieldPayNumber)
  17720. }
  17721. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  17722. fields = append(fields, creditusage.FieldBeforeNumber)
  17723. }
  17724. if m.FieldCleared(creditusage.FieldAfterNumber) {
  17725. fields = append(fields, creditusage.FieldAfterNumber)
  17726. }
  17727. if m.FieldCleared(creditusage.FieldPayMethod) {
  17728. fields = append(fields, creditusage.FieldPayMethod)
  17729. }
  17730. if m.FieldCleared(creditusage.FieldStatus) {
  17731. fields = append(fields, creditusage.FieldStatus)
  17732. }
  17733. if m.FieldCleared(creditusage.FieldOrganizationID) {
  17734. fields = append(fields, creditusage.FieldOrganizationID)
  17735. }
  17736. return fields
  17737. }
  17738. // FieldCleared returns a boolean indicating if a field with the given name was
  17739. // cleared in this mutation.
  17740. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  17741. _, ok := m.clearedFields[name]
  17742. return ok
  17743. }
  17744. // ClearField clears the value of the field with the given name. It returns an
  17745. // error if the field is not defined in the schema.
  17746. func (m *CreditUsageMutation) ClearField(name string) error {
  17747. switch name {
  17748. case creditusage.FieldDeletedAt:
  17749. m.ClearDeletedAt()
  17750. return nil
  17751. case creditusage.FieldUserID:
  17752. m.ClearUserID()
  17753. return nil
  17754. case creditusage.FieldPayNumber:
  17755. m.ClearPayNumber()
  17756. return nil
  17757. case creditusage.FieldBeforeNumber:
  17758. m.ClearBeforeNumber()
  17759. return nil
  17760. case creditusage.FieldAfterNumber:
  17761. m.ClearAfterNumber()
  17762. return nil
  17763. case creditusage.FieldPayMethod:
  17764. m.ClearPayMethod()
  17765. return nil
  17766. case creditusage.FieldStatus:
  17767. m.ClearStatus()
  17768. return nil
  17769. case creditusage.FieldOrganizationID:
  17770. m.ClearOrganizationID()
  17771. return nil
  17772. }
  17773. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  17774. }
  17775. // ResetField resets all changes in the mutation for the field with the given name.
  17776. // It returns an error if the field is not defined in the schema.
  17777. func (m *CreditUsageMutation) ResetField(name string) error {
  17778. switch name {
  17779. case creditusage.FieldCreatedAt:
  17780. m.ResetCreatedAt()
  17781. return nil
  17782. case creditusage.FieldUpdatedAt:
  17783. m.ResetUpdatedAt()
  17784. return nil
  17785. case creditusage.FieldDeletedAt:
  17786. m.ResetDeletedAt()
  17787. return nil
  17788. case creditusage.FieldUserID:
  17789. m.ResetUserID()
  17790. return nil
  17791. case creditusage.FieldNumber:
  17792. m.ResetNumber()
  17793. return nil
  17794. case creditusage.FieldPayNumber:
  17795. m.ResetPayNumber()
  17796. return nil
  17797. case creditusage.FieldBeforeNumber:
  17798. m.ResetBeforeNumber()
  17799. return nil
  17800. case creditusage.FieldAfterNumber:
  17801. m.ResetAfterNumber()
  17802. return nil
  17803. case creditusage.FieldPayMethod:
  17804. m.ResetPayMethod()
  17805. return nil
  17806. case creditusage.FieldStatus:
  17807. m.ResetStatus()
  17808. return nil
  17809. case creditusage.FieldNtype:
  17810. m.ResetNtype()
  17811. return nil
  17812. case creditusage.FieldTable:
  17813. m.ResetTable()
  17814. return nil
  17815. case creditusage.FieldOrganizationID:
  17816. m.ResetOrganizationID()
  17817. return nil
  17818. case creditusage.FieldNid:
  17819. m.ResetNid()
  17820. return nil
  17821. case creditusage.FieldReason:
  17822. m.ResetReason()
  17823. return nil
  17824. case creditusage.FieldOperator:
  17825. m.ResetOperator()
  17826. return nil
  17827. }
  17828. return fmt.Errorf("unknown CreditUsage field %s", name)
  17829. }
  17830. // AddedEdges returns all edge names that were set/added in this mutation.
  17831. func (m *CreditUsageMutation) AddedEdges() []string {
  17832. edges := make([]string, 0, 0)
  17833. return edges
  17834. }
  17835. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17836. // name in this mutation.
  17837. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  17838. return nil
  17839. }
  17840. // RemovedEdges returns all edge names that were removed in this mutation.
  17841. func (m *CreditUsageMutation) RemovedEdges() []string {
  17842. edges := make([]string, 0, 0)
  17843. return edges
  17844. }
  17845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17846. // the given name in this mutation.
  17847. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  17848. return nil
  17849. }
  17850. // ClearedEdges returns all edge names that were cleared in this mutation.
  17851. func (m *CreditUsageMutation) ClearedEdges() []string {
  17852. edges := make([]string, 0, 0)
  17853. return edges
  17854. }
  17855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17856. // was cleared in this mutation.
  17857. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  17858. return false
  17859. }
  17860. // ClearEdge clears the value of the edge with the given name. It returns an error
  17861. // if that edge is not defined in the schema.
  17862. func (m *CreditUsageMutation) ClearEdge(name string) error {
  17863. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  17864. }
  17865. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17866. // It returns an error if the edge is not defined in the schema.
  17867. func (m *CreditUsageMutation) ResetEdge(name string) error {
  17868. return fmt.Errorf("unknown CreditUsage edge %s", name)
  17869. }
  17870. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  17871. type EmployeeMutation struct {
  17872. config
  17873. op Op
  17874. typ string
  17875. id *uint64
  17876. created_at *time.Time
  17877. updated_at *time.Time
  17878. deleted_at *time.Time
  17879. title *string
  17880. avatar *string
  17881. tags *string
  17882. hire_count *int
  17883. addhire_count *int
  17884. service_count *int
  17885. addservice_count *int
  17886. achievement_count *int
  17887. addachievement_count *int
  17888. intro *string
  17889. estimate *string
  17890. skill *string
  17891. ability_type *string
  17892. scene *string
  17893. switch_in *string
  17894. video_url *string
  17895. organization_id *uint64
  17896. addorganization_id *int64
  17897. category_id *uint64
  17898. addcategory_id *int64
  17899. api_base *string
  17900. api_key *string
  17901. ai_info *string
  17902. is_vip *int
  17903. addis_vip *int
  17904. chat_url *string
  17905. clearedFields map[string]struct{}
  17906. em_work_experiences map[uint64]struct{}
  17907. removedem_work_experiences map[uint64]struct{}
  17908. clearedem_work_experiences bool
  17909. em_tutorial map[uint64]struct{}
  17910. removedem_tutorial map[uint64]struct{}
  17911. clearedem_tutorial bool
  17912. done bool
  17913. oldValue func(context.Context) (*Employee, error)
  17914. predicates []predicate.Employee
  17915. }
  17916. var _ ent.Mutation = (*EmployeeMutation)(nil)
  17917. // employeeOption allows management of the mutation configuration using functional options.
  17918. type employeeOption func(*EmployeeMutation)
  17919. // newEmployeeMutation creates new mutation for the Employee entity.
  17920. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  17921. m := &EmployeeMutation{
  17922. config: c,
  17923. op: op,
  17924. typ: TypeEmployee,
  17925. clearedFields: make(map[string]struct{}),
  17926. }
  17927. for _, opt := range opts {
  17928. opt(m)
  17929. }
  17930. return m
  17931. }
  17932. // withEmployeeID sets the ID field of the mutation.
  17933. func withEmployeeID(id uint64) employeeOption {
  17934. return func(m *EmployeeMutation) {
  17935. var (
  17936. err error
  17937. once sync.Once
  17938. value *Employee
  17939. )
  17940. m.oldValue = func(ctx context.Context) (*Employee, error) {
  17941. once.Do(func() {
  17942. if m.done {
  17943. err = errors.New("querying old values post mutation is not allowed")
  17944. } else {
  17945. value, err = m.Client().Employee.Get(ctx, id)
  17946. }
  17947. })
  17948. return value, err
  17949. }
  17950. m.id = &id
  17951. }
  17952. }
  17953. // withEmployee sets the old Employee of the mutation.
  17954. func withEmployee(node *Employee) employeeOption {
  17955. return func(m *EmployeeMutation) {
  17956. m.oldValue = func(context.Context) (*Employee, error) {
  17957. return node, nil
  17958. }
  17959. m.id = &node.ID
  17960. }
  17961. }
  17962. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17963. // executed in a transaction (ent.Tx), a transactional client is returned.
  17964. func (m EmployeeMutation) Client() *Client {
  17965. client := &Client{config: m.config}
  17966. client.init()
  17967. return client
  17968. }
  17969. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17970. // it returns an error otherwise.
  17971. func (m EmployeeMutation) Tx() (*Tx, error) {
  17972. if _, ok := m.driver.(*txDriver); !ok {
  17973. return nil, errors.New("ent: mutation is not running in a transaction")
  17974. }
  17975. tx := &Tx{config: m.config}
  17976. tx.init()
  17977. return tx, nil
  17978. }
  17979. // SetID sets the value of the id field. Note that this
  17980. // operation is only accepted on creation of Employee entities.
  17981. func (m *EmployeeMutation) SetID(id uint64) {
  17982. m.id = &id
  17983. }
  17984. // ID returns the ID value in the mutation. Note that the ID is only available
  17985. // if it was provided to the builder or after it was returned from the database.
  17986. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  17987. if m.id == nil {
  17988. return
  17989. }
  17990. return *m.id, true
  17991. }
  17992. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17993. // That means, if the mutation is applied within a transaction with an isolation level such
  17994. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17995. // or updated by the mutation.
  17996. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17997. switch {
  17998. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17999. id, exists := m.ID()
  18000. if exists {
  18001. return []uint64{id}, nil
  18002. }
  18003. fallthrough
  18004. case m.op.Is(OpUpdate | OpDelete):
  18005. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  18006. default:
  18007. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18008. }
  18009. }
  18010. // SetCreatedAt sets the "created_at" field.
  18011. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  18012. m.created_at = &t
  18013. }
  18014. // CreatedAt returns the value of the "created_at" field in the mutation.
  18015. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  18016. v := m.created_at
  18017. if v == nil {
  18018. return
  18019. }
  18020. return *v, true
  18021. }
  18022. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  18023. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18025. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18026. if !m.op.Is(OpUpdateOne) {
  18027. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18028. }
  18029. if m.id == nil || m.oldValue == nil {
  18030. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18031. }
  18032. oldValue, err := m.oldValue(ctx)
  18033. if err != nil {
  18034. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18035. }
  18036. return oldValue.CreatedAt, nil
  18037. }
  18038. // ResetCreatedAt resets all changes to the "created_at" field.
  18039. func (m *EmployeeMutation) ResetCreatedAt() {
  18040. m.created_at = nil
  18041. }
  18042. // SetUpdatedAt sets the "updated_at" field.
  18043. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  18044. m.updated_at = &t
  18045. }
  18046. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18047. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  18048. v := m.updated_at
  18049. if v == nil {
  18050. return
  18051. }
  18052. return *v, true
  18053. }
  18054. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  18055. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18057. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18058. if !m.op.Is(OpUpdateOne) {
  18059. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18060. }
  18061. if m.id == nil || m.oldValue == nil {
  18062. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18063. }
  18064. oldValue, err := m.oldValue(ctx)
  18065. if err != nil {
  18066. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18067. }
  18068. return oldValue.UpdatedAt, nil
  18069. }
  18070. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18071. func (m *EmployeeMutation) ResetUpdatedAt() {
  18072. m.updated_at = nil
  18073. }
  18074. // SetDeletedAt sets the "deleted_at" field.
  18075. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  18076. m.deleted_at = &t
  18077. }
  18078. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18079. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  18080. v := m.deleted_at
  18081. if v == nil {
  18082. return
  18083. }
  18084. return *v, true
  18085. }
  18086. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  18087. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18089. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18090. if !m.op.Is(OpUpdateOne) {
  18091. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18092. }
  18093. if m.id == nil || m.oldValue == nil {
  18094. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18095. }
  18096. oldValue, err := m.oldValue(ctx)
  18097. if err != nil {
  18098. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18099. }
  18100. return oldValue.DeletedAt, nil
  18101. }
  18102. // ClearDeletedAt clears the value of the "deleted_at" field.
  18103. func (m *EmployeeMutation) ClearDeletedAt() {
  18104. m.deleted_at = nil
  18105. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  18106. }
  18107. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18108. func (m *EmployeeMutation) DeletedAtCleared() bool {
  18109. _, ok := m.clearedFields[employee.FieldDeletedAt]
  18110. return ok
  18111. }
  18112. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18113. func (m *EmployeeMutation) ResetDeletedAt() {
  18114. m.deleted_at = nil
  18115. delete(m.clearedFields, employee.FieldDeletedAt)
  18116. }
  18117. // SetTitle sets the "title" field.
  18118. func (m *EmployeeMutation) SetTitle(s string) {
  18119. m.title = &s
  18120. }
  18121. // Title returns the value of the "title" field in the mutation.
  18122. func (m *EmployeeMutation) Title() (r string, exists bool) {
  18123. v := m.title
  18124. if v == nil {
  18125. return
  18126. }
  18127. return *v, true
  18128. }
  18129. // OldTitle returns the old "title" field's value of the Employee entity.
  18130. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18132. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  18133. if !m.op.Is(OpUpdateOne) {
  18134. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18135. }
  18136. if m.id == nil || m.oldValue == nil {
  18137. return v, errors.New("OldTitle requires an ID field in the mutation")
  18138. }
  18139. oldValue, err := m.oldValue(ctx)
  18140. if err != nil {
  18141. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18142. }
  18143. return oldValue.Title, nil
  18144. }
  18145. // ResetTitle resets all changes to the "title" field.
  18146. func (m *EmployeeMutation) ResetTitle() {
  18147. m.title = nil
  18148. }
  18149. // SetAvatar sets the "avatar" field.
  18150. func (m *EmployeeMutation) SetAvatar(s string) {
  18151. m.avatar = &s
  18152. }
  18153. // Avatar returns the value of the "avatar" field in the mutation.
  18154. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  18155. v := m.avatar
  18156. if v == nil {
  18157. return
  18158. }
  18159. return *v, true
  18160. }
  18161. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  18162. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18164. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  18165. if !m.op.Is(OpUpdateOne) {
  18166. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  18167. }
  18168. if m.id == nil || m.oldValue == nil {
  18169. return v, errors.New("OldAvatar requires an ID field in the mutation")
  18170. }
  18171. oldValue, err := m.oldValue(ctx)
  18172. if err != nil {
  18173. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  18174. }
  18175. return oldValue.Avatar, nil
  18176. }
  18177. // ResetAvatar resets all changes to the "avatar" field.
  18178. func (m *EmployeeMutation) ResetAvatar() {
  18179. m.avatar = nil
  18180. }
  18181. // SetTags sets the "tags" field.
  18182. func (m *EmployeeMutation) SetTags(s string) {
  18183. m.tags = &s
  18184. }
  18185. // Tags returns the value of the "tags" field in the mutation.
  18186. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  18187. v := m.tags
  18188. if v == nil {
  18189. return
  18190. }
  18191. return *v, true
  18192. }
  18193. // OldTags returns the old "tags" field's value of the Employee entity.
  18194. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18196. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  18197. if !m.op.Is(OpUpdateOne) {
  18198. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  18199. }
  18200. if m.id == nil || m.oldValue == nil {
  18201. return v, errors.New("OldTags requires an ID field in the mutation")
  18202. }
  18203. oldValue, err := m.oldValue(ctx)
  18204. if err != nil {
  18205. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  18206. }
  18207. return oldValue.Tags, nil
  18208. }
  18209. // ResetTags resets all changes to the "tags" field.
  18210. func (m *EmployeeMutation) ResetTags() {
  18211. m.tags = nil
  18212. }
  18213. // SetHireCount sets the "hire_count" field.
  18214. func (m *EmployeeMutation) SetHireCount(i int) {
  18215. m.hire_count = &i
  18216. m.addhire_count = nil
  18217. }
  18218. // HireCount returns the value of the "hire_count" field in the mutation.
  18219. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  18220. v := m.hire_count
  18221. if v == nil {
  18222. return
  18223. }
  18224. return *v, true
  18225. }
  18226. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  18227. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18229. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  18230. if !m.op.Is(OpUpdateOne) {
  18231. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  18232. }
  18233. if m.id == nil || m.oldValue == nil {
  18234. return v, errors.New("OldHireCount requires an ID field in the mutation")
  18235. }
  18236. oldValue, err := m.oldValue(ctx)
  18237. if err != nil {
  18238. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  18239. }
  18240. return oldValue.HireCount, nil
  18241. }
  18242. // AddHireCount adds i to the "hire_count" field.
  18243. func (m *EmployeeMutation) AddHireCount(i int) {
  18244. if m.addhire_count != nil {
  18245. *m.addhire_count += i
  18246. } else {
  18247. m.addhire_count = &i
  18248. }
  18249. }
  18250. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  18251. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  18252. v := m.addhire_count
  18253. if v == nil {
  18254. return
  18255. }
  18256. return *v, true
  18257. }
  18258. // ResetHireCount resets all changes to the "hire_count" field.
  18259. func (m *EmployeeMutation) ResetHireCount() {
  18260. m.hire_count = nil
  18261. m.addhire_count = nil
  18262. }
  18263. // SetServiceCount sets the "service_count" field.
  18264. func (m *EmployeeMutation) SetServiceCount(i int) {
  18265. m.service_count = &i
  18266. m.addservice_count = nil
  18267. }
  18268. // ServiceCount returns the value of the "service_count" field in the mutation.
  18269. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  18270. v := m.service_count
  18271. if v == nil {
  18272. return
  18273. }
  18274. return *v, true
  18275. }
  18276. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  18277. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18279. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  18280. if !m.op.Is(OpUpdateOne) {
  18281. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  18282. }
  18283. if m.id == nil || m.oldValue == nil {
  18284. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  18285. }
  18286. oldValue, err := m.oldValue(ctx)
  18287. if err != nil {
  18288. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  18289. }
  18290. return oldValue.ServiceCount, nil
  18291. }
  18292. // AddServiceCount adds i to the "service_count" field.
  18293. func (m *EmployeeMutation) AddServiceCount(i int) {
  18294. if m.addservice_count != nil {
  18295. *m.addservice_count += i
  18296. } else {
  18297. m.addservice_count = &i
  18298. }
  18299. }
  18300. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  18301. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  18302. v := m.addservice_count
  18303. if v == nil {
  18304. return
  18305. }
  18306. return *v, true
  18307. }
  18308. // ResetServiceCount resets all changes to the "service_count" field.
  18309. func (m *EmployeeMutation) ResetServiceCount() {
  18310. m.service_count = nil
  18311. m.addservice_count = nil
  18312. }
  18313. // SetAchievementCount sets the "achievement_count" field.
  18314. func (m *EmployeeMutation) SetAchievementCount(i int) {
  18315. m.achievement_count = &i
  18316. m.addachievement_count = nil
  18317. }
  18318. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  18319. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  18320. v := m.achievement_count
  18321. if v == nil {
  18322. return
  18323. }
  18324. return *v, true
  18325. }
  18326. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  18327. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18329. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  18330. if !m.op.Is(OpUpdateOne) {
  18331. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  18332. }
  18333. if m.id == nil || m.oldValue == nil {
  18334. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  18335. }
  18336. oldValue, err := m.oldValue(ctx)
  18337. if err != nil {
  18338. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  18339. }
  18340. return oldValue.AchievementCount, nil
  18341. }
  18342. // AddAchievementCount adds i to the "achievement_count" field.
  18343. func (m *EmployeeMutation) AddAchievementCount(i int) {
  18344. if m.addachievement_count != nil {
  18345. *m.addachievement_count += i
  18346. } else {
  18347. m.addachievement_count = &i
  18348. }
  18349. }
  18350. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  18351. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  18352. v := m.addachievement_count
  18353. if v == nil {
  18354. return
  18355. }
  18356. return *v, true
  18357. }
  18358. // ResetAchievementCount resets all changes to the "achievement_count" field.
  18359. func (m *EmployeeMutation) ResetAchievementCount() {
  18360. m.achievement_count = nil
  18361. m.addachievement_count = nil
  18362. }
  18363. // SetIntro sets the "intro" field.
  18364. func (m *EmployeeMutation) SetIntro(s string) {
  18365. m.intro = &s
  18366. }
  18367. // Intro returns the value of the "intro" field in the mutation.
  18368. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  18369. v := m.intro
  18370. if v == nil {
  18371. return
  18372. }
  18373. return *v, true
  18374. }
  18375. // OldIntro returns the old "intro" field's value of the Employee entity.
  18376. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18378. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  18379. if !m.op.Is(OpUpdateOne) {
  18380. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  18381. }
  18382. if m.id == nil || m.oldValue == nil {
  18383. return v, errors.New("OldIntro requires an ID field in the mutation")
  18384. }
  18385. oldValue, err := m.oldValue(ctx)
  18386. if err != nil {
  18387. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  18388. }
  18389. return oldValue.Intro, nil
  18390. }
  18391. // ResetIntro resets all changes to the "intro" field.
  18392. func (m *EmployeeMutation) ResetIntro() {
  18393. m.intro = nil
  18394. }
  18395. // SetEstimate sets the "estimate" field.
  18396. func (m *EmployeeMutation) SetEstimate(s string) {
  18397. m.estimate = &s
  18398. }
  18399. // Estimate returns the value of the "estimate" field in the mutation.
  18400. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  18401. v := m.estimate
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // OldEstimate returns the old "estimate" 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) OldEstimate(ctx context.Context) (v string, err error) {
  18411. if !m.op.Is(OpUpdateOne) {
  18412. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  18413. }
  18414. if m.id == nil || m.oldValue == nil {
  18415. return v, errors.New("OldEstimate 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 OldEstimate: %w", err)
  18420. }
  18421. return oldValue.Estimate, nil
  18422. }
  18423. // ResetEstimate resets all changes to the "estimate" field.
  18424. func (m *EmployeeMutation) ResetEstimate() {
  18425. m.estimate = nil
  18426. }
  18427. // SetSkill sets the "skill" field.
  18428. func (m *EmployeeMutation) SetSkill(s string) {
  18429. m.skill = &s
  18430. }
  18431. // Skill returns the value of the "skill" field in the mutation.
  18432. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  18433. v := m.skill
  18434. if v == nil {
  18435. return
  18436. }
  18437. return *v, true
  18438. }
  18439. // OldSkill returns the old "skill" field's value of the Employee entity.
  18440. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18442. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  18443. if !m.op.Is(OpUpdateOne) {
  18444. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  18445. }
  18446. if m.id == nil || m.oldValue == nil {
  18447. return v, errors.New("OldSkill requires an ID field in the mutation")
  18448. }
  18449. oldValue, err := m.oldValue(ctx)
  18450. if err != nil {
  18451. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  18452. }
  18453. return oldValue.Skill, nil
  18454. }
  18455. // ResetSkill resets all changes to the "skill" field.
  18456. func (m *EmployeeMutation) ResetSkill() {
  18457. m.skill = nil
  18458. }
  18459. // SetAbilityType sets the "ability_type" field.
  18460. func (m *EmployeeMutation) SetAbilityType(s string) {
  18461. m.ability_type = &s
  18462. }
  18463. // AbilityType returns the value of the "ability_type" field in the mutation.
  18464. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  18465. v := m.ability_type
  18466. if v == nil {
  18467. return
  18468. }
  18469. return *v, true
  18470. }
  18471. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  18472. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18474. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  18475. if !m.op.Is(OpUpdateOne) {
  18476. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  18477. }
  18478. if m.id == nil || m.oldValue == nil {
  18479. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  18480. }
  18481. oldValue, err := m.oldValue(ctx)
  18482. if err != nil {
  18483. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  18484. }
  18485. return oldValue.AbilityType, nil
  18486. }
  18487. // ResetAbilityType resets all changes to the "ability_type" field.
  18488. func (m *EmployeeMutation) ResetAbilityType() {
  18489. m.ability_type = nil
  18490. }
  18491. // SetScene sets the "scene" field.
  18492. func (m *EmployeeMutation) SetScene(s string) {
  18493. m.scene = &s
  18494. }
  18495. // Scene returns the value of the "scene" field in the mutation.
  18496. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  18497. v := m.scene
  18498. if v == nil {
  18499. return
  18500. }
  18501. return *v, true
  18502. }
  18503. // OldScene returns the old "scene" field's value of the Employee entity.
  18504. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18506. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  18507. if !m.op.Is(OpUpdateOne) {
  18508. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  18509. }
  18510. if m.id == nil || m.oldValue == nil {
  18511. return v, errors.New("OldScene requires an ID field in the mutation")
  18512. }
  18513. oldValue, err := m.oldValue(ctx)
  18514. if err != nil {
  18515. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  18516. }
  18517. return oldValue.Scene, nil
  18518. }
  18519. // ResetScene resets all changes to the "scene" field.
  18520. func (m *EmployeeMutation) ResetScene() {
  18521. m.scene = nil
  18522. }
  18523. // SetSwitchIn sets the "switch_in" field.
  18524. func (m *EmployeeMutation) SetSwitchIn(s string) {
  18525. m.switch_in = &s
  18526. }
  18527. // SwitchIn returns the value of the "switch_in" field in the mutation.
  18528. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  18529. v := m.switch_in
  18530. if v == nil {
  18531. return
  18532. }
  18533. return *v, true
  18534. }
  18535. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  18536. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18538. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  18539. if !m.op.Is(OpUpdateOne) {
  18540. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  18541. }
  18542. if m.id == nil || m.oldValue == nil {
  18543. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  18544. }
  18545. oldValue, err := m.oldValue(ctx)
  18546. if err != nil {
  18547. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  18548. }
  18549. return oldValue.SwitchIn, nil
  18550. }
  18551. // ResetSwitchIn resets all changes to the "switch_in" field.
  18552. func (m *EmployeeMutation) ResetSwitchIn() {
  18553. m.switch_in = nil
  18554. }
  18555. // SetVideoURL sets the "video_url" field.
  18556. func (m *EmployeeMutation) SetVideoURL(s string) {
  18557. m.video_url = &s
  18558. }
  18559. // VideoURL returns the value of the "video_url" field in the mutation.
  18560. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  18561. v := m.video_url
  18562. if v == nil {
  18563. return
  18564. }
  18565. return *v, true
  18566. }
  18567. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  18568. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18570. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  18571. if !m.op.Is(OpUpdateOne) {
  18572. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  18573. }
  18574. if m.id == nil || m.oldValue == nil {
  18575. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  18576. }
  18577. oldValue, err := m.oldValue(ctx)
  18578. if err != nil {
  18579. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  18580. }
  18581. return oldValue.VideoURL, nil
  18582. }
  18583. // ResetVideoURL resets all changes to the "video_url" field.
  18584. func (m *EmployeeMutation) ResetVideoURL() {
  18585. m.video_url = nil
  18586. }
  18587. // SetOrganizationID sets the "organization_id" field.
  18588. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  18589. m.organization_id = &u
  18590. m.addorganization_id = nil
  18591. }
  18592. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18593. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  18594. v := m.organization_id
  18595. if v == nil {
  18596. return
  18597. }
  18598. return *v, true
  18599. }
  18600. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  18601. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18603. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18604. if !m.op.Is(OpUpdateOne) {
  18605. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18606. }
  18607. if m.id == nil || m.oldValue == nil {
  18608. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18609. }
  18610. oldValue, err := m.oldValue(ctx)
  18611. if err != nil {
  18612. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18613. }
  18614. return oldValue.OrganizationID, nil
  18615. }
  18616. // AddOrganizationID adds u to the "organization_id" field.
  18617. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  18618. if m.addorganization_id != nil {
  18619. *m.addorganization_id += u
  18620. } else {
  18621. m.addorganization_id = &u
  18622. }
  18623. }
  18624. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18625. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  18626. v := m.addorganization_id
  18627. if v == nil {
  18628. return
  18629. }
  18630. return *v, true
  18631. }
  18632. // ResetOrganizationID resets all changes to the "organization_id" field.
  18633. func (m *EmployeeMutation) ResetOrganizationID() {
  18634. m.organization_id = nil
  18635. m.addorganization_id = nil
  18636. }
  18637. // SetCategoryID sets the "category_id" field.
  18638. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  18639. m.category_id = &u
  18640. m.addcategory_id = nil
  18641. }
  18642. // CategoryID returns the value of the "category_id" field in the mutation.
  18643. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  18644. v := m.category_id
  18645. if v == nil {
  18646. return
  18647. }
  18648. return *v, true
  18649. }
  18650. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  18651. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18653. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  18654. if !m.op.Is(OpUpdateOne) {
  18655. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  18656. }
  18657. if m.id == nil || m.oldValue == nil {
  18658. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  18659. }
  18660. oldValue, err := m.oldValue(ctx)
  18661. if err != nil {
  18662. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  18663. }
  18664. return oldValue.CategoryID, nil
  18665. }
  18666. // AddCategoryID adds u to the "category_id" field.
  18667. func (m *EmployeeMutation) AddCategoryID(u int64) {
  18668. if m.addcategory_id != nil {
  18669. *m.addcategory_id += u
  18670. } else {
  18671. m.addcategory_id = &u
  18672. }
  18673. }
  18674. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  18675. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  18676. v := m.addcategory_id
  18677. if v == nil {
  18678. return
  18679. }
  18680. return *v, true
  18681. }
  18682. // ResetCategoryID resets all changes to the "category_id" field.
  18683. func (m *EmployeeMutation) ResetCategoryID() {
  18684. m.category_id = nil
  18685. m.addcategory_id = nil
  18686. }
  18687. // SetAPIBase sets the "api_base" field.
  18688. func (m *EmployeeMutation) SetAPIBase(s string) {
  18689. m.api_base = &s
  18690. }
  18691. // APIBase returns the value of the "api_base" field in the mutation.
  18692. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  18693. v := m.api_base
  18694. if v == nil {
  18695. return
  18696. }
  18697. return *v, true
  18698. }
  18699. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  18700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18702. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18703. if !m.op.Is(OpUpdateOne) {
  18704. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18705. }
  18706. if m.id == nil || m.oldValue == nil {
  18707. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18708. }
  18709. oldValue, err := m.oldValue(ctx)
  18710. if err != nil {
  18711. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18712. }
  18713. return oldValue.APIBase, nil
  18714. }
  18715. // ResetAPIBase resets all changes to the "api_base" field.
  18716. func (m *EmployeeMutation) ResetAPIBase() {
  18717. m.api_base = nil
  18718. }
  18719. // SetAPIKey sets the "api_key" field.
  18720. func (m *EmployeeMutation) SetAPIKey(s string) {
  18721. m.api_key = &s
  18722. }
  18723. // APIKey returns the value of the "api_key" field in the mutation.
  18724. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  18725. v := m.api_key
  18726. if v == nil {
  18727. return
  18728. }
  18729. return *v, true
  18730. }
  18731. // OldAPIKey returns the old "api_key" 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) OldAPIKey(ctx context.Context) (v string, err error) {
  18735. if !m.op.Is(OpUpdateOne) {
  18736. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18737. }
  18738. if m.id == nil || m.oldValue == nil {
  18739. return v, errors.New("OldAPIKey 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 OldAPIKey: %w", err)
  18744. }
  18745. return oldValue.APIKey, nil
  18746. }
  18747. // ResetAPIKey resets all changes to the "api_key" field.
  18748. func (m *EmployeeMutation) ResetAPIKey() {
  18749. m.api_key = nil
  18750. }
  18751. // SetAiInfo sets the "ai_info" field.
  18752. func (m *EmployeeMutation) SetAiInfo(s string) {
  18753. m.ai_info = &s
  18754. }
  18755. // AiInfo returns the value of the "ai_info" field in the mutation.
  18756. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  18757. v := m.ai_info
  18758. if v == nil {
  18759. return
  18760. }
  18761. return *v, true
  18762. }
  18763. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  18764. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18766. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  18767. if !m.op.Is(OpUpdateOne) {
  18768. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  18769. }
  18770. if m.id == nil || m.oldValue == nil {
  18771. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  18772. }
  18773. oldValue, err := m.oldValue(ctx)
  18774. if err != nil {
  18775. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  18776. }
  18777. return oldValue.AiInfo, nil
  18778. }
  18779. // ClearAiInfo clears the value of the "ai_info" field.
  18780. func (m *EmployeeMutation) ClearAiInfo() {
  18781. m.ai_info = nil
  18782. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  18783. }
  18784. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  18785. func (m *EmployeeMutation) AiInfoCleared() bool {
  18786. _, ok := m.clearedFields[employee.FieldAiInfo]
  18787. return ok
  18788. }
  18789. // ResetAiInfo resets all changes to the "ai_info" field.
  18790. func (m *EmployeeMutation) ResetAiInfo() {
  18791. m.ai_info = nil
  18792. delete(m.clearedFields, employee.FieldAiInfo)
  18793. }
  18794. // SetIsVip sets the "is_vip" field.
  18795. func (m *EmployeeMutation) SetIsVip(i int) {
  18796. m.is_vip = &i
  18797. m.addis_vip = nil
  18798. }
  18799. // IsVip returns the value of the "is_vip" field in the mutation.
  18800. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  18801. v := m.is_vip
  18802. if v == nil {
  18803. return
  18804. }
  18805. return *v, true
  18806. }
  18807. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  18808. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18810. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  18811. if !m.op.Is(OpUpdateOne) {
  18812. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  18813. }
  18814. if m.id == nil || m.oldValue == nil {
  18815. return v, errors.New("OldIsVip requires an ID field in the mutation")
  18816. }
  18817. oldValue, err := m.oldValue(ctx)
  18818. if err != nil {
  18819. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  18820. }
  18821. return oldValue.IsVip, nil
  18822. }
  18823. // AddIsVip adds i to the "is_vip" field.
  18824. func (m *EmployeeMutation) AddIsVip(i int) {
  18825. if m.addis_vip != nil {
  18826. *m.addis_vip += i
  18827. } else {
  18828. m.addis_vip = &i
  18829. }
  18830. }
  18831. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  18832. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  18833. v := m.addis_vip
  18834. if v == nil {
  18835. return
  18836. }
  18837. return *v, true
  18838. }
  18839. // ResetIsVip resets all changes to the "is_vip" field.
  18840. func (m *EmployeeMutation) ResetIsVip() {
  18841. m.is_vip = nil
  18842. m.addis_vip = nil
  18843. }
  18844. // SetChatURL sets the "chat_url" field.
  18845. func (m *EmployeeMutation) SetChatURL(s string) {
  18846. m.chat_url = &s
  18847. }
  18848. // ChatURL returns the value of the "chat_url" field in the mutation.
  18849. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  18850. v := m.chat_url
  18851. if v == nil {
  18852. return
  18853. }
  18854. return *v, true
  18855. }
  18856. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  18857. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18859. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  18860. if !m.op.Is(OpUpdateOne) {
  18861. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  18862. }
  18863. if m.id == nil || m.oldValue == nil {
  18864. return v, errors.New("OldChatURL requires an ID field in the mutation")
  18865. }
  18866. oldValue, err := m.oldValue(ctx)
  18867. if err != nil {
  18868. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  18869. }
  18870. return oldValue.ChatURL, nil
  18871. }
  18872. // ResetChatURL resets all changes to the "chat_url" field.
  18873. func (m *EmployeeMutation) ResetChatURL() {
  18874. m.chat_url = nil
  18875. }
  18876. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  18877. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  18878. if m.em_work_experiences == nil {
  18879. m.em_work_experiences = make(map[uint64]struct{})
  18880. }
  18881. for i := range ids {
  18882. m.em_work_experiences[ids[i]] = struct{}{}
  18883. }
  18884. }
  18885. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  18886. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  18887. m.clearedem_work_experiences = true
  18888. }
  18889. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  18890. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  18891. return m.clearedem_work_experiences
  18892. }
  18893. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  18894. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  18895. if m.removedem_work_experiences == nil {
  18896. m.removedem_work_experiences = make(map[uint64]struct{})
  18897. }
  18898. for i := range ids {
  18899. delete(m.em_work_experiences, ids[i])
  18900. m.removedem_work_experiences[ids[i]] = struct{}{}
  18901. }
  18902. }
  18903. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  18904. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  18905. for id := range m.removedem_work_experiences {
  18906. ids = append(ids, id)
  18907. }
  18908. return
  18909. }
  18910. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  18911. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  18912. for id := range m.em_work_experiences {
  18913. ids = append(ids, id)
  18914. }
  18915. return
  18916. }
  18917. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  18918. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  18919. m.em_work_experiences = nil
  18920. m.clearedem_work_experiences = false
  18921. m.removedem_work_experiences = nil
  18922. }
  18923. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  18924. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  18925. if m.em_tutorial == nil {
  18926. m.em_tutorial = make(map[uint64]struct{})
  18927. }
  18928. for i := range ids {
  18929. m.em_tutorial[ids[i]] = struct{}{}
  18930. }
  18931. }
  18932. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  18933. func (m *EmployeeMutation) ClearEmTutorial() {
  18934. m.clearedem_tutorial = true
  18935. }
  18936. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  18937. func (m *EmployeeMutation) EmTutorialCleared() bool {
  18938. return m.clearedem_tutorial
  18939. }
  18940. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  18941. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  18942. if m.removedem_tutorial == nil {
  18943. m.removedem_tutorial = make(map[uint64]struct{})
  18944. }
  18945. for i := range ids {
  18946. delete(m.em_tutorial, ids[i])
  18947. m.removedem_tutorial[ids[i]] = struct{}{}
  18948. }
  18949. }
  18950. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  18951. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  18952. for id := range m.removedem_tutorial {
  18953. ids = append(ids, id)
  18954. }
  18955. return
  18956. }
  18957. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  18958. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  18959. for id := range m.em_tutorial {
  18960. ids = append(ids, id)
  18961. }
  18962. return
  18963. }
  18964. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  18965. func (m *EmployeeMutation) ResetEmTutorial() {
  18966. m.em_tutorial = nil
  18967. m.clearedem_tutorial = false
  18968. m.removedem_tutorial = nil
  18969. }
  18970. // Where appends a list predicates to the EmployeeMutation builder.
  18971. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  18972. m.predicates = append(m.predicates, ps...)
  18973. }
  18974. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  18975. // users can use type-assertion to append predicates that do not depend on any generated package.
  18976. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  18977. p := make([]predicate.Employee, len(ps))
  18978. for i := range ps {
  18979. p[i] = ps[i]
  18980. }
  18981. m.Where(p...)
  18982. }
  18983. // Op returns the operation name.
  18984. func (m *EmployeeMutation) Op() Op {
  18985. return m.op
  18986. }
  18987. // SetOp allows setting the mutation operation.
  18988. func (m *EmployeeMutation) SetOp(op Op) {
  18989. m.op = op
  18990. }
  18991. // Type returns the node type of this mutation (Employee).
  18992. func (m *EmployeeMutation) Type() string {
  18993. return m.typ
  18994. }
  18995. // Fields returns all fields that were changed during this mutation. Note that in
  18996. // order to get all numeric fields that were incremented/decremented, call
  18997. // AddedFields().
  18998. func (m *EmployeeMutation) Fields() []string {
  18999. fields := make([]string, 0, 23)
  19000. if m.created_at != nil {
  19001. fields = append(fields, employee.FieldCreatedAt)
  19002. }
  19003. if m.updated_at != nil {
  19004. fields = append(fields, employee.FieldUpdatedAt)
  19005. }
  19006. if m.deleted_at != nil {
  19007. fields = append(fields, employee.FieldDeletedAt)
  19008. }
  19009. if m.title != nil {
  19010. fields = append(fields, employee.FieldTitle)
  19011. }
  19012. if m.avatar != nil {
  19013. fields = append(fields, employee.FieldAvatar)
  19014. }
  19015. if m.tags != nil {
  19016. fields = append(fields, employee.FieldTags)
  19017. }
  19018. if m.hire_count != nil {
  19019. fields = append(fields, employee.FieldHireCount)
  19020. }
  19021. if m.service_count != nil {
  19022. fields = append(fields, employee.FieldServiceCount)
  19023. }
  19024. if m.achievement_count != nil {
  19025. fields = append(fields, employee.FieldAchievementCount)
  19026. }
  19027. if m.intro != nil {
  19028. fields = append(fields, employee.FieldIntro)
  19029. }
  19030. if m.estimate != nil {
  19031. fields = append(fields, employee.FieldEstimate)
  19032. }
  19033. if m.skill != nil {
  19034. fields = append(fields, employee.FieldSkill)
  19035. }
  19036. if m.ability_type != nil {
  19037. fields = append(fields, employee.FieldAbilityType)
  19038. }
  19039. if m.scene != nil {
  19040. fields = append(fields, employee.FieldScene)
  19041. }
  19042. if m.switch_in != nil {
  19043. fields = append(fields, employee.FieldSwitchIn)
  19044. }
  19045. if m.video_url != nil {
  19046. fields = append(fields, employee.FieldVideoURL)
  19047. }
  19048. if m.organization_id != nil {
  19049. fields = append(fields, employee.FieldOrganizationID)
  19050. }
  19051. if m.category_id != nil {
  19052. fields = append(fields, employee.FieldCategoryID)
  19053. }
  19054. if m.api_base != nil {
  19055. fields = append(fields, employee.FieldAPIBase)
  19056. }
  19057. if m.api_key != nil {
  19058. fields = append(fields, employee.FieldAPIKey)
  19059. }
  19060. if m.ai_info != nil {
  19061. fields = append(fields, employee.FieldAiInfo)
  19062. }
  19063. if m.is_vip != nil {
  19064. fields = append(fields, employee.FieldIsVip)
  19065. }
  19066. if m.chat_url != nil {
  19067. fields = append(fields, employee.FieldChatURL)
  19068. }
  19069. return fields
  19070. }
  19071. // Field returns the value of a field with the given name. The second boolean
  19072. // return value indicates that this field was not set, or was not defined in the
  19073. // schema.
  19074. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  19075. switch name {
  19076. case employee.FieldCreatedAt:
  19077. return m.CreatedAt()
  19078. case employee.FieldUpdatedAt:
  19079. return m.UpdatedAt()
  19080. case employee.FieldDeletedAt:
  19081. return m.DeletedAt()
  19082. case employee.FieldTitle:
  19083. return m.Title()
  19084. case employee.FieldAvatar:
  19085. return m.Avatar()
  19086. case employee.FieldTags:
  19087. return m.Tags()
  19088. case employee.FieldHireCount:
  19089. return m.HireCount()
  19090. case employee.FieldServiceCount:
  19091. return m.ServiceCount()
  19092. case employee.FieldAchievementCount:
  19093. return m.AchievementCount()
  19094. case employee.FieldIntro:
  19095. return m.Intro()
  19096. case employee.FieldEstimate:
  19097. return m.Estimate()
  19098. case employee.FieldSkill:
  19099. return m.Skill()
  19100. case employee.FieldAbilityType:
  19101. return m.AbilityType()
  19102. case employee.FieldScene:
  19103. return m.Scene()
  19104. case employee.FieldSwitchIn:
  19105. return m.SwitchIn()
  19106. case employee.FieldVideoURL:
  19107. return m.VideoURL()
  19108. case employee.FieldOrganizationID:
  19109. return m.OrganizationID()
  19110. case employee.FieldCategoryID:
  19111. return m.CategoryID()
  19112. case employee.FieldAPIBase:
  19113. return m.APIBase()
  19114. case employee.FieldAPIKey:
  19115. return m.APIKey()
  19116. case employee.FieldAiInfo:
  19117. return m.AiInfo()
  19118. case employee.FieldIsVip:
  19119. return m.IsVip()
  19120. case employee.FieldChatURL:
  19121. return m.ChatURL()
  19122. }
  19123. return nil, false
  19124. }
  19125. // OldField returns the old value of the field from the database. An error is
  19126. // returned if the mutation operation is not UpdateOne, or the query to the
  19127. // database failed.
  19128. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19129. switch name {
  19130. case employee.FieldCreatedAt:
  19131. return m.OldCreatedAt(ctx)
  19132. case employee.FieldUpdatedAt:
  19133. return m.OldUpdatedAt(ctx)
  19134. case employee.FieldDeletedAt:
  19135. return m.OldDeletedAt(ctx)
  19136. case employee.FieldTitle:
  19137. return m.OldTitle(ctx)
  19138. case employee.FieldAvatar:
  19139. return m.OldAvatar(ctx)
  19140. case employee.FieldTags:
  19141. return m.OldTags(ctx)
  19142. case employee.FieldHireCount:
  19143. return m.OldHireCount(ctx)
  19144. case employee.FieldServiceCount:
  19145. return m.OldServiceCount(ctx)
  19146. case employee.FieldAchievementCount:
  19147. return m.OldAchievementCount(ctx)
  19148. case employee.FieldIntro:
  19149. return m.OldIntro(ctx)
  19150. case employee.FieldEstimate:
  19151. return m.OldEstimate(ctx)
  19152. case employee.FieldSkill:
  19153. return m.OldSkill(ctx)
  19154. case employee.FieldAbilityType:
  19155. return m.OldAbilityType(ctx)
  19156. case employee.FieldScene:
  19157. return m.OldScene(ctx)
  19158. case employee.FieldSwitchIn:
  19159. return m.OldSwitchIn(ctx)
  19160. case employee.FieldVideoURL:
  19161. return m.OldVideoURL(ctx)
  19162. case employee.FieldOrganizationID:
  19163. return m.OldOrganizationID(ctx)
  19164. case employee.FieldCategoryID:
  19165. return m.OldCategoryID(ctx)
  19166. case employee.FieldAPIBase:
  19167. return m.OldAPIBase(ctx)
  19168. case employee.FieldAPIKey:
  19169. return m.OldAPIKey(ctx)
  19170. case employee.FieldAiInfo:
  19171. return m.OldAiInfo(ctx)
  19172. case employee.FieldIsVip:
  19173. return m.OldIsVip(ctx)
  19174. case employee.FieldChatURL:
  19175. return m.OldChatURL(ctx)
  19176. }
  19177. return nil, fmt.Errorf("unknown Employee field %s", name)
  19178. }
  19179. // SetField sets the value of a field with the given name. It returns an error if
  19180. // the field is not defined in the schema, or if the type mismatched the field
  19181. // type.
  19182. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  19183. switch name {
  19184. case employee.FieldCreatedAt:
  19185. v, ok := value.(time.Time)
  19186. if !ok {
  19187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19188. }
  19189. m.SetCreatedAt(v)
  19190. return nil
  19191. case employee.FieldUpdatedAt:
  19192. v, ok := value.(time.Time)
  19193. if !ok {
  19194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19195. }
  19196. m.SetUpdatedAt(v)
  19197. return nil
  19198. case employee.FieldDeletedAt:
  19199. v, ok := value.(time.Time)
  19200. if !ok {
  19201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19202. }
  19203. m.SetDeletedAt(v)
  19204. return nil
  19205. case employee.FieldTitle:
  19206. v, ok := value.(string)
  19207. if !ok {
  19208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19209. }
  19210. m.SetTitle(v)
  19211. return nil
  19212. case employee.FieldAvatar:
  19213. v, ok := value.(string)
  19214. if !ok {
  19215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19216. }
  19217. m.SetAvatar(v)
  19218. return nil
  19219. case employee.FieldTags:
  19220. v, ok := value.(string)
  19221. if !ok {
  19222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19223. }
  19224. m.SetTags(v)
  19225. return nil
  19226. case employee.FieldHireCount:
  19227. v, ok := value.(int)
  19228. if !ok {
  19229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19230. }
  19231. m.SetHireCount(v)
  19232. return nil
  19233. case employee.FieldServiceCount:
  19234. v, ok := value.(int)
  19235. if !ok {
  19236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19237. }
  19238. m.SetServiceCount(v)
  19239. return nil
  19240. case employee.FieldAchievementCount:
  19241. v, ok := value.(int)
  19242. if !ok {
  19243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19244. }
  19245. m.SetAchievementCount(v)
  19246. return nil
  19247. case employee.FieldIntro:
  19248. v, ok := value.(string)
  19249. if !ok {
  19250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19251. }
  19252. m.SetIntro(v)
  19253. return nil
  19254. case employee.FieldEstimate:
  19255. v, ok := value.(string)
  19256. if !ok {
  19257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19258. }
  19259. m.SetEstimate(v)
  19260. return nil
  19261. case employee.FieldSkill:
  19262. v, ok := value.(string)
  19263. if !ok {
  19264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19265. }
  19266. m.SetSkill(v)
  19267. return nil
  19268. case employee.FieldAbilityType:
  19269. v, ok := value.(string)
  19270. if !ok {
  19271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19272. }
  19273. m.SetAbilityType(v)
  19274. return nil
  19275. case employee.FieldScene:
  19276. v, ok := value.(string)
  19277. if !ok {
  19278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19279. }
  19280. m.SetScene(v)
  19281. return nil
  19282. case employee.FieldSwitchIn:
  19283. v, ok := value.(string)
  19284. if !ok {
  19285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19286. }
  19287. m.SetSwitchIn(v)
  19288. return nil
  19289. case employee.FieldVideoURL:
  19290. v, ok := value.(string)
  19291. if !ok {
  19292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19293. }
  19294. m.SetVideoURL(v)
  19295. return nil
  19296. case employee.FieldOrganizationID:
  19297. v, ok := value.(uint64)
  19298. if !ok {
  19299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19300. }
  19301. m.SetOrganizationID(v)
  19302. return nil
  19303. case employee.FieldCategoryID:
  19304. v, ok := value.(uint64)
  19305. if !ok {
  19306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19307. }
  19308. m.SetCategoryID(v)
  19309. return nil
  19310. case employee.FieldAPIBase:
  19311. v, ok := value.(string)
  19312. if !ok {
  19313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19314. }
  19315. m.SetAPIBase(v)
  19316. return nil
  19317. case employee.FieldAPIKey:
  19318. v, ok := value.(string)
  19319. if !ok {
  19320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19321. }
  19322. m.SetAPIKey(v)
  19323. return nil
  19324. case employee.FieldAiInfo:
  19325. v, ok := value.(string)
  19326. if !ok {
  19327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19328. }
  19329. m.SetAiInfo(v)
  19330. return nil
  19331. case employee.FieldIsVip:
  19332. v, ok := value.(int)
  19333. if !ok {
  19334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19335. }
  19336. m.SetIsVip(v)
  19337. return nil
  19338. case employee.FieldChatURL:
  19339. v, ok := value.(string)
  19340. if !ok {
  19341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19342. }
  19343. m.SetChatURL(v)
  19344. return nil
  19345. }
  19346. return fmt.Errorf("unknown Employee field %s", name)
  19347. }
  19348. // AddedFields returns all numeric fields that were incremented/decremented during
  19349. // this mutation.
  19350. func (m *EmployeeMutation) AddedFields() []string {
  19351. var fields []string
  19352. if m.addhire_count != nil {
  19353. fields = append(fields, employee.FieldHireCount)
  19354. }
  19355. if m.addservice_count != nil {
  19356. fields = append(fields, employee.FieldServiceCount)
  19357. }
  19358. if m.addachievement_count != nil {
  19359. fields = append(fields, employee.FieldAchievementCount)
  19360. }
  19361. if m.addorganization_id != nil {
  19362. fields = append(fields, employee.FieldOrganizationID)
  19363. }
  19364. if m.addcategory_id != nil {
  19365. fields = append(fields, employee.FieldCategoryID)
  19366. }
  19367. if m.addis_vip != nil {
  19368. fields = append(fields, employee.FieldIsVip)
  19369. }
  19370. return fields
  19371. }
  19372. // AddedField returns the numeric value that was incremented/decremented on a field
  19373. // with the given name. The second boolean return value indicates that this field
  19374. // was not set, or was not defined in the schema.
  19375. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  19376. switch name {
  19377. case employee.FieldHireCount:
  19378. return m.AddedHireCount()
  19379. case employee.FieldServiceCount:
  19380. return m.AddedServiceCount()
  19381. case employee.FieldAchievementCount:
  19382. return m.AddedAchievementCount()
  19383. case employee.FieldOrganizationID:
  19384. return m.AddedOrganizationID()
  19385. case employee.FieldCategoryID:
  19386. return m.AddedCategoryID()
  19387. case employee.FieldIsVip:
  19388. return m.AddedIsVip()
  19389. }
  19390. return nil, false
  19391. }
  19392. // AddField adds the value to the field with the given name. It returns an error if
  19393. // the field is not defined in the schema, or if the type mismatched the field
  19394. // type.
  19395. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  19396. switch name {
  19397. case employee.FieldHireCount:
  19398. v, ok := value.(int)
  19399. if !ok {
  19400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19401. }
  19402. m.AddHireCount(v)
  19403. return nil
  19404. case employee.FieldServiceCount:
  19405. v, ok := value.(int)
  19406. if !ok {
  19407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19408. }
  19409. m.AddServiceCount(v)
  19410. return nil
  19411. case employee.FieldAchievementCount:
  19412. v, ok := value.(int)
  19413. if !ok {
  19414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19415. }
  19416. m.AddAchievementCount(v)
  19417. return nil
  19418. case employee.FieldOrganizationID:
  19419. v, ok := value.(int64)
  19420. if !ok {
  19421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19422. }
  19423. m.AddOrganizationID(v)
  19424. return nil
  19425. case employee.FieldCategoryID:
  19426. v, ok := value.(int64)
  19427. if !ok {
  19428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19429. }
  19430. m.AddCategoryID(v)
  19431. return nil
  19432. case employee.FieldIsVip:
  19433. v, ok := value.(int)
  19434. if !ok {
  19435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19436. }
  19437. m.AddIsVip(v)
  19438. return nil
  19439. }
  19440. return fmt.Errorf("unknown Employee numeric field %s", name)
  19441. }
  19442. // ClearedFields returns all nullable fields that were cleared during this
  19443. // mutation.
  19444. func (m *EmployeeMutation) ClearedFields() []string {
  19445. var fields []string
  19446. if m.FieldCleared(employee.FieldDeletedAt) {
  19447. fields = append(fields, employee.FieldDeletedAt)
  19448. }
  19449. if m.FieldCleared(employee.FieldAiInfo) {
  19450. fields = append(fields, employee.FieldAiInfo)
  19451. }
  19452. return fields
  19453. }
  19454. // FieldCleared returns a boolean indicating if a field with the given name was
  19455. // cleared in this mutation.
  19456. func (m *EmployeeMutation) FieldCleared(name string) bool {
  19457. _, ok := m.clearedFields[name]
  19458. return ok
  19459. }
  19460. // ClearField clears the value of the field with the given name. It returns an
  19461. // error if the field is not defined in the schema.
  19462. func (m *EmployeeMutation) ClearField(name string) error {
  19463. switch name {
  19464. case employee.FieldDeletedAt:
  19465. m.ClearDeletedAt()
  19466. return nil
  19467. case employee.FieldAiInfo:
  19468. m.ClearAiInfo()
  19469. return nil
  19470. }
  19471. return fmt.Errorf("unknown Employee nullable field %s", name)
  19472. }
  19473. // ResetField resets all changes in the mutation for the field with the given name.
  19474. // It returns an error if the field is not defined in the schema.
  19475. func (m *EmployeeMutation) ResetField(name string) error {
  19476. switch name {
  19477. case employee.FieldCreatedAt:
  19478. m.ResetCreatedAt()
  19479. return nil
  19480. case employee.FieldUpdatedAt:
  19481. m.ResetUpdatedAt()
  19482. return nil
  19483. case employee.FieldDeletedAt:
  19484. m.ResetDeletedAt()
  19485. return nil
  19486. case employee.FieldTitle:
  19487. m.ResetTitle()
  19488. return nil
  19489. case employee.FieldAvatar:
  19490. m.ResetAvatar()
  19491. return nil
  19492. case employee.FieldTags:
  19493. m.ResetTags()
  19494. return nil
  19495. case employee.FieldHireCount:
  19496. m.ResetHireCount()
  19497. return nil
  19498. case employee.FieldServiceCount:
  19499. m.ResetServiceCount()
  19500. return nil
  19501. case employee.FieldAchievementCount:
  19502. m.ResetAchievementCount()
  19503. return nil
  19504. case employee.FieldIntro:
  19505. m.ResetIntro()
  19506. return nil
  19507. case employee.FieldEstimate:
  19508. m.ResetEstimate()
  19509. return nil
  19510. case employee.FieldSkill:
  19511. m.ResetSkill()
  19512. return nil
  19513. case employee.FieldAbilityType:
  19514. m.ResetAbilityType()
  19515. return nil
  19516. case employee.FieldScene:
  19517. m.ResetScene()
  19518. return nil
  19519. case employee.FieldSwitchIn:
  19520. m.ResetSwitchIn()
  19521. return nil
  19522. case employee.FieldVideoURL:
  19523. m.ResetVideoURL()
  19524. return nil
  19525. case employee.FieldOrganizationID:
  19526. m.ResetOrganizationID()
  19527. return nil
  19528. case employee.FieldCategoryID:
  19529. m.ResetCategoryID()
  19530. return nil
  19531. case employee.FieldAPIBase:
  19532. m.ResetAPIBase()
  19533. return nil
  19534. case employee.FieldAPIKey:
  19535. m.ResetAPIKey()
  19536. return nil
  19537. case employee.FieldAiInfo:
  19538. m.ResetAiInfo()
  19539. return nil
  19540. case employee.FieldIsVip:
  19541. m.ResetIsVip()
  19542. return nil
  19543. case employee.FieldChatURL:
  19544. m.ResetChatURL()
  19545. return nil
  19546. }
  19547. return fmt.Errorf("unknown Employee field %s", name)
  19548. }
  19549. // AddedEdges returns all edge names that were set/added in this mutation.
  19550. func (m *EmployeeMutation) AddedEdges() []string {
  19551. edges := make([]string, 0, 2)
  19552. if m.em_work_experiences != nil {
  19553. edges = append(edges, employee.EdgeEmWorkExperiences)
  19554. }
  19555. if m.em_tutorial != nil {
  19556. edges = append(edges, employee.EdgeEmTutorial)
  19557. }
  19558. return edges
  19559. }
  19560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19561. // name in this mutation.
  19562. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  19563. switch name {
  19564. case employee.EdgeEmWorkExperiences:
  19565. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  19566. for id := range m.em_work_experiences {
  19567. ids = append(ids, id)
  19568. }
  19569. return ids
  19570. case employee.EdgeEmTutorial:
  19571. ids := make([]ent.Value, 0, len(m.em_tutorial))
  19572. for id := range m.em_tutorial {
  19573. ids = append(ids, id)
  19574. }
  19575. return ids
  19576. }
  19577. return nil
  19578. }
  19579. // RemovedEdges returns all edge names that were removed in this mutation.
  19580. func (m *EmployeeMutation) RemovedEdges() []string {
  19581. edges := make([]string, 0, 2)
  19582. if m.removedem_work_experiences != nil {
  19583. edges = append(edges, employee.EdgeEmWorkExperiences)
  19584. }
  19585. if m.removedem_tutorial != nil {
  19586. edges = append(edges, employee.EdgeEmTutorial)
  19587. }
  19588. return edges
  19589. }
  19590. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19591. // the given name in this mutation.
  19592. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  19593. switch name {
  19594. case employee.EdgeEmWorkExperiences:
  19595. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  19596. for id := range m.removedem_work_experiences {
  19597. ids = append(ids, id)
  19598. }
  19599. return ids
  19600. case employee.EdgeEmTutorial:
  19601. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  19602. for id := range m.removedem_tutorial {
  19603. ids = append(ids, id)
  19604. }
  19605. return ids
  19606. }
  19607. return nil
  19608. }
  19609. // ClearedEdges returns all edge names that were cleared in this mutation.
  19610. func (m *EmployeeMutation) ClearedEdges() []string {
  19611. edges := make([]string, 0, 2)
  19612. if m.clearedem_work_experiences {
  19613. edges = append(edges, employee.EdgeEmWorkExperiences)
  19614. }
  19615. if m.clearedem_tutorial {
  19616. edges = append(edges, employee.EdgeEmTutorial)
  19617. }
  19618. return edges
  19619. }
  19620. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19621. // was cleared in this mutation.
  19622. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  19623. switch name {
  19624. case employee.EdgeEmWorkExperiences:
  19625. return m.clearedem_work_experiences
  19626. case employee.EdgeEmTutorial:
  19627. return m.clearedem_tutorial
  19628. }
  19629. return false
  19630. }
  19631. // ClearEdge clears the value of the edge with the given name. It returns an error
  19632. // if that edge is not defined in the schema.
  19633. func (m *EmployeeMutation) ClearEdge(name string) error {
  19634. switch name {
  19635. }
  19636. return fmt.Errorf("unknown Employee unique edge %s", name)
  19637. }
  19638. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19639. // It returns an error if the edge is not defined in the schema.
  19640. func (m *EmployeeMutation) ResetEdge(name string) error {
  19641. switch name {
  19642. case employee.EdgeEmWorkExperiences:
  19643. m.ResetEmWorkExperiences()
  19644. return nil
  19645. case employee.EdgeEmTutorial:
  19646. m.ResetEmTutorial()
  19647. return nil
  19648. }
  19649. return fmt.Errorf("unknown Employee edge %s", name)
  19650. }
  19651. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  19652. type EmployeeConfigMutation struct {
  19653. config
  19654. op Op
  19655. typ string
  19656. id *uint64
  19657. created_at *time.Time
  19658. updated_at *time.Time
  19659. deleted_at *time.Time
  19660. stype *string
  19661. title *string
  19662. photo *string
  19663. organization_id *uint64
  19664. addorganization_id *int64
  19665. clearedFields map[string]struct{}
  19666. done bool
  19667. oldValue func(context.Context) (*EmployeeConfig, error)
  19668. predicates []predicate.EmployeeConfig
  19669. }
  19670. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  19671. // employeeconfigOption allows management of the mutation configuration using functional options.
  19672. type employeeconfigOption func(*EmployeeConfigMutation)
  19673. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  19674. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  19675. m := &EmployeeConfigMutation{
  19676. config: c,
  19677. op: op,
  19678. typ: TypeEmployeeConfig,
  19679. clearedFields: make(map[string]struct{}),
  19680. }
  19681. for _, opt := range opts {
  19682. opt(m)
  19683. }
  19684. return m
  19685. }
  19686. // withEmployeeConfigID sets the ID field of the mutation.
  19687. func withEmployeeConfigID(id uint64) employeeconfigOption {
  19688. return func(m *EmployeeConfigMutation) {
  19689. var (
  19690. err error
  19691. once sync.Once
  19692. value *EmployeeConfig
  19693. )
  19694. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  19695. once.Do(func() {
  19696. if m.done {
  19697. err = errors.New("querying old values post mutation is not allowed")
  19698. } else {
  19699. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  19700. }
  19701. })
  19702. return value, err
  19703. }
  19704. m.id = &id
  19705. }
  19706. }
  19707. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  19708. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  19709. return func(m *EmployeeConfigMutation) {
  19710. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  19711. return node, nil
  19712. }
  19713. m.id = &node.ID
  19714. }
  19715. }
  19716. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19717. // executed in a transaction (ent.Tx), a transactional client is returned.
  19718. func (m EmployeeConfigMutation) Client() *Client {
  19719. client := &Client{config: m.config}
  19720. client.init()
  19721. return client
  19722. }
  19723. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19724. // it returns an error otherwise.
  19725. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  19726. if _, ok := m.driver.(*txDriver); !ok {
  19727. return nil, errors.New("ent: mutation is not running in a transaction")
  19728. }
  19729. tx := &Tx{config: m.config}
  19730. tx.init()
  19731. return tx, nil
  19732. }
  19733. // SetID sets the value of the id field. Note that this
  19734. // operation is only accepted on creation of EmployeeConfig entities.
  19735. func (m *EmployeeConfigMutation) SetID(id uint64) {
  19736. m.id = &id
  19737. }
  19738. // ID returns the ID value in the mutation. Note that the ID is only available
  19739. // if it was provided to the builder or after it was returned from the database.
  19740. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  19741. if m.id == nil {
  19742. return
  19743. }
  19744. return *m.id, true
  19745. }
  19746. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19747. // That means, if the mutation is applied within a transaction with an isolation level such
  19748. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19749. // or updated by the mutation.
  19750. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  19751. switch {
  19752. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19753. id, exists := m.ID()
  19754. if exists {
  19755. return []uint64{id}, nil
  19756. }
  19757. fallthrough
  19758. case m.op.Is(OpUpdate | OpDelete):
  19759. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  19760. default:
  19761. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19762. }
  19763. }
  19764. // SetCreatedAt sets the "created_at" field.
  19765. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  19766. m.created_at = &t
  19767. }
  19768. // CreatedAt returns the value of the "created_at" field in the mutation.
  19769. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  19770. v := m.created_at
  19771. if v == nil {
  19772. return
  19773. }
  19774. return *v, true
  19775. }
  19776. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  19777. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19779. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19780. if !m.op.Is(OpUpdateOne) {
  19781. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19782. }
  19783. if m.id == nil || m.oldValue == nil {
  19784. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19785. }
  19786. oldValue, err := m.oldValue(ctx)
  19787. if err != nil {
  19788. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19789. }
  19790. return oldValue.CreatedAt, nil
  19791. }
  19792. // ResetCreatedAt resets all changes to the "created_at" field.
  19793. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  19794. m.created_at = nil
  19795. }
  19796. // SetUpdatedAt sets the "updated_at" field.
  19797. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  19798. m.updated_at = &t
  19799. }
  19800. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19801. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  19802. v := m.updated_at
  19803. if v == nil {
  19804. return
  19805. }
  19806. return *v, true
  19807. }
  19808. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  19809. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19811. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19812. if !m.op.Is(OpUpdateOne) {
  19813. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19814. }
  19815. if m.id == nil || m.oldValue == nil {
  19816. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19817. }
  19818. oldValue, err := m.oldValue(ctx)
  19819. if err != nil {
  19820. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19821. }
  19822. return oldValue.UpdatedAt, nil
  19823. }
  19824. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19825. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  19826. m.updated_at = nil
  19827. }
  19828. // SetDeletedAt sets the "deleted_at" field.
  19829. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  19830. m.deleted_at = &t
  19831. }
  19832. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19833. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  19834. v := m.deleted_at
  19835. if v == nil {
  19836. return
  19837. }
  19838. return *v, true
  19839. }
  19840. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  19841. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19843. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19844. if !m.op.Is(OpUpdateOne) {
  19845. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19846. }
  19847. if m.id == nil || m.oldValue == nil {
  19848. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19849. }
  19850. oldValue, err := m.oldValue(ctx)
  19851. if err != nil {
  19852. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19853. }
  19854. return oldValue.DeletedAt, nil
  19855. }
  19856. // ClearDeletedAt clears the value of the "deleted_at" field.
  19857. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  19858. m.deleted_at = nil
  19859. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  19860. }
  19861. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19862. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  19863. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  19864. return ok
  19865. }
  19866. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19867. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  19868. m.deleted_at = nil
  19869. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  19870. }
  19871. // SetStype sets the "stype" field.
  19872. func (m *EmployeeConfigMutation) SetStype(s string) {
  19873. m.stype = &s
  19874. }
  19875. // Stype returns the value of the "stype" field in the mutation.
  19876. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  19877. v := m.stype
  19878. if v == nil {
  19879. return
  19880. }
  19881. return *v, true
  19882. }
  19883. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  19884. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19886. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  19887. if !m.op.Is(OpUpdateOne) {
  19888. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  19889. }
  19890. if m.id == nil || m.oldValue == nil {
  19891. return v, errors.New("OldStype requires an ID field in the mutation")
  19892. }
  19893. oldValue, err := m.oldValue(ctx)
  19894. if err != nil {
  19895. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  19896. }
  19897. return oldValue.Stype, nil
  19898. }
  19899. // ResetStype resets all changes to the "stype" field.
  19900. func (m *EmployeeConfigMutation) ResetStype() {
  19901. m.stype = nil
  19902. }
  19903. // SetTitle sets the "title" field.
  19904. func (m *EmployeeConfigMutation) SetTitle(s string) {
  19905. m.title = &s
  19906. }
  19907. // Title returns the value of the "title" field in the mutation.
  19908. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  19909. v := m.title
  19910. if v == nil {
  19911. return
  19912. }
  19913. return *v, true
  19914. }
  19915. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  19916. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19918. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  19919. if !m.op.Is(OpUpdateOne) {
  19920. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  19921. }
  19922. if m.id == nil || m.oldValue == nil {
  19923. return v, errors.New("OldTitle requires an ID field in the mutation")
  19924. }
  19925. oldValue, err := m.oldValue(ctx)
  19926. if err != nil {
  19927. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  19928. }
  19929. return oldValue.Title, nil
  19930. }
  19931. // ResetTitle resets all changes to the "title" field.
  19932. func (m *EmployeeConfigMutation) ResetTitle() {
  19933. m.title = nil
  19934. }
  19935. // SetPhoto sets the "photo" field.
  19936. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  19937. m.photo = &s
  19938. }
  19939. // Photo returns the value of the "photo" field in the mutation.
  19940. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  19941. v := m.photo
  19942. if v == nil {
  19943. return
  19944. }
  19945. return *v, true
  19946. }
  19947. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  19948. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19950. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  19951. if !m.op.Is(OpUpdateOne) {
  19952. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  19953. }
  19954. if m.id == nil || m.oldValue == nil {
  19955. return v, errors.New("OldPhoto requires an ID field in the mutation")
  19956. }
  19957. oldValue, err := m.oldValue(ctx)
  19958. if err != nil {
  19959. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  19960. }
  19961. return oldValue.Photo, nil
  19962. }
  19963. // ResetPhoto resets all changes to the "photo" field.
  19964. func (m *EmployeeConfigMutation) ResetPhoto() {
  19965. m.photo = nil
  19966. }
  19967. // SetOrganizationID sets the "organization_id" field.
  19968. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  19969. m.organization_id = &u
  19970. m.addorganization_id = nil
  19971. }
  19972. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19973. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  19974. v := m.organization_id
  19975. if v == nil {
  19976. return
  19977. }
  19978. return *v, true
  19979. }
  19980. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  19981. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19983. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19984. if !m.op.Is(OpUpdateOne) {
  19985. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19986. }
  19987. if m.id == nil || m.oldValue == nil {
  19988. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19989. }
  19990. oldValue, err := m.oldValue(ctx)
  19991. if err != nil {
  19992. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19993. }
  19994. return oldValue.OrganizationID, nil
  19995. }
  19996. // AddOrganizationID adds u to the "organization_id" field.
  19997. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  19998. if m.addorganization_id != nil {
  19999. *m.addorganization_id += u
  20000. } else {
  20001. m.addorganization_id = &u
  20002. }
  20003. }
  20004. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20005. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  20006. v := m.addorganization_id
  20007. if v == nil {
  20008. return
  20009. }
  20010. return *v, true
  20011. }
  20012. // ClearOrganizationID clears the value of the "organization_id" field.
  20013. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  20014. m.organization_id = nil
  20015. m.addorganization_id = nil
  20016. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  20017. }
  20018. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20019. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  20020. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  20021. return ok
  20022. }
  20023. // ResetOrganizationID resets all changes to the "organization_id" field.
  20024. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  20025. m.organization_id = nil
  20026. m.addorganization_id = nil
  20027. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  20028. }
  20029. // Where appends a list predicates to the EmployeeConfigMutation builder.
  20030. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  20031. m.predicates = append(m.predicates, ps...)
  20032. }
  20033. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  20034. // users can use type-assertion to append predicates that do not depend on any generated package.
  20035. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  20036. p := make([]predicate.EmployeeConfig, len(ps))
  20037. for i := range ps {
  20038. p[i] = ps[i]
  20039. }
  20040. m.Where(p...)
  20041. }
  20042. // Op returns the operation name.
  20043. func (m *EmployeeConfigMutation) Op() Op {
  20044. return m.op
  20045. }
  20046. // SetOp allows setting the mutation operation.
  20047. func (m *EmployeeConfigMutation) SetOp(op Op) {
  20048. m.op = op
  20049. }
  20050. // Type returns the node type of this mutation (EmployeeConfig).
  20051. func (m *EmployeeConfigMutation) Type() string {
  20052. return m.typ
  20053. }
  20054. // Fields returns all fields that were changed during this mutation. Note that in
  20055. // order to get all numeric fields that were incremented/decremented, call
  20056. // AddedFields().
  20057. func (m *EmployeeConfigMutation) Fields() []string {
  20058. fields := make([]string, 0, 7)
  20059. if m.created_at != nil {
  20060. fields = append(fields, employeeconfig.FieldCreatedAt)
  20061. }
  20062. if m.updated_at != nil {
  20063. fields = append(fields, employeeconfig.FieldUpdatedAt)
  20064. }
  20065. if m.deleted_at != nil {
  20066. fields = append(fields, employeeconfig.FieldDeletedAt)
  20067. }
  20068. if m.stype != nil {
  20069. fields = append(fields, employeeconfig.FieldStype)
  20070. }
  20071. if m.title != nil {
  20072. fields = append(fields, employeeconfig.FieldTitle)
  20073. }
  20074. if m.photo != nil {
  20075. fields = append(fields, employeeconfig.FieldPhoto)
  20076. }
  20077. if m.organization_id != nil {
  20078. fields = append(fields, employeeconfig.FieldOrganizationID)
  20079. }
  20080. return fields
  20081. }
  20082. // Field returns the value of a field with the given name. The second boolean
  20083. // return value indicates that this field was not set, or was not defined in the
  20084. // schema.
  20085. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  20086. switch name {
  20087. case employeeconfig.FieldCreatedAt:
  20088. return m.CreatedAt()
  20089. case employeeconfig.FieldUpdatedAt:
  20090. return m.UpdatedAt()
  20091. case employeeconfig.FieldDeletedAt:
  20092. return m.DeletedAt()
  20093. case employeeconfig.FieldStype:
  20094. return m.Stype()
  20095. case employeeconfig.FieldTitle:
  20096. return m.Title()
  20097. case employeeconfig.FieldPhoto:
  20098. return m.Photo()
  20099. case employeeconfig.FieldOrganizationID:
  20100. return m.OrganizationID()
  20101. }
  20102. return nil, false
  20103. }
  20104. // OldField returns the old value of the field from the database. An error is
  20105. // returned if the mutation operation is not UpdateOne, or the query to the
  20106. // database failed.
  20107. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20108. switch name {
  20109. case employeeconfig.FieldCreatedAt:
  20110. return m.OldCreatedAt(ctx)
  20111. case employeeconfig.FieldUpdatedAt:
  20112. return m.OldUpdatedAt(ctx)
  20113. case employeeconfig.FieldDeletedAt:
  20114. return m.OldDeletedAt(ctx)
  20115. case employeeconfig.FieldStype:
  20116. return m.OldStype(ctx)
  20117. case employeeconfig.FieldTitle:
  20118. return m.OldTitle(ctx)
  20119. case employeeconfig.FieldPhoto:
  20120. return m.OldPhoto(ctx)
  20121. case employeeconfig.FieldOrganizationID:
  20122. return m.OldOrganizationID(ctx)
  20123. }
  20124. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  20125. }
  20126. // SetField sets the value of a field with the given name. It returns an error if
  20127. // the field is not defined in the schema, or if the type mismatched the field
  20128. // type.
  20129. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  20130. switch name {
  20131. case employeeconfig.FieldCreatedAt:
  20132. v, ok := value.(time.Time)
  20133. if !ok {
  20134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20135. }
  20136. m.SetCreatedAt(v)
  20137. return nil
  20138. case employeeconfig.FieldUpdatedAt:
  20139. v, ok := value.(time.Time)
  20140. if !ok {
  20141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20142. }
  20143. m.SetUpdatedAt(v)
  20144. return nil
  20145. case employeeconfig.FieldDeletedAt:
  20146. v, ok := value.(time.Time)
  20147. if !ok {
  20148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20149. }
  20150. m.SetDeletedAt(v)
  20151. return nil
  20152. case employeeconfig.FieldStype:
  20153. v, ok := value.(string)
  20154. if !ok {
  20155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20156. }
  20157. m.SetStype(v)
  20158. return nil
  20159. case employeeconfig.FieldTitle:
  20160. v, ok := value.(string)
  20161. if !ok {
  20162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20163. }
  20164. m.SetTitle(v)
  20165. return nil
  20166. case employeeconfig.FieldPhoto:
  20167. v, ok := value.(string)
  20168. if !ok {
  20169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20170. }
  20171. m.SetPhoto(v)
  20172. return nil
  20173. case employeeconfig.FieldOrganizationID:
  20174. v, ok := value.(uint64)
  20175. if !ok {
  20176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20177. }
  20178. m.SetOrganizationID(v)
  20179. return nil
  20180. }
  20181. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20182. }
  20183. // AddedFields returns all numeric fields that were incremented/decremented during
  20184. // this mutation.
  20185. func (m *EmployeeConfigMutation) AddedFields() []string {
  20186. var fields []string
  20187. if m.addorganization_id != nil {
  20188. fields = append(fields, employeeconfig.FieldOrganizationID)
  20189. }
  20190. return fields
  20191. }
  20192. // AddedField returns the numeric value that was incremented/decremented on a field
  20193. // with the given name. The second boolean return value indicates that this field
  20194. // was not set, or was not defined in the schema.
  20195. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  20196. switch name {
  20197. case employeeconfig.FieldOrganizationID:
  20198. return m.AddedOrganizationID()
  20199. }
  20200. return nil, false
  20201. }
  20202. // AddField adds the value to the field with the given name. It returns an error if
  20203. // the field is not defined in the schema, or if the type mismatched the field
  20204. // type.
  20205. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  20206. switch name {
  20207. case employeeconfig.FieldOrganizationID:
  20208. v, ok := value.(int64)
  20209. if !ok {
  20210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20211. }
  20212. m.AddOrganizationID(v)
  20213. return nil
  20214. }
  20215. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  20216. }
  20217. // ClearedFields returns all nullable fields that were cleared during this
  20218. // mutation.
  20219. func (m *EmployeeConfigMutation) ClearedFields() []string {
  20220. var fields []string
  20221. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  20222. fields = append(fields, employeeconfig.FieldDeletedAt)
  20223. }
  20224. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  20225. fields = append(fields, employeeconfig.FieldOrganizationID)
  20226. }
  20227. return fields
  20228. }
  20229. // FieldCleared returns a boolean indicating if a field with the given name was
  20230. // cleared in this mutation.
  20231. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  20232. _, ok := m.clearedFields[name]
  20233. return ok
  20234. }
  20235. // ClearField clears the value of the field with the given name. It returns an
  20236. // error if the field is not defined in the schema.
  20237. func (m *EmployeeConfigMutation) ClearField(name string) error {
  20238. switch name {
  20239. case employeeconfig.FieldDeletedAt:
  20240. m.ClearDeletedAt()
  20241. return nil
  20242. case employeeconfig.FieldOrganizationID:
  20243. m.ClearOrganizationID()
  20244. return nil
  20245. }
  20246. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  20247. }
  20248. // ResetField resets all changes in the mutation for the field with the given name.
  20249. // It returns an error if the field is not defined in the schema.
  20250. func (m *EmployeeConfigMutation) ResetField(name string) error {
  20251. switch name {
  20252. case employeeconfig.FieldCreatedAt:
  20253. m.ResetCreatedAt()
  20254. return nil
  20255. case employeeconfig.FieldUpdatedAt:
  20256. m.ResetUpdatedAt()
  20257. return nil
  20258. case employeeconfig.FieldDeletedAt:
  20259. m.ResetDeletedAt()
  20260. return nil
  20261. case employeeconfig.FieldStype:
  20262. m.ResetStype()
  20263. return nil
  20264. case employeeconfig.FieldTitle:
  20265. m.ResetTitle()
  20266. return nil
  20267. case employeeconfig.FieldPhoto:
  20268. m.ResetPhoto()
  20269. return nil
  20270. case employeeconfig.FieldOrganizationID:
  20271. m.ResetOrganizationID()
  20272. return nil
  20273. }
  20274. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20275. }
  20276. // AddedEdges returns all edge names that were set/added in this mutation.
  20277. func (m *EmployeeConfigMutation) AddedEdges() []string {
  20278. edges := make([]string, 0, 0)
  20279. return edges
  20280. }
  20281. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20282. // name in this mutation.
  20283. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  20284. return nil
  20285. }
  20286. // RemovedEdges returns all edge names that were removed in this mutation.
  20287. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  20288. edges := make([]string, 0, 0)
  20289. return edges
  20290. }
  20291. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20292. // the given name in this mutation.
  20293. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  20294. return nil
  20295. }
  20296. // ClearedEdges returns all edge names that were cleared in this mutation.
  20297. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  20298. edges := make([]string, 0, 0)
  20299. return edges
  20300. }
  20301. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20302. // was cleared in this mutation.
  20303. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  20304. return false
  20305. }
  20306. // ClearEdge clears the value of the edge with the given name. It returns an error
  20307. // if that edge is not defined in the schema.
  20308. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  20309. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  20310. }
  20311. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20312. // It returns an error if the edge is not defined in the schema.
  20313. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  20314. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  20315. }
  20316. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  20317. type LabelMutation struct {
  20318. config
  20319. op Op
  20320. typ string
  20321. id *uint64
  20322. created_at *time.Time
  20323. updated_at *time.Time
  20324. status *uint8
  20325. addstatus *int8
  20326. _type *int
  20327. add_type *int
  20328. name *string
  20329. from *int
  20330. addfrom *int
  20331. mode *int
  20332. addmode *int
  20333. conditions *string
  20334. organization_id *uint64
  20335. addorganization_id *int64
  20336. clearedFields map[string]struct{}
  20337. label_relationships map[uint64]struct{}
  20338. removedlabel_relationships map[uint64]struct{}
  20339. clearedlabel_relationships bool
  20340. done bool
  20341. oldValue func(context.Context) (*Label, error)
  20342. predicates []predicate.Label
  20343. }
  20344. var _ ent.Mutation = (*LabelMutation)(nil)
  20345. // labelOption allows management of the mutation configuration using functional options.
  20346. type labelOption func(*LabelMutation)
  20347. // newLabelMutation creates new mutation for the Label entity.
  20348. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  20349. m := &LabelMutation{
  20350. config: c,
  20351. op: op,
  20352. typ: TypeLabel,
  20353. clearedFields: make(map[string]struct{}),
  20354. }
  20355. for _, opt := range opts {
  20356. opt(m)
  20357. }
  20358. return m
  20359. }
  20360. // withLabelID sets the ID field of the mutation.
  20361. func withLabelID(id uint64) labelOption {
  20362. return func(m *LabelMutation) {
  20363. var (
  20364. err error
  20365. once sync.Once
  20366. value *Label
  20367. )
  20368. m.oldValue = func(ctx context.Context) (*Label, error) {
  20369. once.Do(func() {
  20370. if m.done {
  20371. err = errors.New("querying old values post mutation is not allowed")
  20372. } else {
  20373. value, err = m.Client().Label.Get(ctx, id)
  20374. }
  20375. })
  20376. return value, err
  20377. }
  20378. m.id = &id
  20379. }
  20380. }
  20381. // withLabel sets the old Label of the mutation.
  20382. func withLabel(node *Label) labelOption {
  20383. return func(m *LabelMutation) {
  20384. m.oldValue = func(context.Context) (*Label, error) {
  20385. return node, nil
  20386. }
  20387. m.id = &node.ID
  20388. }
  20389. }
  20390. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20391. // executed in a transaction (ent.Tx), a transactional client is returned.
  20392. func (m LabelMutation) Client() *Client {
  20393. client := &Client{config: m.config}
  20394. client.init()
  20395. return client
  20396. }
  20397. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20398. // it returns an error otherwise.
  20399. func (m LabelMutation) Tx() (*Tx, error) {
  20400. if _, ok := m.driver.(*txDriver); !ok {
  20401. return nil, errors.New("ent: mutation is not running in a transaction")
  20402. }
  20403. tx := &Tx{config: m.config}
  20404. tx.init()
  20405. return tx, nil
  20406. }
  20407. // SetID sets the value of the id field. Note that this
  20408. // operation is only accepted on creation of Label entities.
  20409. func (m *LabelMutation) SetID(id uint64) {
  20410. m.id = &id
  20411. }
  20412. // ID returns the ID value in the mutation. Note that the ID is only available
  20413. // if it was provided to the builder or after it was returned from the database.
  20414. func (m *LabelMutation) ID() (id uint64, exists bool) {
  20415. if m.id == nil {
  20416. return
  20417. }
  20418. return *m.id, true
  20419. }
  20420. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20421. // That means, if the mutation is applied within a transaction with an isolation level such
  20422. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20423. // or updated by the mutation.
  20424. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  20425. switch {
  20426. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20427. id, exists := m.ID()
  20428. if exists {
  20429. return []uint64{id}, nil
  20430. }
  20431. fallthrough
  20432. case m.op.Is(OpUpdate | OpDelete):
  20433. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  20434. default:
  20435. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20436. }
  20437. }
  20438. // SetCreatedAt sets the "created_at" field.
  20439. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  20440. m.created_at = &t
  20441. }
  20442. // CreatedAt returns the value of the "created_at" field in the mutation.
  20443. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  20444. v := m.created_at
  20445. if v == nil {
  20446. return
  20447. }
  20448. return *v, true
  20449. }
  20450. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  20451. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20453. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20454. if !m.op.Is(OpUpdateOne) {
  20455. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20456. }
  20457. if m.id == nil || m.oldValue == nil {
  20458. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20459. }
  20460. oldValue, err := m.oldValue(ctx)
  20461. if err != nil {
  20462. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20463. }
  20464. return oldValue.CreatedAt, nil
  20465. }
  20466. // ResetCreatedAt resets all changes to the "created_at" field.
  20467. func (m *LabelMutation) ResetCreatedAt() {
  20468. m.created_at = nil
  20469. }
  20470. // SetUpdatedAt sets the "updated_at" field.
  20471. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  20472. m.updated_at = &t
  20473. }
  20474. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20475. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  20476. v := m.updated_at
  20477. if v == nil {
  20478. return
  20479. }
  20480. return *v, true
  20481. }
  20482. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  20483. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20485. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20486. if !m.op.Is(OpUpdateOne) {
  20487. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20488. }
  20489. if m.id == nil || m.oldValue == nil {
  20490. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20491. }
  20492. oldValue, err := m.oldValue(ctx)
  20493. if err != nil {
  20494. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20495. }
  20496. return oldValue.UpdatedAt, nil
  20497. }
  20498. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20499. func (m *LabelMutation) ResetUpdatedAt() {
  20500. m.updated_at = nil
  20501. }
  20502. // SetStatus sets the "status" field.
  20503. func (m *LabelMutation) SetStatus(u uint8) {
  20504. m.status = &u
  20505. m.addstatus = nil
  20506. }
  20507. // Status returns the value of the "status" field in the mutation.
  20508. func (m *LabelMutation) Status() (r uint8, exists bool) {
  20509. v := m.status
  20510. if v == nil {
  20511. return
  20512. }
  20513. return *v, true
  20514. }
  20515. // OldStatus returns the old "status" field's value of the Label entity.
  20516. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20518. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20519. if !m.op.Is(OpUpdateOne) {
  20520. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20521. }
  20522. if m.id == nil || m.oldValue == nil {
  20523. return v, errors.New("OldStatus requires an ID field in the mutation")
  20524. }
  20525. oldValue, err := m.oldValue(ctx)
  20526. if err != nil {
  20527. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20528. }
  20529. return oldValue.Status, nil
  20530. }
  20531. // AddStatus adds u to the "status" field.
  20532. func (m *LabelMutation) AddStatus(u int8) {
  20533. if m.addstatus != nil {
  20534. *m.addstatus += u
  20535. } else {
  20536. m.addstatus = &u
  20537. }
  20538. }
  20539. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20540. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  20541. v := m.addstatus
  20542. if v == nil {
  20543. return
  20544. }
  20545. return *v, true
  20546. }
  20547. // ClearStatus clears the value of the "status" field.
  20548. func (m *LabelMutation) ClearStatus() {
  20549. m.status = nil
  20550. m.addstatus = nil
  20551. m.clearedFields[label.FieldStatus] = struct{}{}
  20552. }
  20553. // StatusCleared returns if the "status" field was cleared in this mutation.
  20554. func (m *LabelMutation) StatusCleared() bool {
  20555. _, ok := m.clearedFields[label.FieldStatus]
  20556. return ok
  20557. }
  20558. // ResetStatus resets all changes to the "status" field.
  20559. func (m *LabelMutation) ResetStatus() {
  20560. m.status = nil
  20561. m.addstatus = nil
  20562. delete(m.clearedFields, label.FieldStatus)
  20563. }
  20564. // SetType sets the "type" field.
  20565. func (m *LabelMutation) SetType(i int) {
  20566. m._type = &i
  20567. m.add_type = nil
  20568. }
  20569. // GetType returns the value of the "type" field in the mutation.
  20570. func (m *LabelMutation) GetType() (r int, exists bool) {
  20571. v := m._type
  20572. if v == nil {
  20573. return
  20574. }
  20575. return *v, true
  20576. }
  20577. // OldType returns the old "type" field's value of the Label entity.
  20578. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20580. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  20581. if !m.op.Is(OpUpdateOne) {
  20582. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20583. }
  20584. if m.id == nil || m.oldValue == nil {
  20585. return v, errors.New("OldType requires an ID field in the mutation")
  20586. }
  20587. oldValue, err := m.oldValue(ctx)
  20588. if err != nil {
  20589. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20590. }
  20591. return oldValue.Type, nil
  20592. }
  20593. // AddType adds i to the "type" field.
  20594. func (m *LabelMutation) AddType(i int) {
  20595. if m.add_type != nil {
  20596. *m.add_type += i
  20597. } else {
  20598. m.add_type = &i
  20599. }
  20600. }
  20601. // AddedType returns the value that was added to the "type" field in this mutation.
  20602. func (m *LabelMutation) AddedType() (r int, exists bool) {
  20603. v := m.add_type
  20604. if v == nil {
  20605. return
  20606. }
  20607. return *v, true
  20608. }
  20609. // ResetType resets all changes to the "type" field.
  20610. func (m *LabelMutation) ResetType() {
  20611. m._type = nil
  20612. m.add_type = nil
  20613. }
  20614. // SetName sets the "name" field.
  20615. func (m *LabelMutation) SetName(s string) {
  20616. m.name = &s
  20617. }
  20618. // Name returns the value of the "name" field in the mutation.
  20619. func (m *LabelMutation) Name() (r string, exists bool) {
  20620. v := m.name
  20621. if v == nil {
  20622. return
  20623. }
  20624. return *v, true
  20625. }
  20626. // OldName returns the old "name" field's value of the Label entity.
  20627. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20629. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  20630. if !m.op.Is(OpUpdateOne) {
  20631. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20632. }
  20633. if m.id == nil || m.oldValue == nil {
  20634. return v, errors.New("OldName requires an ID field in the mutation")
  20635. }
  20636. oldValue, err := m.oldValue(ctx)
  20637. if err != nil {
  20638. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20639. }
  20640. return oldValue.Name, nil
  20641. }
  20642. // ResetName resets all changes to the "name" field.
  20643. func (m *LabelMutation) ResetName() {
  20644. m.name = nil
  20645. }
  20646. // SetFrom sets the "from" field.
  20647. func (m *LabelMutation) SetFrom(i int) {
  20648. m.from = &i
  20649. m.addfrom = nil
  20650. }
  20651. // From returns the value of the "from" field in the mutation.
  20652. func (m *LabelMutation) From() (r int, exists bool) {
  20653. v := m.from
  20654. if v == nil {
  20655. return
  20656. }
  20657. return *v, true
  20658. }
  20659. // OldFrom returns the old "from" field's value of the Label entity.
  20660. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20662. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  20663. if !m.op.Is(OpUpdateOne) {
  20664. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  20665. }
  20666. if m.id == nil || m.oldValue == nil {
  20667. return v, errors.New("OldFrom requires an ID field in the mutation")
  20668. }
  20669. oldValue, err := m.oldValue(ctx)
  20670. if err != nil {
  20671. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  20672. }
  20673. return oldValue.From, nil
  20674. }
  20675. // AddFrom adds i to the "from" field.
  20676. func (m *LabelMutation) AddFrom(i int) {
  20677. if m.addfrom != nil {
  20678. *m.addfrom += i
  20679. } else {
  20680. m.addfrom = &i
  20681. }
  20682. }
  20683. // AddedFrom returns the value that was added to the "from" field in this mutation.
  20684. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  20685. v := m.addfrom
  20686. if v == nil {
  20687. return
  20688. }
  20689. return *v, true
  20690. }
  20691. // ResetFrom resets all changes to the "from" field.
  20692. func (m *LabelMutation) ResetFrom() {
  20693. m.from = nil
  20694. m.addfrom = nil
  20695. }
  20696. // SetMode sets the "mode" field.
  20697. func (m *LabelMutation) SetMode(i int) {
  20698. m.mode = &i
  20699. m.addmode = nil
  20700. }
  20701. // Mode returns the value of the "mode" field in the mutation.
  20702. func (m *LabelMutation) Mode() (r int, exists bool) {
  20703. v := m.mode
  20704. if v == nil {
  20705. return
  20706. }
  20707. return *v, true
  20708. }
  20709. // OldMode returns the old "mode" field's value of the Label entity.
  20710. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20712. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  20713. if !m.op.Is(OpUpdateOne) {
  20714. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  20715. }
  20716. if m.id == nil || m.oldValue == nil {
  20717. return v, errors.New("OldMode requires an ID field in the mutation")
  20718. }
  20719. oldValue, err := m.oldValue(ctx)
  20720. if err != nil {
  20721. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  20722. }
  20723. return oldValue.Mode, nil
  20724. }
  20725. // AddMode adds i to the "mode" field.
  20726. func (m *LabelMutation) AddMode(i int) {
  20727. if m.addmode != nil {
  20728. *m.addmode += i
  20729. } else {
  20730. m.addmode = &i
  20731. }
  20732. }
  20733. // AddedMode returns the value that was added to the "mode" field in this mutation.
  20734. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  20735. v := m.addmode
  20736. if v == nil {
  20737. return
  20738. }
  20739. return *v, true
  20740. }
  20741. // ResetMode resets all changes to the "mode" field.
  20742. func (m *LabelMutation) ResetMode() {
  20743. m.mode = nil
  20744. m.addmode = nil
  20745. }
  20746. // SetConditions sets the "conditions" field.
  20747. func (m *LabelMutation) SetConditions(s string) {
  20748. m.conditions = &s
  20749. }
  20750. // Conditions returns the value of the "conditions" field in the mutation.
  20751. func (m *LabelMutation) Conditions() (r string, exists bool) {
  20752. v := m.conditions
  20753. if v == nil {
  20754. return
  20755. }
  20756. return *v, true
  20757. }
  20758. // OldConditions returns the old "conditions" field's value of the Label entity.
  20759. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20761. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  20762. if !m.op.Is(OpUpdateOne) {
  20763. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20764. }
  20765. if m.id == nil || m.oldValue == nil {
  20766. return v, errors.New("OldConditions requires an ID field in the mutation")
  20767. }
  20768. oldValue, err := m.oldValue(ctx)
  20769. if err != nil {
  20770. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20771. }
  20772. return oldValue.Conditions, nil
  20773. }
  20774. // ClearConditions clears the value of the "conditions" field.
  20775. func (m *LabelMutation) ClearConditions() {
  20776. m.conditions = nil
  20777. m.clearedFields[label.FieldConditions] = struct{}{}
  20778. }
  20779. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  20780. func (m *LabelMutation) ConditionsCleared() bool {
  20781. _, ok := m.clearedFields[label.FieldConditions]
  20782. return ok
  20783. }
  20784. // ResetConditions resets all changes to the "conditions" field.
  20785. func (m *LabelMutation) ResetConditions() {
  20786. m.conditions = nil
  20787. delete(m.clearedFields, label.FieldConditions)
  20788. }
  20789. // SetOrganizationID sets the "organization_id" field.
  20790. func (m *LabelMutation) SetOrganizationID(u uint64) {
  20791. m.organization_id = &u
  20792. m.addorganization_id = nil
  20793. }
  20794. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20795. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  20796. v := m.organization_id
  20797. if v == nil {
  20798. return
  20799. }
  20800. return *v, true
  20801. }
  20802. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  20803. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20805. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20806. if !m.op.Is(OpUpdateOne) {
  20807. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20808. }
  20809. if m.id == nil || m.oldValue == nil {
  20810. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20811. }
  20812. oldValue, err := m.oldValue(ctx)
  20813. if err != nil {
  20814. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20815. }
  20816. return oldValue.OrganizationID, nil
  20817. }
  20818. // AddOrganizationID adds u to the "organization_id" field.
  20819. func (m *LabelMutation) AddOrganizationID(u int64) {
  20820. if m.addorganization_id != nil {
  20821. *m.addorganization_id += u
  20822. } else {
  20823. m.addorganization_id = &u
  20824. }
  20825. }
  20826. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20827. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  20828. v := m.addorganization_id
  20829. if v == nil {
  20830. return
  20831. }
  20832. return *v, true
  20833. }
  20834. // ClearOrganizationID clears the value of the "organization_id" field.
  20835. func (m *LabelMutation) ClearOrganizationID() {
  20836. m.organization_id = nil
  20837. m.addorganization_id = nil
  20838. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  20839. }
  20840. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20841. func (m *LabelMutation) OrganizationIDCleared() bool {
  20842. _, ok := m.clearedFields[label.FieldOrganizationID]
  20843. return ok
  20844. }
  20845. // ResetOrganizationID resets all changes to the "organization_id" field.
  20846. func (m *LabelMutation) ResetOrganizationID() {
  20847. m.organization_id = nil
  20848. m.addorganization_id = nil
  20849. delete(m.clearedFields, label.FieldOrganizationID)
  20850. }
  20851. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  20852. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  20853. if m.label_relationships == nil {
  20854. m.label_relationships = make(map[uint64]struct{})
  20855. }
  20856. for i := range ids {
  20857. m.label_relationships[ids[i]] = struct{}{}
  20858. }
  20859. }
  20860. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  20861. func (m *LabelMutation) ClearLabelRelationships() {
  20862. m.clearedlabel_relationships = true
  20863. }
  20864. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  20865. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  20866. return m.clearedlabel_relationships
  20867. }
  20868. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  20869. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  20870. if m.removedlabel_relationships == nil {
  20871. m.removedlabel_relationships = make(map[uint64]struct{})
  20872. }
  20873. for i := range ids {
  20874. delete(m.label_relationships, ids[i])
  20875. m.removedlabel_relationships[ids[i]] = struct{}{}
  20876. }
  20877. }
  20878. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  20879. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  20880. for id := range m.removedlabel_relationships {
  20881. ids = append(ids, id)
  20882. }
  20883. return
  20884. }
  20885. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  20886. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  20887. for id := range m.label_relationships {
  20888. ids = append(ids, id)
  20889. }
  20890. return
  20891. }
  20892. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  20893. func (m *LabelMutation) ResetLabelRelationships() {
  20894. m.label_relationships = nil
  20895. m.clearedlabel_relationships = false
  20896. m.removedlabel_relationships = nil
  20897. }
  20898. // Where appends a list predicates to the LabelMutation builder.
  20899. func (m *LabelMutation) Where(ps ...predicate.Label) {
  20900. m.predicates = append(m.predicates, ps...)
  20901. }
  20902. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  20903. // users can use type-assertion to append predicates that do not depend on any generated package.
  20904. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  20905. p := make([]predicate.Label, len(ps))
  20906. for i := range ps {
  20907. p[i] = ps[i]
  20908. }
  20909. m.Where(p...)
  20910. }
  20911. // Op returns the operation name.
  20912. func (m *LabelMutation) Op() Op {
  20913. return m.op
  20914. }
  20915. // SetOp allows setting the mutation operation.
  20916. func (m *LabelMutation) SetOp(op Op) {
  20917. m.op = op
  20918. }
  20919. // Type returns the node type of this mutation (Label).
  20920. func (m *LabelMutation) Type() string {
  20921. return m.typ
  20922. }
  20923. // Fields returns all fields that were changed during this mutation. Note that in
  20924. // order to get all numeric fields that were incremented/decremented, call
  20925. // AddedFields().
  20926. func (m *LabelMutation) Fields() []string {
  20927. fields := make([]string, 0, 9)
  20928. if m.created_at != nil {
  20929. fields = append(fields, label.FieldCreatedAt)
  20930. }
  20931. if m.updated_at != nil {
  20932. fields = append(fields, label.FieldUpdatedAt)
  20933. }
  20934. if m.status != nil {
  20935. fields = append(fields, label.FieldStatus)
  20936. }
  20937. if m._type != nil {
  20938. fields = append(fields, label.FieldType)
  20939. }
  20940. if m.name != nil {
  20941. fields = append(fields, label.FieldName)
  20942. }
  20943. if m.from != nil {
  20944. fields = append(fields, label.FieldFrom)
  20945. }
  20946. if m.mode != nil {
  20947. fields = append(fields, label.FieldMode)
  20948. }
  20949. if m.conditions != nil {
  20950. fields = append(fields, label.FieldConditions)
  20951. }
  20952. if m.organization_id != nil {
  20953. fields = append(fields, label.FieldOrganizationID)
  20954. }
  20955. return fields
  20956. }
  20957. // Field returns the value of a field with the given name. The second boolean
  20958. // return value indicates that this field was not set, or was not defined in the
  20959. // schema.
  20960. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  20961. switch name {
  20962. case label.FieldCreatedAt:
  20963. return m.CreatedAt()
  20964. case label.FieldUpdatedAt:
  20965. return m.UpdatedAt()
  20966. case label.FieldStatus:
  20967. return m.Status()
  20968. case label.FieldType:
  20969. return m.GetType()
  20970. case label.FieldName:
  20971. return m.Name()
  20972. case label.FieldFrom:
  20973. return m.From()
  20974. case label.FieldMode:
  20975. return m.Mode()
  20976. case label.FieldConditions:
  20977. return m.Conditions()
  20978. case label.FieldOrganizationID:
  20979. return m.OrganizationID()
  20980. }
  20981. return nil, false
  20982. }
  20983. // OldField returns the old value of the field from the database. An error is
  20984. // returned if the mutation operation is not UpdateOne, or the query to the
  20985. // database failed.
  20986. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20987. switch name {
  20988. case label.FieldCreatedAt:
  20989. return m.OldCreatedAt(ctx)
  20990. case label.FieldUpdatedAt:
  20991. return m.OldUpdatedAt(ctx)
  20992. case label.FieldStatus:
  20993. return m.OldStatus(ctx)
  20994. case label.FieldType:
  20995. return m.OldType(ctx)
  20996. case label.FieldName:
  20997. return m.OldName(ctx)
  20998. case label.FieldFrom:
  20999. return m.OldFrom(ctx)
  21000. case label.FieldMode:
  21001. return m.OldMode(ctx)
  21002. case label.FieldConditions:
  21003. return m.OldConditions(ctx)
  21004. case label.FieldOrganizationID:
  21005. return m.OldOrganizationID(ctx)
  21006. }
  21007. return nil, fmt.Errorf("unknown Label field %s", name)
  21008. }
  21009. // SetField sets the value of a field with the given name. It returns an error if
  21010. // the field is not defined in the schema, or if the type mismatched the field
  21011. // type.
  21012. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  21013. switch name {
  21014. case label.FieldCreatedAt:
  21015. v, ok := value.(time.Time)
  21016. if !ok {
  21017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21018. }
  21019. m.SetCreatedAt(v)
  21020. return nil
  21021. case label.FieldUpdatedAt:
  21022. v, ok := value.(time.Time)
  21023. if !ok {
  21024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21025. }
  21026. m.SetUpdatedAt(v)
  21027. return nil
  21028. case label.FieldStatus:
  21029. v, ok := value.(uint8)
  21030. if !ok {
  21031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21032. }
  21033. m.SetStatus(v)
  21034. return nil
  21035. case label.FieldType:
  21036. v, ok := value.(int)
  21037. if !ok {
  21038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21039. }
  21040. m.SetType(v)
  21041. return nil
  21042. case label.FieldName:
  21043. v, ok := value.(string)
  21044. if !ok {
  21045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21046. }
  21047. m.SetName(v)
  21048. return nil
  21049. case label.FieldFrom:
  21050. v, ok := value.(int)
  21051. if !ok {
  21052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21053. }
  21054. m.SetFrom(v)
  21055. return nil
  21056. case label.FieldMode:
  21057. v, ok := value.(int)
  21058. if !ok {
  21059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21060. }
  21061. m.SetMode(v)
  21062. return nil
  21063. case label.FieldConditions:
  21064. v, ok := value.(string)
  21065. if !ok {
  21066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21067. }
  21068. m.SetConditions(v)
  21069. return nil
  21070. case label.FieldOrganizationID:
  21071. v, ok := value.(uint64)
  21072. if !ok {
  21073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21074. }
  21075. m.SetOrganizationID(v)
  21076. return nil
  21077. }
  21078. return fmt.Errorf("unknown Label field %s", name)
  21079. }
  21080. // AddedFields returns all numeric fields that were incremented/decremented during
  21081. // this mutation.
  21082. func (m *LabelMutation) AddedFields() []string {
  21083. var fields []string
  21084. if m.addstatus != nil {
  21085. fields = append(fields, label.FieldStatus)
  21086. }
  21087. if m.add_type != nil {
  21088. fields = append(fields, label.FieldType)
  21089. }
  21090. if m.addfrom != nil {
  21091. fields = append(fields, label.FieldFrom)
  21092. }
  21093. if m.addmode != nil {
  21094. fields = append(fields, label.FieldMode)
  21095. }
  21096. if m.addorganization_id != nil {
  21097. fields = append(fields, label.FieldOrganizationID)
  21098. }
  21099. return fields
  21100. }
  21101. // AddedField returns the numeric value that was incremented/decremented on a field
  21102. // with the given name. The second boolean return value indicates that this field
  21103. // was not set, or was not defined in the schema.
  21104. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  21105. switch name {
  21106. case label.FieldStatus:
  21107. return m.AddedStatus()
  21108. case label.FieldType:
  21109. return m.AddedType()
  21110. case label.FieldFrom:
  21111. return m.AddedFrom()
  21112. case label.FieldMode:
  21113. return m.AddedMode()
  21114. case label.FieldOrganizationID:
  21115. return m.AddedOrganizationID()
  21116. }
  21117. return nil, false
  21118. }
  21119. // AddField adds the value to the field with the given name. It returns an error if
  21120. // the field is not defined in the schema, or if the type mismatched the field
  21121. // type.
  21122. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  21123. switch name {
  21124. case label.FieldStatus:
  21125. v, ok := value.(int8)
  21126. if !ok {
  21127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21128. }
  21129. m.AddStatus(v)
  21130. return nil
  21131. case label.FieldType:
  21132. v, ok := value.(int)
  21133. if !ok {
  21134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21135. }
  21136. m.AddType(v)
  21137. return nil
  21138. case label.FieldFrom:
  21139. v, ok := value.(int)
  21140. if !ok {
  21141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21142. }
  21143. m.AddFrom(v)
  21144. return nil
  21145. case label.FieldMode:
  21146. v, ok := value.(int)
  21147. if !ok {
  21148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21149. }
  21150. m.AddMode(v)
  21151. return nil
  21152. case label.FieldOrganizationID:
  21153. v, ok := value.(int64)
  21154. if !ok {
  21155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21156. }
  21157. m.AddOrganizationID(v)
  21158. return nil
  21159. }
  21160. return fmt.Errorf("unknown Label numeric field %s", name)
  21161. }
  21162. // ClearedFields returns all nullable fields that were cleared during this
  21163. // mutation.
  21164. func (m *LabelMutation) ClearedFields() []string {
  21165. var fields []string
  21166. if m.FieldCleared(label.FieldStatus) {
  21167. fields = append(fields, label.FieldStatus)
  21168. }
  21169. if m.FieldCleared(label.FieldConditions) {
  21170. fields = append(fields, label.FieldConditions)
  21171. }
  21172. if m.FieldCleared(label.FieldOrganizationID) {
  21173. fields = append(fields, label.FieldOrganizationID)
  21174. }
  21175. return fields
  21176. }
  21177. // FieldCleared returns a boolean indicating if a field with the given name was
  21178. // cleared in this mutation.
  21179. func (m *LabelMutation) FieldCleared(name string) bool {
  21180. _, ok := m.clearedFields[name]
  21181. return ok
  21182. }
  21183. // ClearField clears the value of the field with the given name. It returns an
  21184. // error if the field is not defined in the schema.
  21185. func (m *LabelMutation) ClearField(name string) error {
  21186. switch name {
  21187. case label.FieldStatus:
  21188. m.ClearStatus()
  21189. return nil
  21190. case label.FieldConditions:
  21191. m.ClearConditions()
  21192. return nil
  21193. case label.FieldOrganizationID:
  21194. m.ClearOrganizationID()
  21195. return nil
  21196. }
  21197. return fmt.Errorf("unknown Label nullable field %s", name)
  21198. }
  21199. // ResetField resets all changes in the mutation for the field with the given name.
  21200. // It returns an error if the field is not defined in the schema.
  21201. func (m *LabelMutation) ResetField(name string) error {
  21202. switch name {
  21203. case label.FieldCreatedAt:
  21204. m.ResetCreatedAt()
  21205. return nil
  21206. case label.FieldUpdatedAt:
  21207. m.ResetUpdatedAt()
  21208. return nil
  21209. case label.FieldStatus:
  21210. m.ResetStatus()
  21211. return nil
  21212. case label.FieldType:
  21213. m.ResetType()
  21214. return nil
  21215. case label.FieldName:
  21216. m.ResetName()
  21217. return nil
  21218. case label.FieldFrom:
  21219. m.ResetFrom()
  21220. return nil
  21221. case label.FieldMode:
  21222. m.ResetMode()
  21223. return nil
  21224. case label.FieldConditions:
  21225. m.ResetConditions()
  21226. return nil
  21227. case label.FieldOrganizationID:
  21228. m.ResetOrganizationID()
  21229. return nil
  21230. }
  21231. return fmt.Errorf("unknown Label field %s", name)
  21232. }
  21233. // AddedEdges returns all edge names that were set/added in this mutation.
  21234. func (m *LabelMutation) AddedEdges() []string {
  21235. edges := make([]string, 0, 1)
  21236. if m.label_relationships != nil {
  21237. edges = append(edges, label.EdgeLabelRelationships)
  21238. }
  21239. return edges
  21240. }
  21241. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21242. // name in this mutation.
  21243. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  21244. switch name {
  21245. case label.EdgeLabelRelationships:
  21246. ids := make([]ent.Value, 0, len(m.label_relationships))
  21247. for id := range m.label_relationships {
  21248. ids = append(ids, id)
  21249. }
  21250. return ids
  21251. }
  21252. return nil
  21253. }
  21254. // RemovedEdges returns all edge names that were removed in this mutation.
  21255. func (m *LabelMutation) RemovedEdges() []string {
  21256. edges := make([]string, 0, 1)
  21257. if m.removedlabel_relationships != nil {
  21258. edges = append(edges, label.EdgeLabelRelationships)
  21259. }
  21260. return edges
  21261. }
  21262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21263. // the given name in this mutation.
  21264. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  21265. switch name {
  21266. case label.EdgeLabelRelationships:
  21267. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  21268. for id := range m.removedlabel_relationships {
  21269. ids = append(ids, id)
  21270. }
  21271. return ids
  21272. }
  21273. return nil
  21274. }
  21275. // ClearedEdges returns all edge names that were cleared in this mutation.
  21276. func (m *LabelMutation) ClearedEdges() []string {
  21277. edges := make([]string, 0, 1)
  21278. if m.clearedlabel_relationships {
  21279. edges = append(edges, label.EdgeLabelRelationships)
  21280. }
  21281. return edges
  21282. }
  21283. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21284. // was cleared in this mutation.
  21285. func (m *LabelMutation) EdgeCleared(name string) bool {
  21286. switch name {
  21287. case label.EdgeLabelRelationships:
  21288. return m.clearedlabel_relationships
  21289. }
  21290. return false
  21291. }
  21292. // ClearEdge clears the value of the edge with the given name. It returns an error
  21293. // if that edge is not defined in the schema.
  21294. func (m *LabelMutation) ClearEdge(name string) error {
  21295. switch name {
  21296. }
  21297. return fmt.Errorf("unknown Label unique edge %s", name)
  21298. }
  21299. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21300. // It returns an error if the edge is not defined in the schema.
  21301. func (m *LabelMutation) ResetEdge(name string) error {
  21302. switch name {
  21303. case label.EdgeLabelRelationships:
  21304. m.ResetLabelRelationships()
  21305. return nil
  21306. }
  21307. return fmt.Errorf("unknown Label edge %s", name)
  21308. }
  21309. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  21310. type LabelLogMutation struct {
  21311. config
  21312. op Op
  21313. typ string
  21314. id *uint64
  21315. created_at *time.Time
  21316. updated_at *time.Time
  21317. label_name *string
  21318. label_id *int
  21319. addlabel_id *int
  21320. wx_id *string
  21321. organization_id *uint64
  21322. addorganization_id *int64
  21323. clearedFields map[string]struct{}
  21324. done bool
  21325. oldValue func(context.Context) (*LabelLog, error)
  21326. predicates []predicate.LabelLog
  21327. }
  21328. var _ ent.Mutation = (*LabelLogMutation)(nil)
  21329. // labellogOption allows management of the mutation configuration using functional options.
  21330. type labellogOption func(*LabelLogMutation)
  21331. // newLabelLogMutation creates new mutation for the LabelLog entity.
  21332. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  21333. m := &LabelLogMutation{
  21334. config: c,
  21335. op: op,
  21336. typ: TypeLabelLog,
  21337. clearedFields: make(map[string]struct{}),
  21338. }
  21339. for _, opt := range opts {
  21340. opt(m)
  21341. }
  21342. return m
  21343. }
  21344. // withLabelLogID sets the ID field of the mutation.
  21345. func withLabelLogID(id uint64) labellogOption {
  21346. return func(m *LabelLogMutation) {
  21347. var (
  21348. err error
  21349. once sync.Once
  21350. value *LabelLog
  21351. )
  21352. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  21353. once.Do(func() {
  21354. if m.done {
  21355. err = errors.New("querying old values post mutation is not allowed")
  21356. } else {
  21357. value, err = m.Client().LabelLog.Get(ctx, id)
  21358. }
  21359. })
  21360. return value, err
  21361. }
  21362. m.id = &id
  21363. }
  21364. }
  21365. // withLabelLog sets the old LabelLog of the mutation.
  21366. func withLabelLog(node *LabelLog) labellogOption {
  21367. return func(m *LabelLogMutation) {
  21368. m.oldValue = func(context.Context) (*LabelLog, error) {
  21369. return node, nil
  21370. }
  21371. m.id = &node.ID
  21372. }
  21373. }
  21374. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21375. // executed in a transaction (ent.Tx), a transactional client is returned.
  21376. func (m LabelLogMutation) Client() *Client {
  21377. client := &Client{config: m.config}
  21378. client.init()
  21379. return client
  21380. }
  21381. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21382. // it returns an error otherwise.
  21383. func (m LabelLogMutation) Tx() (*Tx, error) {
  21384. if _, ok := m.driver.(*txDriver); !ok {
  21385. return nil, errors.New("ent: mutation is not running in a transaction")
  21386. }
  21387. tx := &Tx{config: m.config}
  21388. tx.init()
  21389. return tx, nil
  21390. }
  21391. // SetID sets the value of the id field. Note that this
  21392. // operation is only accepted on creation of LabelLog entities.
  21393. func (m *LabelLogMutation) SetID(id uint64) {
  21394. m.id = &id
  21395. }
  21396. // ID returns the ID value in the mutation. Note that the ID is only available
  21397. // if it was provided to the builder or after it was returned from the database.
  21398. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  21399. if m.id == nil {
  21400. return
  21401. }
  21402. return *m.id, true
  21403. }
  21404. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21405. // That means, if the mutation is applied within a transaction with an isolation level such
  21406. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21407. // or updated by the mutation.
  21408. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  21409. switch {
  21410. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21411. id, exists := m.ID()
  21412. if exists {
  21413. return []uint64{id}, nil
  21414. }
  21415. fallthrough
  21416. case m.op.Is(OpUpdate | OpDelete):
  21417. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  21418. default:
  21419. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21420. }
  21421. }
  21422. // SetCreatedAt sets the "created_at" field.
  21423. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  21424. m.created_at = &t
  21425. }
  21426. // CreatedAt returns the value of the "created_at" field in the mutation.
  21427. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  21428. v := m.created_at
  21429. if v == nil {
  21430. return
  21431. }
  21432. return *v, true
  21433. }
  21434. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  21435. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21437. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21438. if !m.op.Is(OpUpdateOne) {
  21439. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21440. }
  21441. if m.id == nil || m.oldValue == nil {
  21442. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21443. }
  21444. oldValue, err := m.oldValue(ctx)
  21445. if err != nil {
  21446. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21447. }
  21448. return oldValue.CreatedAt, nil
  21449. }
  21450. // ResetCreatedAt resets all changes to the "created_at" field.
  21451. func (m *LabelLogMutation) ResetCreatedAt() {
  21452. m.created_at = nil
  21453. }
  21454. // SetUpdatedAt sets the "updated_at" field.
  21455. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  21456. m.updated_at = &t
  21457. }
  21458. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21459. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  21460. v := m.updated_at
  21461. if v == nil {
  21462. return
  21463. }
  21464. return *v, true
  21465. }
  21466. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  21467. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21469. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21470. if !m.op.Is(OpUpdateOne) {
  21471. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21472. }
  21473. if m.id == nil || m.oldValue == nil {
  21474. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21475. }
  21476. oldValue, err := m.oldValue(ctx)
  21477. if err != nil {
  21478. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21479. }
  21480. return oldValue.UpdatedAt, nil
  21481. }
  21482. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21483. func (m *LabelLogMutation) ResetUpdatedAt() {
  21484. m.updated_at = nil
  21485. }
  21486. // SetLabelName sets the "label_name" field.
  21487. func (m *LabelLogMutation) SetLabelName(s string) {
  21488. m.label_name = &s
  21489. }
  21490. // LabelName returns the value of the "label_name" field in the mutation.
  21491. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  21492. v := m.label_name
  21493. if v == nil {
  21494. return
  21495. }
  21496. return *v, true
  21497. }
  21498. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  21499. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21501. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  21502. if !m.op.Is(OpUpdateOne) {
  21503. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  21504. }
  21505. if m.id == nil || m.oldValue == nil {
  21506. return v, errors.New("OldLabelName requires an ID field in the mutation")
  21507. }
  21508. oldValue, err := m.oldValue(ctx)
  21509. if err != nil {
  21510. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  21511. }
  21512. return oldValue.LabelName, nil
  21513. }
  21514. // ResetLabelName resets all changes to the "label_name" field.
  21515. func (m *LabelLogMutation) ResetLabelName() {
  21516. m.label_name = nil
  21517. }
  21518. // SetLabelID sets the "label_id" field.
  21519. func (m *LabelLogMutation) SetLabelID(i int) {
  21520. m.label_id = &i
  21521. m.addlabel_id = nil
  21522. }
  21523. // LabelID returns the value of the "label_id" field in the mutation.
  21524. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  21525. v := m.label_id
  21526. if v == nil {
  21527. return
  21528. }
  21529. return *v, true
  21530. }
  21531. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  21532. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21534. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  21535. if !m.op.Is(OpUpdateOne) {
  21536. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21537. }
  21538. if m.id == nil || m.oldValue == nil {
  21539. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21540. }
  21541. oldValue, err := m.oldValue(ctx)
  21542. if err != nil {
  21543. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21544. }
  21545. return oldValue.LabelID, nil
  21546. }
  21547. // AddLabelID adds i to the "label_id" field.
  21548. func (m *LabelLogMutation) AddLabelID(i int) {
  21549. if m.addlabel_id != nil {
  21550. *m.addlabel_id += i
  21551. } else {
  21552. m.addlabel_id = &i
  21553. }
  21554. }
  21555. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  21556. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  21557. v := m.addlabel_id
  21558. if v == nil {
  21559. return
  21560. }
  21561. return *v, true
  21562. }
  21563. // ResetLabelID resets all changes to the "label_id" field.
  21564. func (m *LabelLogMutation) ResetLabelID() {
  21565. m.label_id = nil
  21566. m.addlabel_id = nil
  21567. }
  21568. // SetWxID sets the "wx_id" field.
  21569. func (m *LabelLogMutation) SetWxID(s string) {
  21570. m.wx_id = &s
  21571. }
  21572. // WxID returns the value of the "wx_id" field in the mutation.
  21573. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  21574. v := m.wx_id
  21575. if v == nil {
  21576. return
  21577. }
  21578. return *v, true
  21579. }
  21580. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  21581. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21583. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  21584. if !m.op.Is(OpUpdateOne) {
  21585. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  21586. }
  21587. if m.id == nil || m.oldValue == nil {
  21588. return v, errors.New("OldWxID requires an ID field in the mutation")
  21589. }
  21590. oldValue, err := m.oldValue(ctx)
  21591. if err != nil {
  21592. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  21593. }
  21594. return oldValue.WxID, nil
  21595. }
  21596. // ResetWxID resets all changes to the "wx_id" field.
  21597. func (m *LabelLogMutation) ResetWxID() {
  21598. m.wx_id = nil
  21599. }
  21600. // SetOrganizationID sets the "organization_id" field.
  21601. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  21602. m.organization_id = &u
  21603. m.addorganization_id = nil
  21604. }
  21605. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21606. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  21607. v := m.organization_id
  21608. if v == nil {
  21609. return
  21610. }
  21611. return *v, true
  21612. }
  21613. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  21614. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21616. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21617. if !m.op.Is(OpUpdateOne) {
  21618. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21619. }
  21620. if m.id == nil || m.oldValue == nil {
  21621. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21622. }
  21623. oldValue, err := m.oldValue(ctx)
  21624. if err != nil {
  21625. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21626. }
  21627. return oldValue.OrganizationID, nil
  21628. }
  21629. // AddOrganizationID adds u to the "organization_id" field.
  21630. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  21631. if m.addorganization_id != nil {
  21632. *m.addorganization_id += u
  21633. } else {
  21634. m.addorganization_id = &u
  21635. }
  21636. }
  21637. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21638. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  21639. v := m.addorganization_id
  21640. if v == nil {
  21641. return
  21642. }
  21643. return *v, true
  21644. }
  21645. // ClearOrganizationID clears the value of the "organization_id" field.
  21646. func (m *LabelLogMutation) ClearOrganizationID() {
  21647. m.organization_id = nil
  21648. m.addorganization_id = nil
  21649. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  21650. }
  21651. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21652. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  21653. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  21654. return ok
  21655. }
  21656. // ResetOrganizationID resets all changes to the "organization_id" field.
  21657. func (m *LabelLogMutation) ResetOrganizationID() {
  21658. m.organization_id = nil
  21659. m.addorganization_id = nil
  21660. delete(m.clearedFields, labellog.FieldOrganizationID)
  21661. }
  21662. // Where appends a list predicates to the LabelLogMutation builder.
  21663. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  21664. m.predicates = append(m.predicates, ps...)
  21665. }
  21666. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  21667. // users can use type-assertion to append predicates that do not depend on any generated package.
  21668. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  21669. p := make([]predicate.LabelLog, len(ps))
  21670. for i := range ps {
  21671. p[i] = ps[i]
  21672. }
  21673. m.Where(p...)
  21674. }
  21675. // Op returns the operation name.
  21676. func (m *LabelLogMutation) Op() Op {
  21677. return m.op
  21678. }
  21679. // SetOp allows setting the mutation operation.
  21680. func (m *LabelLogMutation) SetOp(op Op) {
  21681. m.op = op
  21682. }
  21683. // Type returns the node type of this mutation (LabelLog).
  21684. func (m *LabelLogMutation) Type() string {
  21685. return m.typ
  21686. }
  21687. // Fields returns all fields that were changed during this mutation. Note that in
  21688. // order to get all numeric fields that were incremented/decremented, call
  21689. // AddedFields().
  21690. func (m *LabelLogMutation) Fields() []string {
  21691. fields := make([]string, 0, 6)
  21692. if m.created_at != nil {
  21693. fields = append(fields, labellog.FieldCreatedAt)
  21694. }
  21695. if m.updated_at != nil {
  21696. fields = append(fields, labellog.FieldUpdatedAt)
  21697. }
  21698. if m.label_name != nil {
  21699. fields = append(fields, labellog.FieldLabelName)
  21700. }
  21701. if m.label_id != nil {
  21702. fields = append(fields, labellog.FieldLabelID)
  21703. }
  21704. if m.wx_id != nil {
  21705. fields = append(fields, labellog.FieldWxID)
  21706. }
  21707. if m.organization_id != nil {
  21708. fields = append(fields, labellog.FieldOrganizationID)
  21709. }
  21710. return fields
  21711. }
  21712. // Field returns the value of a field with the given name. The second boolean
  21713. // return value indicates that this field was not set, or was not defined in the
  21714. // schema.
  21715. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  21716. switch name {
  21717. case labellog.FieldCreatedAt:
  21718. return m.CreatedAt()
  21719. case labellog.FieldUpdatedAt:
  21720. return m.UpdatedAt()
  21721. case labellog.FieldLabelName:
  21722. return m.LabelName()
  21723. case labellog.FieldLabelID:
  21724. return m.LabelID()
  21725. case labellog.FieldWxID:
  21726. return m.WxID()
  21727. case labellog.FieldOrganizationID:
  21728. return m.OrganizationID()
  21729. }
  21730. return nil, false
  21731. }
  21732. // OldField returns the old value of the field from the database. An error is
  21733. // returned if the mutation operation is not UpdateOne, or the query to the
  21734. // database failed.
  21735. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21736. switch name {
  21737. case labellog.FieldCreatedAt:
  21738. return m.OldCreatedAt(ctx)
  21739. case labellog.FieldUpdatedAt:
  21740. return m.OldUpdatedAt(ctx)
  21741. case labellog.FieldLabelName:
  21742. return m.OldLabelName(ctx)
  21743. case labellog.FieldLabelID:
  21744. return m.OldLabelID(ctx)
  21745. case labellog.FieldWxID:
  21746. return m.OldWxID(ctx)
  21747. case labellog.FieldOrganizationID:
  21748. return m.OldOrganizationID(ctx)
  21749. }
  21750. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  21751. }
  21752. // SetField sets the value of a field with the given name. It returns an error if
  21753. // the field is not defined in the schema, or if the type mismatched the field
  21754. // type.
  21755. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  21756. switch name {
  21757. case labellog.FieldCreatedAt:
  21758. v, ok := value.(time.Time)
  21759. if !ok {
  21760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21761. }
  21762. m.SetCreatedAt(v)
  21763. return nil
  21764. case labellog.FieldUpdatedAt:
  21765. v, ok := value.(time.Time)
  21766. if !ok {
  21767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21768. }
  21769. m.SetUpdatedAt(v)
  21770. return nil
  21771. case labellog.FieldLabelName:
  21772. v, ok := value.(string)
  21773. if !ok {
  21774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21775. }
  21776. m.SetLabelName(v)
  21777. return nil
  21778. case labellog.FieldLabelID:
  21779. v, ok := value.(int)
  21780. if !ok {
  21781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21782. }
  21783. m.SetLabelID(v)
  21784. return nil
  21785. case labellog.FieldWxID:
  21786. v, ok := value.(string)
  21787. if !ok {
  21788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21789. }
  21790. m.SetWxID(v)
  21791. return nil
  21792. case labellog.FieldOrganizationID:
  21793. v, ok := value.(uint64)
  21794. if !ok {
  21795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21796. }
  21797. m.SetOrganizationID(v)
  21798. return nil
  21799. }
  21800. return fmt.Errorf("unknown LabelLog field %s", name)
  21801. }
  21802. // AddedFields returns all numeric fields that were incremented/decremented during
  21803. // this mutation.
  21804. func (m *LabelLogMutation) AddedFields() []string {
  21805. var fields []string
  21806. if m.addlabel_id != nil {
  21807. fields = append(fields, labellog.FieldLabelID)
  21808. }
  21809. if m.addorganization_id != nil {
  21810. fields = append(fields, labellog.FieldOrganizationID)
  21811. }
  21812. return fields
  21813. }
  21814. // AddedField returns the numeric value that was incremented/decremented on a field
  21815. // with the given name. The second boolean return value indicates that this field
  21816. // was not set, or was not defined in the schema.
  21817. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  21818. switch name {
  21819. case labellog.FieldLabelID:
  21820. return m.AddedLabelID()
  21821. case labellog.FieldOrganizationID:
  21822. return m.AddedOrganizationID()
  21823. }
  21824. return nil, false
  21825. }
  21826. // AddField adds the value to the field with the given name. It returns an error if
  21827. // the field is not defined in the schema, or if the type mismatched the field
  21828. // type.
  21829. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  21830. switch name {
  21831. case labellog.FieldLabelID:
  21832. v, ok := value.(int)
  21833. if !ok {
  21834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21835. }
  21836. m.AddLabelID(v)
  21837. return nil
  21838. case labellog.FieldOrganizationID:
  21839. v, ok := value.(int64)
  21840. if !ok {
  21841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21842. }
  21843. m.AddOrganizationID(v)
  21844. return nil
  21845. }
  21846. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  21847. }
  21848. // ClearedFields returns all nullable fields that were cleared during this
  21849. // mutation.
  21850. func (m *LabelLogMutation) ClearedFields() []string {
  21851. var fields []string
  21852. if m.FieldCleared(labellog.FieldOrganizationID) {
  21853. fields = append(fields, labellog.FieldOrganizationID)
  21854. }
  21855. return fields
  21856. }
  21857. // FieldCleared returns a boolean indicating if a field with the given name was
  21858. // cleared in this mutation.
  21859. func (m *LabelLogMutation) FieldCleared(name string) bool {
  21860. _, ok := m.clearedFields[name]
  21861. return ok
  21862. }
  21863. // ClearField clears the value of the field with the given name. It returns an
  21864. // error if the field is not defined in the schema.
  21865. func (m *LabelLogMutation) ClearField(name string) error {
  21866. switch name {
  21867. case labellog.FieldOrganizationID:
  21868. m.ClearOrganizationID()
  21869. return nil
  21870. }
  21871. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  21872. }
  21873. // ResetField resets all changes in the mutation for the field with the given name.
  21874. // It returns an error if the field is not defined in the schema.
  21875. func (m *LabelLogMutation) ResetField(name string) error {
  21876. switch name {
  21877. case labellog.FieldCreatedAt:
  21878. m.ResetCreatedAt()
  21879. return nil
  21880. case labellog.FieldUpdatedAt:
  21881. m.ResetUpdatedAt()
  21882. return nil
  21883. case labellog.FieldLabelName:
  21884. m.ResetLabelName()
  21885. return nil
  21886. case labellog.FieldLabelID:
  21887. m.ResetLabelID()
  21888. return nil
  21889. case labellog.FieldWxID:
  21890. m.ResetWxID()
  21891. return nil
  21892. case labellog.FieldOrganizationID:
  21893. m.ResetOrganizationID()
  21894. return nil
  21895. }
  21896. return fmt.Errorf("unknown LabelLog field %s", name)
  21897. }
  21898. // AddedEdges returns all edge names that were set/added in this mutation.
  21899. func (m *LabelLogMutation) AddedEdges() []string {
  21900. edges := make([]string, 0, 0)
  21901. return edges
  21902. }
  21903. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21904. // name in this mutation.
  21905. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  21906. return nil
  21907. }
  21908. // RemovedEdges returns all edge names that were removed in this mutation.
  21909. func (m *LabelLogMutation) RemovedEdges() []string {
  21910. edges := make([]string, 0, 0)
  21911. return edges
  21912. }
  21913. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21914. // the given name in this mutation.
  21915. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  21916. return nil
  21917. }
  21918. // ClearedEdges returns all edge names that were cleared in this mutation.
  21919. func (m *LabelLogMutation) ClearedEdges() []string {
  21920. edges := make([]string, 0, 0)
  21921. return edges
  21922. }
  21923. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21924. // was cleared in this mutation.
  21925. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  21926. return false
  21927. }
  21928. // ClearEdge clears the value of the edge with the given name. It returns an error
  21929. // if that edge is not defined in the schema.
  21930. func (m *LabelLogMutation) ClearEdge(name string) error {
  21931. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  21932. }
  21933. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21934. // It returns an error if the edge is not defined in the schema.
  21935. func (m *LabelLogMutation) ResetEdge(name string) error {
  21936. return fmt.Errorf("unknown LabelLog edge %s", name)
  21937. }
  21938. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  21939. type LabelRelationshipMutation struct {
  21940. config
  21941. op Op
  21942. typ string
  21943. id *uint64
  21944. created_at *time.Time
  21945. updated_at *time.Time
  21946. status *uint8
  21947. addstatus *int8
  21948. organization_id *uint64
  21949. addorganization_id *int64
  21950. clearedFields map[string]struct{}
  21951. contacts *uint64
  21952. clearedcontacts bool
  21953. labels *uint64
  21954. clearedlabels bool
  21955. done bool
  21956. oldValue func(context.Context) (*LabelRelationship, error)
  21957. predicates []predicate.LabelRelationship
  21958. }
  21959. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  21960. // labelrelationshipOption allows management of the mutation configuration using functional options.
  21961. type labelrelationshipOption func(*LabelRelationshipMutation)
  21962. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  21963. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  21964. m := &LabelRelationshipMutation{
  21965. config: c,
  21966. op: op,
  21967. typ: TypeLabelRelationship,
  21968. clearedFields: make(map[string]struct{}),
  21969. }
  21970. for _, opt := range opts {
  21971. opt(m)
  21972. }
  21973. return m
  21974. }
  21975. // withLabelRelationshipID sets the ID field of the mutation.
  21976. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  21977. return func(m *LabelRelationshipMutation) {
  21978. var (
  21979. err error
  21980. once sync.Once
  21981. value *LabelRelationship
  21982. )
  21983. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  21984. once.Do(func() {
  21985. if m.done {
  21986. err = errors.New("querying old values post mutation is not allowed")
  21987. } else {
  21988. value, err = m.Client().LabelRelationship.Get(ctx, id)
  21989. }
  21990. })
  21991. return value, err
  21992. }
  21993. m.id = &id
  21994. }
  21995. }
  21996. // withLabelRelationship sets the old LabelRelationship of the mutation.
  21997. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  21998. return func(m *LabelRelationshipMutation) {
  21999. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  22000. return node, nil
  22001. }
  22002. m.id = &node.ID
  22003. }
  22004. }
  22005. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22006. // executed in a transaction (ent.Tx), a transactional client is returned.
  22007. func (m LabelRelationshipMutation) Client() *Client {
  22008. client := &Client{config: m.config}
  22009. client.init()
  22010. return client
  22011. }
  22012. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22013. // it returns an error otherwise.
  22014. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  22015. if _, ok := m.driver.(*txDriver); !ok {
  22016. return nil, errors.New("ent: mutation is not running in a transaction")
  22017. }
  22018. tx := &Tx{config: m.config}
  22019. tx.init()
  22020. return tx, nil
  22021. }
  22022. // SetID sets the value of the id field. Note that this
  22023. // operation is only accepted on creation of LabelRelationship entities.
  22024. func (m *LabelRelationshipMutation) SetID(id uint64) {
  22025. m.id = &id
  22026. }
  22027. // ID returns the ID value in the mutation. Note that the ID is only available
  22028. // if it was provided to the builder or after it was returned from the database.
  22029. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  22030. if m.id == nil {
  22031. return
  22032. }
  22033. return *m.id, true
  22034. }
  22035. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22036. // That means, if the mutation is applied within a transaction with an isolation level such
  22037. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22038. // or updated by the mutation.
  22039. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  22040. switch {
  22041. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22042. id, exists := m.ID()
  22043. if exists {
  22044. return []uint64{id}, nil
  22045. }
  22046. fallthrough
  22047. case m.op.Is(OpUpdate | OpDelete):
  22048. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  22049. default:
  22050. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22051. }
  22052. }
  22053. // SetCreatedAt sets the "created_at" field.
  22054. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  22055. m.created_at = &t
  22056. }
  22057. // CreatedAt returns the value of the "created_at" field in the mutation.
  22058. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  22059. v := m.created_at
  22060. if v == nil {
  22061. return
  22062. }
  22063. return *v, true
  22064. }
  22065. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  22066. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22068. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22069. if !m.op.Is(OpUpdateOne) {
  22070. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22071. }
  22072. if m.id == nil || m.oldValue == nil {
  22073. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22074. }
  22075. oldValue, err := m.oldValue(ctx)
  22076. if err != nil {
  22077. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22078. }
  22079. return oldValue.CreatedAt, nil
  22080. }
  22081. // ResetCreatedAt resets all changes to the "created_at" field.
  22082. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  22083. m.created_at = nil
  22084. }
  22085. // SetUpdatedAt sets the "updated_at" field.
  22086. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  22087. m.updated_at = &t
  22088. }
  22089. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22090. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  22091. v := m.updated_at
  22092. if v == nil {
  22093. return
  22094. }
  22095. return *v, true
  22096. }
  22097. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  22098. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22100. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22101. if !m.op.Is(OpUpdateOne) {
  22102. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22103. }
  22104. if m.id == nil || m.oldValue == nil {
  22105. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22106. }
  22107. oldValue, err := m.oldValue(ctx)
  22108. if err != nil {
  22109. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22110. }
  22111. return oldValue.UpdatedAt, nil
  22112. }
  22113. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22114. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  22115. m.updated_at = nil
  22116. }
  22117. // SetStatus sets the "status" field.
  22118. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  22119. m.status = &u
  22120. m.addstatus = nil
  22121. }
  22122. // Status returns the value of the "status" field in the mutation.
  22123. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  22124. v := m.status
  22125. if v == nil {
  22126. return
  22127. }
  22128. return *v, true
  22129. }
  22130. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  22131. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22133. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22134. if !m.op.Is(OpUpdateOne) {
  22135. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22136. }
  22137. if m.id == nil || m.oldValue == nil {
  22138. return v, errors.New("OldStatus requires an ID field in the mutation")
  22139. }
  22140. oldValue, err := m.oldValue(ctx)
  22141. if err != nil {
  22142. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22143. }
  22144. return oldValue.Status, nil
  22145. }
  22146. // AddStatus adds u to the "status" field.
  22147. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  22148. if m.addstatus != nil {
  22149. *m.addstatus += u
  22150. } else {
  22151. m.addstatus = &u
  22152. }
  22153. }
  22154. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22155. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  22156. v := m.addstatus
  22157. if v == nil {
  22158. return
  22159. }
  22160. return *v, true
  22161. }
  22162. // ClearStatus clears the value of the "status" field.
  22163. func (m *LabelRelationshipMutation) ClearStatus() {
  22164. m.status = nil
  22165. m.addstatus = nil
  22166. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  22167. }
  22168. // StatusCleared returns if the "status" field was cleared in this mutation.
  22169. func (m *LabelRelationshipMutation) StatusCleared() bool {
  22170. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  22171. return ok
  22172. }
  22173. // ResetStatus resets all changes to the "status" field.
  22174. func (m *LabelRelationshipMutation) ResetStatus() {
  22175. m.status = nil
  22176. m.addstatus = nil
  22177. delete(m.clearedFields, labelrelationship.FieldStatus)
  22178. }
  22179. // SetLabelID sets the "label_id" field.
  22180. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  22181. m.labels = &u
  22182. }
  22183. // LabelID returns the value of the "label_id" field in the mutation.
  22184. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  22185. v := m.labels
  22186. if v == nil {
  22187. return
  22188. }
  22189. return *v, true
  22190. }
  22191. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  22192. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22194. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  22195. if !m.op.Is(OpUpdateOne) {
  22196. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  22197. }
  22198. if m.id == nil || m.oldValue == nil {
  22199. return v, errors.New("OldLabelID requires an ID field in the mutation")
  22200. }
  22201. oldValue, err := m.oldValue(ctx)
  22202. if err != nil {
  22203. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  22204. }
  22205. return oldValue.LabelID, nil
  22206. }
  22207. // ResetLabelID resets all changes to the "label_id" field.
  22208. func (m *LabelRelationshipMutation) ResetLabelID() {
  22209. m.labels = nil
  22210. }
  22211. // SetContactID sets the "contact_id" field.
  22212. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  22213. m.contacts = &u
  22214. }
  22215. // ContactID returns the value of the "contact_id" field in the mutation.
  22216. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  22217. v := m.contacts
  22218. if v == nil {
  22219. return
  22220. }
  22221. return *v, true
  22222. }
  22223. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  22224. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22226. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22227. if !m.op.Is(OpUpdateOne) {
  22228. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22229. }
  22230. if m.id == nil || m.oldValue == nil {
  22231. return v, errors.New("OldContactID requires an ID field in the mutation")
  22232. }
  22233. oldValue, err := m.oldValue(ctx)
  22234. if err != nil {
  22235. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22236. }
  22237. return oldValue.ContactID, nil
  22238. }
  22239. // ResetContactID resets all changes to the "contact_id" field.
  22240. func (m *LabelRelationshipMutation) ResetContactID() {
  22241. m.contacts = nil
  22242. }
  22243. // SetOrganizationID sets the "organization_id" field.
  22244. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  22245. m.organization_id = &u
  22246. m.addorganization_id = nil
  22247. }
  22248. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22249. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  22250. v := m.organization_id
  22251. if v == nil {
  22252. return
  22253. }
  22254. return *v, true
  22255. }
  22256. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  22257. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22259. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22260. if !m.op.Is(OpUpdateOne) {
  22261. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22262. }
  22263. if m.id == nil || m.oldValue == nil {
  22264. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22265. }
  22266. oldValue, err := m.oldValue(ctx)
  22267. if err != nil {
  22268. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22269. }
  22270. return oldValue.OrganizationID, nil
  22271. }
  22272. // AddOrganizationID adds u to the "organization_id" field.
  22273. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  22274. if m.addorganization_id != nil {
  22275. *m.addorganization_id += u
  22276. } else {
  22277. m.addorganization_id = &u
  22278. }
  22279. }
  22280. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22281. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  22282. v := m.addorganization_id
  22283. if v == nil {
  22284. return
  22285. }
  22286. return *v, true
  22287. }
  22288. // ClearOrganizationID clears the value of the "organization_id" field.
  22289. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  22290. m.organization_id = nil
  22291. m.addorganization_id = nil
  22292. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  22293. }
  22294. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22295. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  22296. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  22297. return ok
  22298. }
  22299. // ResetOrganizationID resets all changes to the "organization_id" field.
  22300. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  22301. m.organization_id = nil
  22302. m.addorganization_id = nil
  22303. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  22304. }
  22305. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  22306. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  22307. m.contacts = &id
  22308. }
  22309. // ClearContacts clears the "contacts" edge to the Contact entity.
  22310. func (m *LabelRelationshipMutation) ClearContacts() {
  22311. m.clearedcontacts = true
  22312. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  22313. }
  22314. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  22315. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  22316. return m.clearedcontacts
  22317. }
  22318. // ContactsID returns the "contacts" edge ID in the mutation.
  22319. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  22320. if m.contacts != nil {
  22321. return *m.contacts, true
  22322. }
  22323. return
  22324. }
  22325. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  22326. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22327. // ContactsID instead. It exists only for internal usage by the builders.
  22328. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  22329. if id := m.contacts; id != nil {
  22330. ids = append(ids, *id)
  22331. }
  22332. return
  22333. }
  22334. // ResetContacts resets all changes to the "contacts" edge.
  22335. func (m *LabelRelationshipMutation) ResetContacts() {
  22336. m.contacts = nil
  22337. m.clearedcontacts = false
  22338. }
  22339. // SetLabelsID sets the "labels" edge to the Label entity by id.
  22340. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  22341. m.labels = &id
  22342. }
  22343. // ClearLabels clears the "labels" edge to the Label entity.
  22344. func (m *LabelRelationshipMutation) ClearLabels() {
  22345. m.clearedlabels = true
  22346. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  22347. }
  22348. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  22349. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  22350. return m.clearedlabels
  22351. }
  22352. // LabelsID returns the "labels" edge ID in the mutation.
  22353. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  22354. if m.labels != nil {
  22355. return *m.labels, true
  22356. }
  22357. return
  22358. }
  22359. // LabelsIDs returns the "labels" edge IDs in the mutation.
  22360. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22361. // LabelsID instead. It exists only for internal usage by the builders.
  22362. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  22363. if id := m.labels; id != nil {
  22364. ids = append(ids, *id)
  22365. }
  22366. return
  22367. }
  22368. // ResetLabels resets all changes to the "labels" edge.
  22369. func (m *LabelRelationshipMutation) ResetLabels() {
  22370. m.labels = nil
  22371. m.clearedlabels = false
  22372. }
  22373. // Where appends a list predicates to the LabelRelationshipMutation builder.
  22374. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  22375. m.predicates = append(m.predicates, ps...)
  22376. }
  22377. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  22378. // users can use type-assertion to append predicates that do not depend on any generated package.
  22379. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  22380. p := make([]predicate.LabelRelationship, len(ps))
  22381. for i := range ps {
  22382. p[i] = ps[i]
  22383. }
  22384. m.Where(p...)
  22385. }
  22386. // Op returns the operation name.
  22387. func (m *LabelRelationshipMutation) Op() Op {
  22388. return m.op
  22389. }
  22390. // SetOp allows setting the mutation operation.
  22391. func (m *LabelRelationshipMutation) SetOp(op Op) {
  22392. m.op = op
  22393. }
  22394. // Type returns the node type of this mutation (LabelRelationship).
  22395. func (m *LabelRelationshipMutation) Type() string {
  22396. return m.typ
  22397. }
  22398. // Fields returns all fields that were changed during this mutation. Note that in
  22399. // order to get all numeric fields that were incremented/decremented, call
  22400. // AddedFields().
  22401. func (m *LabelRelationshipMutation) Fields() []string {
  22402. fields := make([]string, 0, 6)
  22403. if m.created_at != nil {
  22404. fields = append(fields, labelrelationship.FieldCreatedAt)
  22405. }
  22406. if m.updated_at != nil {
  22407. fields = append(fields, labelrelationship.FieldUpdatedAt)
  22408. }
  22409. if m.status != nil {
  22410. fields = append(fields, labelrelationship.FieldStatus)
  22411. }
  22412. if m.labels != nil {
  22413. fields = append(fields, labelrelationship.FieldLabelID)
  22414. }
  22415. if m.contacts != nil {
  22416. fields = append(fields, labelrelationship.FieldContactID)
  22417. }
  22418. if m.organization_id != nil {
  22419. fields = append(fields, labelrelationship.FieldOrganizationID)
  22420. }
  22421. return fields
  22422. }
  22423. // Field returns the value of a field with the given name. The second boolean
  22424. // return value indicates that this field was not set, or was not defined in the
  22425. // schema.
  22426. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  22427. switch name {
  22428. case labelrelationship.FieldCreatedAt:
  22429. return m.CreatedAt()
  22430. case labelrelationship.FieldUpdatedAt:
  22431. return m.UpdatedAt()
  22432. case labelrelationship.FieldStatus:
  22433. return m.Status()
  22434. case labelrelationship.FieldLabelID:
  22435. return m.LabelID()
  22436. case labelrelationship.FieldContactID:
  22437. return m.ContactID()
  22438. case labelrelationship.FieldOrganizationID:
  22439. return m.OrganizationID()
  22440. }
  22441. return nil, false
  22442. }
  22443. // OldField returns the old value of the field from the database. An error is
  22444. // returned if the mutation operation is not UpdateOne, or the query to the
  22445. // database failed.
  22446. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22447. switch name {
  22448. case labelrelationship.FieldCreatedAt:
  22449. return m.OldCreatedAt(ctx)
  22450. case labelrelationship.FieldUpdatedAt:
  22451. return m.OldUpdatedAt(ctx)
  22452. case labelrelationship.FieldStatus:
  22453. return m.OldStatus(ctx)
  22454. case labelrelationship.FieldLabelID:
  22455. return m.OldLabelID(ctx)
  22456. case labelrelationship.FieldContactID:
  22457. return m.OldContactID(ctx)
  22458. case labelrelationship.FieldOrganizationID:
  22459. return m.OldOrganizationID(ctx)
  22460. }
  22461. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  22462. }
  22463. // SetField sets the value of a field with the given name. It returns an error if
  22464. // the field is not defined in the schema, or if the type mismatched the field
  22465. // type.
  22466. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  22467. switch name {
  22468. case labelrelationship.FieldCreatedAt:
  22469. v, ok := value.(time.Time)
  22470. if !ok {
  22471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22472. }
  22473. m.SetCreatedAt(v)
  22474. return nil
  22475. case labelrelationship.FieldUpdatedAt:
  22476. v, ok := value.(time.Time)
  22477. if !ok {
  22478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22479. }
  22480. m.SetUpdatedAt(v)
  22481. return nil
  22482. case labelrelationship.FieldStatus:
  22483. v, ok := value.(uint8)
  22484. if !ok {
  22485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22486. }
  22487. m.SetStatus(v)
  22488. return nil
  22489. case labelrelationship.FieldLabelID:
  22490. v, ok := value.(uint64)
  22491. if !ok {
  22492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22493. }
  22494. m.SetLabelID(v)
  22495. return nil
  22496. case labelrelationship.FieldContactID:
  22497. v, ok := value.(uint64)
  22498. if !ok {
  22499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22500. }
  22501. m.SetContactID(v)
  22502. return nil
  22503. case labelrelationship.FieldOrganizationID:
  22504. v, ok := value.(uint64)
  22505. if !ok {
  22506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22507. }
  22508. m.SetOrganizationID(v)
  22509. return nil
  22510. }
  22511. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22512. }
  22513. // AddedFields returns all numeric fields that were incremented/decremented during
  22514. // this mutation.
  22515. func (m *LabelRelationshipMutation) AddedFields() []string {
  22516. var fields []string
  22517. if m.addstatus != nil {
  22518. fields = append(fields, labelrelationship.FieldStatus)
  22519. }
  22520. if m.addorganization_id != nil {
  22521. fields = append(fields, labelrelationship.FieldOrganizationID)
  22522. }
  22523. return fields
  22524. }
  22525. // AddedField returns the numeric value that was incremented/decremented on a field
  22526. // with the given name. The second boolean return value indicates that this field
  22527. // was not set, or was not defined in the schema.
  22528. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  22529. switch name {
  22530. case labelrelationship.FieldStatus:
  22531. return m.AddedStatus()
  22532. case labelrelationship.FieldOrganizationID:
  22533. return m.AddedOrganizationID()
  22534. }
  22535. return nil, false
  22536. }
  22537. // AddField adds the value to the field with the given name. It returns an error if
  22538. // the field is not defined in the schema, or if the type mismatched the field
  22539. // type.
  22540. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  22541. switch name {
  22542. case labelrelationship.FieldStatus:
  22543. v, ok := value.(int8)
  22544. if !ok {
  22545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22546. }
  22547. m.AddStatus(v)
  22548. return nil
  22549. case labelrelationship.FieldOrganizationID:
  22550. v, ok := value.(int64)
  22551. if !ok {
  22552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22553. }
  22554. m.AddOrganizationID(v)
  22555. return nil
  22556. }
  22557. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  22558. }
  22559. // ClearedFields returns all nullable fields that were cleared during this
  22560. // mutation.
  22561. func (m *LabelRelationshipMutation) ClearedFields() []string {
  22562. var fields []string
  22563. if m.FieldCleared(labelrelationship.FieldStatus) {
  22564. fields = append(fields, labelrelationship.FieldStatus)
  22565. }
  22566. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  22567. fields = append(fields, labelrelationship.FieldOrganizationID)
  22568. }
  22569. return fields
  22570. }
  22571. // FieldCleared returns a boolean indicating if a field with the given name was
  22572. // cleared in this mutation.
  22573. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  22574. _, ok := m.clearedFields[name]
  22575. return ok
  22576. }
  22577. // ClearField clears the value of the field with the given name. It returns an
  22578. // error if the field is not defined in the schema.
  22579. func (m *LabelRelationshipMutation) ClearField(name string) error {
  22580. switch name {
  22581. case labelrelationship.FieldStatus:
  22582. m.ClearStatus()
  22583. return nil
  22584. case labelrelationship.FieldOrganizationID:
  22585. m.ClearOrganizationID()
  22586. return nil
  22587. }
  22588. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  22589. }
  22590. // ResetField resets all changes in the mutation for the field with the given name.
  22591. // It returns an error if the field is not defined in the schema.
  22592. func (m *LabelRelationshipMutation) ResetField(name string) error {
  22593. switch name {
  22594. case labelrelationship.FieldCreatedAt:
  22595. m.ResetCreatedAt()
  22596. return nil
  22597. case labelrelationship.FieldUpdatedAt:
  22598. m.ResetUpdatedAt()
  22599. return nil
  22600. case labelrelationship.FieldStatus:
  22601. m.ResetStatus()
  22602. return nil
  22603. case labelrelationship.FieldLabelID:
  22604. m.ResetLabelID()
  22605. return nil
  22606. case labelrelationship.FieldContactID:
  22607. m.ResetContactID()
  22608. return nil
  22609. case labelrelationship.FieldOrganizationID:
  22610. m.ResetOrganizationID()
  22611. return nil
  22612. }
  22613. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22614. }
  22615. // AddedEdges returns all edge names that were set/added in this mutation.
  22616. func (m *LabelRelationshipMutation) AddedEdges() []string {
  22617. edges := make([]string, 0, 2)
  22618. if m.contacts != nil {
  22619. edges = append(edges, labelrelationship.EdgeContacts)
  22620. }
  22621. if m.labels != nil {
  22622. edges = append(edges, labelrelationship.EdgeLabels)
  22623. }
  22624. return edges
  22625. }
  22626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22627. // name in this mutation.
  22628. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  22629. switch name {
  22630. case labelrelationship.EdgeContacts:
  22631. if id := m.contacts; id != nil {
  22632. return []ent.Value{*id}
  22633. }
  22634. case labelrelationship.EdgeLabels:
  22635. if id := m.labels; id != nil {
  22636. return []ent.Value{*id}
  22637. }
  22638. }
  22639. return nil
  22640. }
  22641. // RemovedEdges returns all edge names that were removed in this mutation.
  22642. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  22643. edges := make([]string, 0, 2)
  22644. return edges
  22645. }
  22646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22647. // the given name in this mutation.
  22648. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  22649. return nil
  22650. }
  22651. // ClearedEdges returns all edge names that were cleared in this mutation.
  22652. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  22653. edges := make([]string, 0, 2)
  22654. if m.clearedcontacts {
  22655. edges = append(edges, labelrelationship.EdgeContacts)
  22656. }
  22657. if m.clearedlabels {
  22658. edges = append(edges, labelrelationship.EdgeLabels)
  22659. }
  22660. return edges
  22661. }
  22662. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22663. // was cleared in this mutation.
  22664. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  22665. switch name {
  22666. case labelrelationship.EdgeContacts:
  22667. return m.clearedcontacts
  22668. case labelrelationship.EdgeLabels:
  22669. return m.clearedlabels
  22670. }
  22671. return false
  22672. }
  22673. // ClearEdge clears the value of the edge with the given name. It returns an error
  22674. // if that edge is not defined in the schema.
  22675. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  22676. switch name {
  22677. case labelrelationship.EdgeContacts:
  22678. m.ClearContacts()
  22679. return nil
  22680. case labelrelationship.EdgeLabels:
  22681. m.ClearLabels()
  22682. return nil
  22683. }
  22684. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  22685. }
  22686. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22687. // It returns an error if the edge is not defined in the schema.
  22688. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  22689. switch name {
  22690. case labelrelationship.EdgeContacts:
  22691. m.ResetContacts()
  22692. return nil
  22693. case labelrelationship.EdgeLabels:
  22694. m.ResetLabels()
  22695. return nil
  22696. }
  22697. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  22698. }
  22699. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  22700. type LabelTaggingMutation struct {
  22701. config
  22702. op Op
  22703. typ string
  22704. id *uint64
  22705. created_at *time.Time
  22706. updated_at *time.Time
  22707. status *uint8
  22708. addstatus *int8
  22709. deleted_at *time.Time
  22710. organization_id *uint64
  22711. addorganization_id *int64
  22712. _type *int
  22713. add_type *int
  22714. conditions *string
  22715. action_label_add *[]uint64
  22716. appendaction_label_add []uint64
  22717. action_label_del *[]uint64
  22718. appendaction_label_del []uint64
  22719. clearedFields map[string]struct{}
  22720. done bool
  22721. oldValue func(context.Context) (*LabelTagging, error)
  22722. predicates []predicate.LabelTagging
  22723. }
  22724. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  22725. // labeltaggingOption allows management of the mutation configuration using functional options.
  22726. type labeltaggingOption func(*LabelTaggingMutation)
  22727. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  22728. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  22729. m := &LabelTaggingMutation{
  22730. config: c,
  22731. op: op,
  22732. typ: TypeLabelTagging,
  22733. clearedFields: make(map[string]struct{}),
  22734. }
  22735. for _, opt := range opts {
  22736. opt(m)
  22737. }
  22738. return m
  22739. }
  22740. // withLabelTaggingID sets the ID field of the mutation.
  22741. func withLabelTaggingID(id uint64) labeltaggingOption {
  22742. return func(m *LabelTaggingMutation) {
  22743. var (
  22744. err error
  22745. once sync.Once
  22746. value *LabelTagging
  22747. )
  22748. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  22749. once.Do(func() {
  22750. if m.done {
  22751. err = errors.New("querying old values post mutation is not allowed")
  22752. } else {
  22753. value, err = m.Client().LabelTagging.Get(ctx, id)
  22754. }
  22755. })
  22756. return value, err
  22757. }
  22758. m.id = &id
  22759. }
  22760. }
  22761. // withLabelTagging sets the old LabelTagging of the mutation.
  22762. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  22763. return func(m *LabelTaggingMutation) {
  22764. m.oldValue = func(context.Context) (*LabelTagging, error) {
  22765. return node, nil
  22766. }
  22767. m.id = &node.ID
  22768. }
  22769. }
  22770. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22771. // executed in a transaction (ent.Tx), a transactional client is returned.
  22772. func (m LabelTaggingMutation) Client() *Client {
  22773. client := &Client{config: m.config}
  22774. client.init()
  22775. return client
  22776. }
  22777. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22778. // it returns an error otherwise.
  22779. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  22780. if _, ok := m.driver.(*txDriver); !ok {
  22781. return nil, errors.New("ent: mutation is not running in a transaction")
  22782. }
  22783. tx := &Tx{config: m.config}
  22784. tx.init()
  22785. return tx, nil
  22786. }
  22787. // SetID sets the value of the id field. Note that this
  22788. // operation is only accepted on creation of LabelTagging entities.
  22789. func (m *LabelTaggingMutation) SetID(id uint64) {
  22790. m.id = &id
  22791. }
  22792. // ID returns the ID value in the mutation. Note that the ID is only available
  22793. // if it was provided to the builder or after it was returned from the database.
  22794. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  22795. if m.id == nil {
  22796. return
  22797. }
  22798. return *m.id, true
  22799. }
  22800. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22801. // That means, if the mutation is applied within a transaction with an isolation level such
  22802. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22803. // or updated by the mutation.
  22804. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  22805. switch {
  22806. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22807. id, exists := m.ID()
  22808. if exists {
  22809. return []uint64{id}, nil
  22810. }
  22811. fallthrough
  22812. case m.op.Is(OpUpdate | OpDelete):
  22813. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  22814. default:
  22815. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22816. }
  22817. }
  22818. // SetCreatedAt sets the "created_at" field.
  22819. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  22820. m.created_at = &t
  22821. }
  22822. // CreatedAt returns the value of the "created_at" field in the mutation.
  22823. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  22824. v := m.created_at
  22825. if v == nil {
  22826. return
  22827. }
  22828. return *v, true
  22829. }
  22830. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  22831. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22833. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22834. if !m.op.Is(OpUpdateOne) {
  22835. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22836. }
  22837. if m.id == nil || m.oldValue == nil {
  22838. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22839. }
  22840. oldValue, err := m.oldValue(ctx)
  22841. if err != nil {
  22842. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22843. }
  22844. return oldValue.CreatedAt, nil
  22845. }
  22846. // ResetCreatedAt resets all changes to the "created_at" field.
  22847. func (m *LabelTaggingMutation) ResetCreatedAt() {
  22848. m.created_at = nil
  22849. }
  22850. // SetUpdatedAt sets the "updated_at" field.
  22851. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  22852. m.updated_at = &t
  22853. }
  22854. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22855. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  22856. v := m.updated_at
  22857. if v == nil {
  22858. return
  22859. }
  22860. return *v, true
  22861. }
  22862. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  22863. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22865. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22866. if !m.op.Is(OpUpdateOne) {
  22867. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22868. }
  22869. if m.id == nil || m.oldValue == nil {
  22870. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22871. }
  22872. oldValue, err := m.oldValue(ctx)
  22873. if err != nil {
  22874. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22875. }
  22876. return oldValue.UpdatedAt, nil
  22877. }
  22878. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22879. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  22880. m.updated_at = nil
  22881. }
  22882. // SetStatus sets the "status" field.
  22883. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  22884. m.status = &u
  22885. m.addstatus = nil
  22886. }
  22887. // Status returns the value of the "status" field in the mutation.
  22888. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  22889. v := m.status
  22890. if v == nil {
  22891. return
  22892. }
  22893. return *v, true
  22894. }
  22895. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  22896. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22898. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22899. if !m.op.Is(OpUpdateOne) {
  22900. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22901. }
  22902. if m.id == nil || m.oldValue == nil {
  22903. return v, errors.New("OldStatus requires an ID field in the mutation")
  22904. }
  22905. oldValue, err := m.oldValue(ctx)
  22906. if err != nil {
  22907. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22908. }
  22909. return oldValue.Status, nil
  22910. }
  22911. // AddStatus adds u to the "status" field.
  22912. func (m *LabelTaggingMutation) AddStatus(u int8) {
  22913. if m.addstatus != nil {
  22914. *m.addstatus += u
  22915. } else {
  22916. m.addstatus = &u
  22917. }
  22918. }
  22919. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22920. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  22921. v := m.addstatus
  22922. if v == nil {
  22923. return
  22924. }
  22925. return *v, true
  22926. }
  22927. // ClearStatus clears the value of the "status" field.
  22928. func (m *LabelTaggingMutation) ClearStatus() {
  22929. m.status = nil
  22930. m.addstatus = nil
  22931. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  22932. }
  22933. // StatusCleared returns if the "status" field was cleared in this mutation.
  22934. func (m *LabelTaggingMutation) StatusCleared() bool {
  22935. _, ok := m.clearedFields[labeltagging.FieldStatus]
  22936. return ok
  22937. }
  22938. // ResetStatus resets all changes to the "status" field.
  22939. func (m *LabelTaggingMutation) ResetStatus() {
  22940. m.status = nil
  22941. m.addstatus = nil
  22942. delete(m.clearedFields, labeltagging.FieldStatus)
  22943. }
  22944. // SetDeletedAt sets the "deleted_at" field.
  22945. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  22946. m.deleted_at = &t
  22947. }
  22948. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22949. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  22950. v := m.deleted_at
  22951. if v == nil {
  22952. return
  22953. }
  22954. return *v, true
  22955. }
  22956. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  22957. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22959. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22960. if !m.op.Is(OpUpdateOne) {
  22961. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22962. }
  22963. if m.id == nil || m.oldValue == nil {
  22964. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22965. }
  22966. oldValue, err := m.oldValue(ctx)
  22967. if err != nil {
  22968. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22969. }
  22970. return oldValue.DeletedAt, nil
  22971. }
  22972. // ClearDeletedAt clears the value of the "deleted_at" field.
  22973. func (m *LabelTaggingMutation) ClearDeletedAt() {
  22974. m.deleted_at = nil
  22975. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  22976. }
  22977. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22978. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  22979. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  22980. return ok
  22981. }
  22982. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22983. func (m *LabelTaggingMutation) ResetDeletedAt() {
  22984. m.deleted_at = nil
  22985. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  22986. }
  22987. // SetOrganizationID sets the "organization_id" field.
  22988. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  22989. m.organization_id = &u
  22990. m.addorganization_id = nil
  22991. }
  22992. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22993. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  22994. v := m.organization_id
  22995. if v == nil {
  22996. return
  22997. }
  22998. return *v, true
  22999. }
  23000. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  23001. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23003. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23004. if !m.op.Is(OpUpdateOne) {
  23005. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23006. }
  23007. if m.id == nil || m.oldValue == nil {
  23008. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23009. }
  23010. oldValue, err := m.oldValue(ctx)
  23011. if err != nil {
  23012. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23013. }
  23014. return oldValue.OrganizationID, nil
  23015. }
  23016. // AddOrganizationID adds u to the "organization_id" field.
  23017. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  23018. if m.addorganization_id != nil {
  23019. *m.addorganization_id += u
  23020. } else {
  23021. m.addorganization_id = &u
  23022. }
  23023. }
  23024. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23025. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  23026. v := m.addorganization_id
  23027. if v == nil {
  23028. return
  23029. }
  23030. return *v, true
  23031. }
  23032. // ResetOrganizationID resets all changes to the "organization_id" field.
  23033. func (m *LabelTaggingMutation) ResetOrganizationID() {
  23034. m.organization_id = nil
  23035. m.addorganization_id = nil
  23036. }
  23037. // SetType sets the "type" field.
  23038. func (m *LabelTaggingMutation) SetType(i int) {
  23039. m._type = &i
  23040. m.add_type = nil
  23041. }
  23042. // GetType returns the value of the "type" field in the mutation.
  23043. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  23044. v := m._type
  23045. if v == nil {
  23046. return
  23047. }
  23048. return *v, true
  23049. }
  23050. // OldType returns the old "type" field's value of the LabelTagging entity.
  23051. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23053. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  23054. if !m.op.Is(OpUpdateOne) {
  23055. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23056. }
  23057. if m.id == nil || m.oldValue == nil {
  23058. return v, errors.New("OldType requires an ID field in the mutation")
  23059. }
  23060. oldValue, err := m.oldValue(ctx)
  23061. if err != nil {
  23062. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23063. }
  23064. return oldValue.Type, nil
  23065. }
  23066. // AddType adds i to the "type" field.
  23067. func (m *LabelTaggingMutation) AddType(i int) {
  23068. if m.add_type != nil {
  23069. *m.add_type += i
  23070. } else {
  23071. m.add_type = &i
  23072. }
  23073. }
  23074. // AddedType returns the value that was added to the "type" field in this mutation.
  23075. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  23076. v := m.add_type
  23077. if v == nil {
  23078. return
  23079. }
  23080. return *v, true
  23081. }
  23082. // ResetType resets all changes to the "type" field.
  23083. func (m *LabelTaggingMutation) ResetType() {
  23084. m._type = nil
  23085. m.add_type = nil
  23086. }
  23087. // SetConditions sets the "conditions" field.
  23088. func (m *LabelTaggingMutation) SetConditions(s string) {
  23089. m.conditions = &s
  23090. }
  23091. // Conditions returns the value of the "conditions" field in the mutation.
  23092. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  23093. v := m.conditions
  23094. if v == nil {
  23095. return
  23096. }
  23097. return *v, true
  23098. }
  23099. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  23100. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23102. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  23103. if !m.op.Is(OpUpdateOne) {
  23104. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  23105. }
  23106. if m.id == nil || m.oldValue == nil {
  23107. return v, errors.New("OldConditions requires an ID field in the mutation")
  23108. }
  23109. oldValue, err := m.oldValue(ctx)
  23110. if err != nil {
  23111. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  23112. }
  23113. return oldValue.Conditions, nil
  23114. }
  23115. // ResetConditions resets all changes to the "conditions" field.
  23116. func (m *LabelTaggingMutation) ResetConditions() {
  23117. m.conditions = nil
  23118. }
  23119. // SetActionLabelAdd sets the "action_label_add" field.
  23120. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  23121. m.action_label_add = &u
  23122. m.appendaction_label_add = nil
  23123. }
  23124. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23125. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23126. v := m.action_label_add
  23127. if v == nil {
  23128. return
  23129. }
  23130. return *v, true
  23131. }
  23132. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  23133. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23135. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23136. if !m.op.Is(OpUpdateOne) {
  23137. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23138. }
  23139. if m.id == nil || m.oldValue == nil {
  23140. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23141. }
  23142. oldValue, err := m.oldValue(ctx)
  23143. if err != nil {
  23144. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23145. }
  23146. return oldValue.ActionLabelAdd, nil
  23147. }
  23148. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23149. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  23150. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23151. }
  23152. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23153. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23154. if len(m.appendaction_label_add) == 0 {
  23155. return nil, false
  23156. }
  23157. return m.appendaction_label_add, true
  23158. }
  23159. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23160. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  23161. m.action_label_add = nil
  23162. m.appendaction_label_add = nil
  23163. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  23164. }
  23165. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23166. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  23167. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  23168. return ok
  23169. }
  23170. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23171. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  23172. m.action_label_add = nil
  23173. m.appendaction_label_add = nil
  23174. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  23175. }
  23176. // SetActionLabelDel sets the "action_label_del" field.
  23177. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  23178. m.action_label_del = &u
  23179. m.appendaction_label_del = nil
  23180. }
  23181. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23182. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  23183. v := m.action_label_del
  23184. if v == nil {
  23185. return
  23186. }
  23187. return *v, true
  23188. }
  23189. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  23190. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23192. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23193. if !m.op.Is(OpUpdateOne) {
  23194. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23195. }
  23196. if m.id == nil || m.oldValue == nil {
  23197. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23198. }
  23199. oldValue, err := m.oldValue(ctx)
  23200. if err != nil {
  23201. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23202. }
  23203. return oldValue.ActionLabelDel, nil
  23204. }
  23205. // AppendActionLabelDel adds u to the "action_label_del" field.
  23206. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  23207. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23208. }
  23209. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23210. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23211. if len(m.appendaction_label_del) == 0 {
  23212. return nil, false
  23213. }
  23214. return m.appendaction_label_del, true
  23215. }
  23216. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23217. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  23218. m.action_label_del = nil
  23219. m.appendaction_label_del = nil
  23220. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  23221. }
  23222. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23223. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  23224. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  23225. return ok
  23226. }
  23227. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23228. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  23229. m.action_label_del = nil
  23230. m.appendaction_label_del = nil
  23231. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  23232. }
  23233. // Where appends a list predicates to the LabelTaggingMutation builder.
  23234. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  23235. m.predicates = append(m.predicates, ps...)
  23236. }
  23237. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  23238. // users can use type-assertion to append predicates that do not depend on any generated package.
  23239. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  23240. p := make([]predicate.LabelTagging, len(ps))
  23241. for i := range ps {
  23242. p[i] = ps[i]
  23243. }
  23244. m.Where(p...)
  23245. }
  23246. // Op returns the operation name.
  23247. func (m *LabelTaggingMutation) Op() Op {
  23248. return m.op
  23249. }
  23250. // SetOp allows setting the mutation operation.
  23251. func (m *LabelTaggingMutation) SetOp(op Op) {
  23252. m.op = op
  23253. }
  23254. // Type returns the node type of this mutation (LabelTagging).
  23255. func (m *LabelTaggingMutation) Type() string {
  23256. return m.typ
  23257. }
  23258. // Fields returns all fields that were changed during this mutation. Note that in
  23259. // order to get all numeric fields that were incremented/decremented, call
  23260. // AddedFields().
  23261. func (m *LabelTaggingMutation) Fields() []string {
  23262. fields := make([]string, 0, 9)
  23263. if m.created_at != nil {
  23264. fields = append(fields, labeltagging.FieldCreatedAt)
  23265. }
  23266. if m.updated_at != nil {
  23267. fields = append(fields, labeltagging.FieldUpdatedAt)
  23268. }
  23269. if m.status != nil {
  23270. fields = append(fields, labeltagging.FieldStatus)
  23271. }
  23272. if m.deleted_at != nil {
  23273. fields = append(fields, labeltagging.FieldDeletedAt)
  23274. }
  23275. if m.organization_id != nil {
  23276. fields = append(fields, labeltagging.FieldOrganizationID)
  23277. }
  23278. if m._type != nil {
  23279. fields = append(fields, labeltagging.FieldType)
  23280. }
  23281. if m.conditions != nil {
  23282. fields = append(fields, labeltagging.FieldConditions)
  23283. }
  23284. if m.action_label_add != nil {
  23285. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23286. }
  23287. if m.action_label_del != nil {
  23288. fields = append(fields, labeltagging.FieldActionLabelDel)
  23289. }
  23290. return fields
  23291. }
  23292. // Field returns the value of a field with the given name. The second boolean
  23293. // return value indicates that this field was not set, or was not defined in the
  23294. // schema.
  23295. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  23296. switch name {
  23297. case labeltagging.FieldCreatedAt:
  23298. return m.CreatedAt()
  23299. case labeltagging.FieldUpdatedAt:
  23300. return m.UpdatedAt()
  23301. case labeltagging.FieldStatus:
  23302. return m.Status()
  23303. case labeltagging.FieldDeletedAt:
  23304. return m.DeletedAt()
  23305. case labeltagging.FieldOrganizationID:
  23306. return m.OrganizationID()
  23307. case labeltagging.FieldType:
  23308. return m.GetType()
  23309. case labeltagging.FieldConditions:
  23310. return m.Conditions()
  23311. case labeltagging.FieldActionLabelAdd:
  23312. return m.ActionLabelAdd()
  23313. case labeltagging.FieldActionLabelDel:
  23314. return m.ActionLabelDel()
  23315. }
  23316. return nil, false
  23317. }
  23318. // OldField returns the old value of the field from the database. An error is
  23319. // returned if the mutation operation is not UpdateOne, or the query to the
  23320. // database failed.
  23321. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23322. switch name {
  23323. case labeltagging.FieldCreatedAt:
  23324. return m.OldCreatedAt(ctx)
  23325. case labeltagging.FieldUpdatedAt:
  23326. return m.OldUpdatedAt(ctx)
  23327. case labeltagging.FieldStatus:
  23328. return m.OldStatus(ctx)
  23329. case labeltagging.FieldDeletedAt:
  23330. return m.OldDeletedAt(ctx)
  23331. case labeltagging.FieldOrganizationID:
  23332. return m.OldOrganizationID(ctx)
  23333. case labeltagging.FieldType:
  23334. return m.OldType(ctx)
  23335. case labeltagging.FieldConditions:
  23336. return m.OldConditions(ctx)
  23337. case labeltagging.FieldActionLabelAdd:
  23338. return m.OldActionLabelAdd(ctx)
  23339. case labeltagging.FieldActionLabelDel:
  23340. return m.OldActionLabelDel(ctx)
  23341. }
  23342. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  23343. }
  23344. // SetField sets the value of a field with the given name. It returns an error if
  23345. // the field is not defined in the schema, or if the type mismatched the field
  23346. // type.
  23347. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  23348. switch name {
  23349. case labeltagging.FieldCreatedAt:
  23350. v, ok := value.(time.Time)
  23351. if !ok {
  23352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23353. }
  23354. m.SetCreatedAt(v)
  23355. return nil
  23356. case labeltagging.FieldUpdatedAt:
  23357. v, ok := value.(time.Time)
  23358. if !ok {
  23359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23360. }
  23361. m.SetUpdatedAt(v)
  23362. return nil
  23363. case labeltagging.FieldStatus:
  23364. v, ok := value.(uint8)
  23365. if !ok {
  23366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23367. }
  23368. m.SetStatus(v)
  23369. return nil
  23370. case labeltagging.FieldDeletedAt:
  23371. v, ok := value.(time.Time)
  23372. if !ok {
  23373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23374. }
  23375. m.SetDeletedAt(v)
  23376. return nil
  23377. case labeltagging.FieldOrganizationID:
  23378. v, ok := value.(uint64)
  23379. if !ok {
  23380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23381. }
  23382. m.SetOrganizationID(v)
  23383. return nil
  23384. case labeltagging.FieldType:
  23385. v, ok := value.(int)
  23386. if !ok {
  23387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23388. }
  23389. m.SetType(v)
  23390. return nil
  23391. case labeltagging.FieldConditions:
  23392. v, ok := value.(string)
  23393. if !ok {
  23394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23395. }
  23396. m.SetConditions(v)
  23397. return nil
  23398. case labeltagging.FieldActionLabelAdd:
  23399. v, ok := value.([]uint64)
  23400. if !ok {
  23401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23402. }
  23403. m.SetActionLabelAdd(v)
  23404. return nil
  23405. case labeltagging.FieldActionLabelDel:
  23406. v, ok := value.([]uint64)
  23407. if !ok {
  23408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23409. }
  23410. m.SetActionLabelDel(v)
  23411. return nil
  23412. }
  23413. return fmt.Errorf("unknown LabelTagging field %s", name)
  23414. }
  23415. // AddedFields returns all numeric fields that were incremented/decremented during
  23416. // this mutation.
  23417. func (m *LabelTaggingMutation) AddedFields() []string {
  23418. var fields []string
  23419. if m.addstatus != nil {
  23420. fields = append(fields, labeltagging.FieldStatus)
  23421. }
  23422. if m.addorganization_id != nil {
  23423. fields = append(fields, labeltagging.FieldOrganizationID)
  23424. }
  23425. if m.add_type != nil {
  23426. fields = append(fields, labeltagging.FieldType)
  23427. }
  23428. return fields
  23429. }
  23430. // AddedField returns the numeric value that was incremented/decremented on a field
  23431. // with the given name. The second boolean return value indicates that this field
  23432. // was not set, or was not defined in the schema.
  23433. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  23434. switch name {
  23435. case labeltagging.FieldStatus:
  23436. return m.AddedStatus()
  23437. case labeltagging.FieldOrganizationID:
  23438. return m.AddedOrganizationID()
  23439. case labeltagging.FieldType:
  23440. return m.AddedType()
  23441. }
  23442. return nil, false
  23443. }
  23444. // AddField adds the value to the field with the given name. It returns an error if
  23445. // the field is not defined in the schema, or if the type mismatched the field
  23446. // type.
  23447. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  23448. switch name {
  23449. case labeltagging.FieldStatus:
  23450. v, ok := value.(int8)
  23451. if !ok {
  23452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23453. }
  23454. m.AddStatus(v)
  23455. return nil
  23456. case labeltagging.FieldOrganizationID:
  23457. v, ok := value.(int64)
  23458. if !ok {
  23459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23460. }
  23461. m.AddOrganizationID(v)
  23462. return nil
  23463. case labeltagging.FieldType:
  23464. v, ok := value.(int)
  23465. if !ok {
  23466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23467. }
  23468. m.AddType(v)
  23469. return nil
  23470. }
  23471. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  23472. }
  23473. // ClearedFields returns all nullable fields that were cleared during this
  23474. // mutation.
  23475. func (m *LabelTaggingMutation) ClearedFields() []string {
  23476. var fields []string
  23477. if m.FieldCleared(labeltagging.FieldStatus) {
  23478. fields = append(fields, labeltagging.FieldStatus)
  23479. }
  23480. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  23481. fields = append(fields, labeltagging.FieldDeletedAt)
  23482. }
  23483. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  23484. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23485. }
  23486. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  23487. fields = append(fields, labeltagging.FieldActionLabelDel)
  23488. }
  23489. return fields
  23490. }
  23491. // FieldCleared returns a boolean indicating if a field with the given name was
  23492. // cleared in this mutation.
  23493. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  23494. _, ok := m.clearedFields[name]
  23495. return ok
  23496. }
  23497. // ClearField clears the value of the field with the given name. It returns an
  23498. // error if the field is not defined in the schema.
  23499. func (m *LabelTaggingMutation) ClearField(name string) error {
  23500. switch name {
  23501. case labeltagging.FieldStatus:
  23502. m.ClearStatus()
  23503. return nil
  23504. case labeltagging.FieldDeletedAt:
  23505. m.ClearDeletedAt()
  23506. return nil
  23507. case labeltagging.FieldActionLabelAdd:
  23508. m.ClearActionLabelAdd()
  23509. return nil
  23510. case labeltagging.FieldActionLabelDel:
  23511. m.ClearActionLabelDel()
  23512. return nil
  23513. }
  23514. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  23515. }
  23516. // ResetField resets all changes in the mutation for the field with the given name.
  23517. // It returns an error if the field is not defined in the schema.
  23518. func (m *LabelTaggingMutation) ResetField(name string) error {
  23519. switch name {
  23520. case labeltagging.FieldCreatedAt:
  23521. m.ResetCreatedAt()
  23522. return nil
  23523. case labeltagging.FieldUpdatedAt:
  23524. m.ResetUpdatedAt()
  23525. return nil
  23526. case labeltagging.FieldStatus:
  23527. m.ResetStatus()
  23528. return nil
  23529. case labeltagging.FieldDeletedAt:
  23530. m.ResetDeletedAt()
  23531. return nil
  23532. case labeltagging.FieldOrganizationID:
  23533. m.ResetOrganizationID()
  23534. return nil
  23535. case labeltagging.FieldType:
  23536. m.ResetType()
  23537. return nil
  23538. case labeltagging.FieldConditions:
  23539. m.ResetConditions()
  23540. return nil
  23541. case labeltagging.FieldActionLabelAdd:
  23542. m.ResetActionLabelAdd()
  23543. return nil
  23544. case labeltagging.FieldActionLabelDel:
  23545. m.ResetActionLabelDel()
  23546. return nil
  23547. }
  23548. return fmt.Errorf("unknown LabelTagging field %s", name)
  23549. }
  23550. // AddedEdges returns all edge names that were set/added in this mutation.
  23551. func (m *LabelTaggingMutation) AddedEdges() []string {
  23552. edges := make([]string, 0, 0)
  23553. return edges
  23554. }
  23555. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23556. // name in this mutation.
  23557. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  23558. return nil
  23559. }
  23560. // RemovedEdges returns all edge names that were removed in this mutation.
  23561. func (m *LabelTaggingMutation) RemovedEdges() []string {
  23562. edges := make([]string, 0, 0)
  23563. return edges
  23564. }
  23565. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23566. // the given name in this mutation.
  23567. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  23568. return nil
  23569. }
  23570. // ClearedEdges returns all edge names that were cleared in this mutation.
  23571. func (m *LabelTaggingMutation) ClearedEdges() []string {
  23572. edges := make([]string, 0, 0)
  23573. return edges
  23574. }
  23575. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23576. // was cleared in this mutation.
  23577. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  23578. return false
  23579. }
  23580. // ClearEdge clears the value of the edge with the given name. It returns an error
  23581. // if that edge is not defined in the schema.
  23582. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  23583. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  23584. }
  23585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23586. // It returns an error if the edge is not defined in the schema.
  23587. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  23588. return fmt.Errorf("unknown LabelTagging edge %s", name)
  23589. }
  23590. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  23591. type MessageMutation struct {
  23592. config
  23593. op Op
  23594. typ string
  23595. id *int
  23596. wx_wxid *string
  23597. wxid *string
  23598. content *string
  23599. clearedFields map[string]struct{}
  23600. done bool
  23601. oldValue func(context.Context) (*Message, error)
  23602. predicates []predicate.Message
  23603. }
  23604. var _ ent.Mutation = (*MessageMutation)(nil)
  23605. // messageOption allows management of the mutation configuration using functional options.
  23606. type messageOption func(*MessageMutation)
  23607. // newMessageMutation creates new mutation for the Message entity.
  23608. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  23609. m := &MessageMutation{
  23610. config: c,
  23611. op: op,
  23612. typ: TypeMessage,
  23613. clearedFields: make(map[string]struct{}),
  23614. }
  23615. for _, opt := range opts {
  23616. opt(m)
  23617. }
  23618. return m
  23619. }
  23620. // withMessageID sets the ID field of the mutation.
  23621. func withMessageID(id int) messageOption {
  23622. return func(m *MessageMutation) {
  23623. var (
  23624. err error
  23625. once sync.Once
  23626. value *Message
  23627. )
  23628. m.oldValue = func(ctx context.Context) (*Message, error) {
  23629. once.Do(func() {
  23630. if m.done {
  23631. err = errors.New("querying old values post mutation is not allowed")
  23632. } else {
  23633. value, err = m.Client().Message.Get(ctx, id)
  23634. }
  23635. })
  23636. return value, err
  23637. }
  23638. m.id = &id
  23639. }
  23640. }
  23641. // withMessage sets the old Message of the mutation.
  23642. func withMessage(node *Message) messageOption {
  23643. return func(m *MessageMutation) {
  23644. m.oldValue = func(context.Context) (*Message, error) {
  23645. return node, nil
  23646. }
  23647. m.id = &node.ID
  23648. }
  23649. }
  23650. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23651. // executed in a transaction (ent.Tx), a transactional client is returned.
  23652. func (m MessageMutation) Client() *Client {
  23653. client := &Client{config: m.config}
  23654. client.init()
  23655. return client
  23656. }
  23657. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23658. // it returns an error otherwise.
  23659. func (m MessageMutation) Tx() (*Tx, error) {
  23660. if _, ok := m.driver.(*txDriver); !ok {
  23661. return nil, errors.New("ent: mutation is not running in a transaction")
  23662. }
  23663. tx := &Tx{config: m.config}
  23664. tx.init()
  23665. return tx, nil
  23666. }
  23667. // ID returns the ID value in the mutation. Note that the ID is only available
  23668. // if it was provided to the builder or after it was returned from the database.
  23669. func (m *MessageMutation) ID() (id int, exists bool) {
  23670. if m.id == nil {
  23671. return
  23672. }
  23673. return *m.id, true
  23674. }
  23675. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23676. // That means, if the mutation is applied within a transaction with an isolation level such
  23677. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23678. // or updated by the mutation.
  23679. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  23680. switch {
  23681. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23682. id, exists := m.ID()
  23683. if exists {
  23684. return []int{id}, nil
  23685. }
  23686. fallthrough
  23687. case m.op.Is(OpUpdate | OpDelete):
  23688. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  23689. default:
  23690. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23691. }
  23692. }
  23693. // SetWxWxid sets the "wx_wxid" field.
  23694. func (m *MessageMutation) SetWxWxid(s string) {
  23695. m.wx_wxid = &s
  23696. }
  23697. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  23698. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  23699. v := m.wx_wxid
  23700. if v == nil {
  23701. return
  23702. }
  23703. return *v, true
  23704. }
  23705. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  23706. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23708. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  23709. if !m.op.Is(OpUpdateOne) {
  23710. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  23711. }
  23712. if m.id == nil || m.oldValue == nil {
  23713. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  23714. }
  23715. oldValue, err := m.oldValue(ctx)
  23716. if err != nil {
  23717. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  23718. }
  23719. return oldValue.WxWxid, nil
  23720. }
  23721. // ClearWxWxid clears the value of the "wx_wxid" field.
  23722. func (m *MessageMutation) ClearWxWxid() {
  23723. m.wx_wxid = nil
  23724. m.clearedFields[message.FieldWxWxid] = struct{}{}
  23725. }
  23726. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  23727. func (m *MessageMutation) WxWxidCleared() bool {
  23728. _, ok := m.clearedFields[message.FieldWxWxid]
  23729. return ok
  23730. }
  23731. // ResetWxWxid resets all changes to the "wx_wxid" field.
  23732. func (m *MessageMutation) ResetWxWxid() {
  23733. m.wx_wxid = nil
  23734. delete(m.clearedFields, message.FieldWxWxid)
  23735. }
  23736. // SetWxid sets the "wxid" field.
  23737. func (m *MessageMutation) SetWxid(s string) {
  23738. m.wxid = &s
  23739. }
  23740. // Wxid returns the value of the "wxid" field in the mutation.
  23741. func (m *MessageMutation) Wxid() (r string, exists bool) {
  23742. v := m.wxid
  23743. if v == nil {
  23744. return
  23745. }
  23746. return *v, true
  23747. }
  23748. // OldWxid returns the old "wxid" field's value of the Message entity.
  23749. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23751. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  23752. if !m.op.Is(OpUpdateOne) {
  23753. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23754. }
  23755. if m.id == nil || m.oldValue == nil {
  23756. return v, errors.New("OldWxid requires an ID field in the mutation")
  23757. }
  23758. oldValue, err := m.oldValue(ctx)
  23759. if err != nil {
  23760. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23761. }
  23762. return oldValue.Wxid, nil
  23763. }
  23764. // ResetWxid resets all changes to the "wxid" field.
  23765. func (m *MessageMutation) ResetWxid() {
  23766. m.wxid = nil
  23767. }
  23768. // SetContent sets the "content" field.
  23769. func (m *MessageMutation) SetContent(s string) {
  23770. m.content = &s
  23771. }
  23772. // Content returns the value of the "content" field in the mutation.
  23773. func (m *MessageMutation) Content() (r string, exists bool) {
  23774. v := m.content
  23775. if v == nil {
  23776. return
  23777. }
  23778. return *v, true
  23779. }
  23780. // OldContent returns the old "content" field's value of the Message entity.
  23781. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23783. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  23784. if !m.op.Is(OpUpdateOne) {
  23785. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23786. }
  23787. if m.id == nil || m.oldValue == nil {
  23788. return v, errors.New("OldContent requires an ID field in the mutation")
  23789. }
  23790. oldValue, err := m.oldValue(ctx)
  23791. if err != nil {
  23792. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23793. }
  23794. return oldValue.Content, nil
  23795. }
  23796. // ResetContent resets all changes to the "content" field.
  23797. func (m *MessageMutation) ResetContent() {
  23798. m.content = nil
  23799. }
  23800. // Where appends a list predicates to the MessageMutation builder.
  23801. func (m *MessageMutation) Where(ps ...predicate.Message) {
  23802. m.predicates = append(m.predicates, ps...)
  23803. }
  23804. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  23805. // users can use type-assertion to append predicates that do not depend on any generated package.
  23806. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  23807. p := make([]predicate.Message, len(ps))
  23808. for i := range ps {
  23809. p[i] = ps[i]
  23810. }
  23811. m.Where(p...)
  23812. }
  23813. // Op returns the operation name.
  23814. func (m *MessageMutation) Op() Op {
  23815. return m.op
  23816. }
  23817. // SetOp allows setting the mutation operation.
  23818. func (m *MessageMutation) SetOp(op Op) {
  23819. m.op = op
  23820. }
  23821. // Type returns the node type of this mutation (Message).
  23822. func (m *MessageMutation) Type() string {
  23823. return m.typ
  23824. }
  23825. // Fields returns all fields that were changed during this mutation. Note that in
  23826. // order to get all numeric fields that were incremented/decremented, call
  23827. // AddedFields().
  23828. func (m *MessageMutation) Fields() []string {
  23829. fields := make([]string, 0, 3)
  23830. if m.wx_wxid != nil {
  23831. fields = append(fields, message.FieldWxWxid)
  23832. }
  23833. if m.wxid != nil {
  23834. fields = append(fields, message.FieldWxid)
  23835. }
  23836. if m.content != nil {
  23837. fields = append(fields, message.FieldContent)
  23838. }
  23839. return fields
  23840. }
  23841. // Field returns the value of a field with the given name. The second boolean
  23842. // return value indicates that this field was not set, or was not defined in the
  23843. // schema.
  23844. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  23845. switch name {
  23846. case message.FieldWxWxid:
  23847. return m.WxWxid()
  23848. case message.FieldWxid:
  23849. return m.Wxid()
  23850. case message.FieldContent:
  23851. return m.Content()
  23852. }
  23853. return nil, false
  23854. }
  23855. // OldField returns the old value of the field from the database. An error is
  23856. // returned if the mutation operation is not UpdateOne, or the query to the
  23857. // database failed.
  23858. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23859. switch name {
  23860. case message.FieldWxWxid:
  23861. return m.OldWxWxid(ctx)
  23862. case message.FieldWxid:
  23863. return m.OldWxid(ctx)
  23864. case message.FieldContent:
  23865. return m.OldContent(ctx)
  23866. }
  23867. return nil, fmt.Errorf("unknown Message field %s", name)
  23868. }
  23869. // SetField sets the value of a field with the given name. It returns an error if
  23870. // the field is not defined in the schema, or if the type mismatched the field
  23871. // type.
  23872. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  23873. switch name {
  23874. case message.FieldWxWxid:
  23875. v, ok := value.(string)
  23876. if !ok {
  23877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23878. }
  23879. m.SetWxWxid(v)
  23880. return nil
  23881. case message.FieldWxid:
  23882. v, ok := value.(string)
  23883. if !ok {
  23884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23885. }
  23886. m.SetWxid(v)
  23887. return nil
  23888. case message.FieldContent:
  23889. v, ok := value.(string)
  23890. if !ok {
  23891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23892. }
  23893. m.SetContent(v)
  23894. return nil
  23895. }
  23896. return fmt.Errorf("unknown Message field %s", name)
  23897. }
  23898. // AddedFields returns all numeric fields that were incremented/decremented during
  23899. // this mutation.
  23900. func (m *MessageMutation) AddedFields() []string {
  23901. return nil
  23902. }
  23903. // AddedField returns the numeric value that was incremented/decremented on a field
  23904. // with the given name. The second boolean return value indicates that this field
  23905. // was not set, or was not defined in the schema.
  23906. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  23907. return nil, false
  23908. }
  23909. // AddField adds the value to the field with the given name. It returns an error if
  23910. // the field is not defined in the schema, or if the type mismatched the field
  23911. // type.
  23912. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  23913. switch name {
  23914. }
  23915. return fmt.Errorf("unknown Message numeric field %s", name)
  23916. }
  23917. // ClearedFields returns all nullable fields that were cleared during this
  23918. // mutation.
  23919. func (m *MessageMutation) ClearedFields() []string {
  23920. var fields []string
  23921. if m.FieldCleared(message.FieldWxWxid) {
  23922. fields = append(fields, message.FieldWxWxid)
  23923. }
  23924. return fields
  23925. }
  23926. // FieldCleared returns a boolean indicating if a field with the given name was
  23927. // cleared in this mutation.
  23928. func (m *MessageMutation) FieldCleared(name string) bool {
  23929. _, ok := m.clearedFields[name]
  23930. return ok
  23931. }
  23932. // ClearField clears the value of the field with the given name. It returns an
  23933. // error if the field is not defined in the schema.
  23934. func (m *MessageMutation) ClearField(name string) error {
  23935. switch name {
  23936. case message.FieldWxWxid:
  23937. m.ClearWxWxid()
  23938. return nil
  23939. }
  23940. return fmt.Errorf("unknown Message nullable field %s", name)
  23941. }
  23942. // ResetField resets all changes in the mutation for the field with the given name.
  23943. // It returns an error if the field is not defined in the schema.
  23944. func (m *MessageMutation) ResetField(name string) error {
  23945. switch name {
  23946. case message.FieldWxWxid:
  23947. m.ResetWxWxid()
  23948. return nil
  23949. case message.FieldWxid:
  23950. m.ResetWxid()
  23951. return nil
  23952. case message.FieldContent:
  23953. m.ResetContent()
  23954. return nil
  23955. }
  23956. return fmt.Errorf("unknown Message field %s", name)
  23957. }
  23958. // AddedEdges returns all edge names that were set/added in this mutation.
  23959. func (m *MessageMutation) AddedEdges() []string {
  23960. edges := make([]string, 0, 0)
  23961. return edges
  23962. }
  23963. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23964. // name in this mutation.
  23965. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  23966. return nil
  23967. }
  23968. // RemovedEdges returns all edge names that were removed in this mutation.
  23969. func (m *MessageMutation) RemovedEdges() []string {
  23970. edges := make([]string, 0, 0)
  23971. return edges
  23972. }
  23973. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23974. // the given name in this mutation.
  23975. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  23976. return nil
  23977. }
  23978. // ClearedEdges returns all edge names that were cleared in this mutation.
  23979. func (m *MessageMutation) ClearedEdges() []string {
  23980. edges := make([]string, 0, 0)
  23981. return edges
  23982. }
  23983. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23984. // was cleared in this mutation.
  23985. func (m *MessageMutation) EdgeCleared(name string) bool {
  23986. return false
  23987. }
  23988. // ClearEdge clears the value of the edge with the given name. It returns an error
  23989. // if that edge is not defined in the schema.
  23990. func (m *MessageMutation) ClearEdge(name string) error {
  23991. return fmt.Errorf("unknown Message unique edge %s", name)
  23992. }
  23993. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23994. // It returns an error if the edge is not defined in the schema.
  23995. func (m *MessageMutation) ResetEdge(name string) error {
  23996. return fmt.Errorf("unknown Message edge %s", name)
  23997. }
  23998. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  23999. type MessageRecordsMutation struct {
  24000. config
  24001. op Op
  24002. typ string
  24003. id *uint64
  24004. created_at *time.Time
  24005. updated_at *time.Time
  24006. status *uint8
  24007. addstatus *int8
  24008. bot_wxid *string
  24009. contact_type *int
  24010. addcontact_type *int
  24011. contact_wxid *string
  24012. content_type *int
  24013. addcontent_type *int
  24014. content *string
  24015. meta *custom_types.Meta
  24016. error_detail *string
  24017. send_time *time.Time
  24018. source_type *int
  24019. addsource_type *int
  24020. organization_id *uint64
  24021. addorganization_id *int64
  24022. clearedFields map[string]struct{}
  24023. sop_stage *uint64
  24024. clearedsop_stage bool
  24025. sop_node *uint64
  24026. clearedsop_node bool
  24027. message_contact *uint64
  24028. clearedmessage_contact bool
  24029. done bool
  24030. oldValue func(context.Context) (*MessageRecords, error)
  24031. predicates []predicate.MessageRecords
  24032. }
  24033. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  24034. // messagerecordsOption allows management of the mutation configuration using functional options.
  24035. type messagerecordsOption func(*MessageRecordsMutation)
  24036. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  24037. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  24038. m := &MessageRecordsMutation{
  24039. config: c,
  24040. op: op,
  24041. typ: TypeMessageRecords,
  24042. clearedFields: make(map[string]struct{}),
  24043. }
  24044. for _, opt := range opts {
  24045. opt(m)
  24046. }
  24047. return m
  24048. }
  24049. // withMessageRecordsID sets the ID field of the mutation.
  24050. func withMessageRecordsID(id uint64) messagerecordsOption {
  24051. return func(m *MessageRecordsMutation) {
  24052. var (
  24053. err error
  24054. once sync.Once
  24055. value *MessageRecords
  24056. )
  24057. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  24058. once.Do(func() {
  24059. if m.done {
  24060. err = errors.New("querying old values post mutation is not allowed")
  24061. } else {
  24062. value, err = m.Client().MessageRecords.Get(ctx, id)
  24063. }
  24064. })
  24065. return value, err
  24066. }
  24067. m.id = &id
  24068. }
  24069. }
  24070. // withMessageRecords sets the old MessageRecords of the mutation.
  24071. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  24072. return func(m *MessageRecordsMutation) {
  24073. m.oldValue = func(context.Context) (*MessageRecords, error) {
  24074. return node, nil
  24075. }
  24076. m.id = &node.ID
  24077. }
  24078. }
  24079. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24080. // executed in a transaction (ent.Tx), a transactional client is returned.
  24081. func (m MessageRecordsMutation) Client() *Client {
  24082. client := &Client{config: m.config}
  24083. client.init()
  24084. return client
  24085. }
  24086. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24087. // it returns an error otherwise.
  24088. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  24089. if _, ok := m.driver.(*txDriver); !ok {
  24090. return nil, errors.New("ent: mutation is not running in a transaction")
  24091. }
  24092. tx := &Tx{config: m.config}
  24093. tx.init()
  24094. return tx, nil
  24095. }
  24096. // SetID sets the value of the id field. Note that this
  24097. // operation is only accepted on creation of MessageRecords entities.
  24098. func (m *MessageRecordsMutation) SetID(id uint64) {
  24099. m.id = &id
  24100. }
  24101. // ID returns the ID value in the mutation. Note that the ID is only available
  24102. // if it was provided to the builder or after it was returned from the database.
  24103. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  24104. if m.id == nil {
  24105. return
  24106. }
  24107. return *m.id, true
  24108. }
  24109. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24110. // That means, if the mutation is applied within a transaction with an isolation level such
  24111. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24112. // or updated by the mutation.
  24113. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  24114. switch {
  24115. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24116. id, exists := m.ID()
  24117. if exists {
  24118. return []uint64{id}, nil
  24119. }
  24120. fallthrough
  24121. case m.op.Is(OpUpdate | OpDelete):
  24122. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  24123. default:
  24124. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24125. }
  24126. }
  24127. // SetCreatedAt sets the "created_at" field.
  24128. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  24129. m.created_at = &t
  24130. }
  24131. // CreatedAt returns the value of the "created_at" field in the mutation.
  24132. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  24133. v := m.created_at
  24134. if v == nil {
  24135. return
  24136. }
  24137. return *v, true
  24138. }
  24139. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  24140. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24142. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24143. if !m.op.Is(OpUpdateOne) {
  24144. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24145. }
  24146. if m.id == nil || m.oldValue == nil {
  24147. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24148. }
  24149. oldValue, err := m.oldValue(ctx)
  24150. if err != nil {
  24151. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24152. }
  24153. return oldValue.CreatedAt, nil
  24154. }
  24155. // ResetCreatedAt resets all changes to the "created_at" field.
  24156. func (m *MessageRecordsMutation) ResetCreatedAt() {
  24157. m.created_at = nil
  24158. }
  24159. // SetUpdatedAt sets the "updated_at" field.
  24160. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  24161. m.updated_at = &t
  24162. }
  24163. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24164. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  24165. v := m.updated_at
  24166. if v == nil {
  24167. return
  24168. }
  24169. return *v, true
  24170. }
  24171. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  24172. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24174. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24175. if !m.op.Is(OpUpdateOne) {
  24176. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24177. }
  24178. if m.id == nil || m.oldValue == nil {
  24179. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24180. }
  24181. oldValue, err := m.oldValue(ctx)
  24182. if err != nil {
  24183. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24184. }
  24185. return oldValue.UpdatedAt, nil
  24186. }
  24187. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24188. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  24189. m.updated_at = nil
  24190. }
  24191. // SetStatus sets the "status" field.
  24192. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  24193. m.status = &u
  24194. m.addstatus = nil
  24195. }
  24196. // Status returns the value of the "status" field in the mutation.
  24197. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  24198. v := m.status
  24199. if v == nil {
  24200. return
  24201. }
  24202. return *v, true
  24203. }
  24204. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  24205. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24207. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24208. if !m.op.Is(OpUpdateOne) {
  24209. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24210. }
  24211. if m.id == nil || m.oldValue == nil {
  24212. return v, errors.New("OldStatus requires an ID field in the mutation")
  24213. }
  24214. oldValue, err := m.oldValue(ctx)
  24215. if err != nil {
  24216. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24217. }
  24218. return oldValue.Status, nil
  24219. }
  24220. // AddStatus adds u to the "status" field.
  24221. func (m *MessageRecordsMutation) AddStatus(u int8) {
  24222. if m.addstatus != nil {
  24223. *m.addstatus += u
  24224. } else {
  24225. m.addstatus = &u
  24226. }
  24227. }
  24228. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24229. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  24230. v := m.addstatus
  24231. if v == nil {
  24232. return
  24233. }
  24234. return *v, true
  24235. }
  24236. // ClearStatus clears the value of the "status" field.
  24237. func (m *MessageRecordsMutation) ClearStatus() {
  24238. m.status = nil
  24239. m.addstatus = nil
  24240. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  24241. }
  24242. // StatusCleared returns if the "status" field was cleared in this mutation.
  24243. func (m *MessageRecordsMutation) StatusCleared() bool {
  24244. _, ok := m.clearedFields[messagerecords.FieldStatus]
  24245. return ok
  24246. }
  24247. // ResetStatus resets all changes to the "status" field.
  24248. func (m *MessageRecordsMutation) ResetStatus() {
  24249. m.status = nil
  24250. m.addstatus = nil
  24251. delete(m.clearedFields, messagerecords.FieldStatus)
  24252. }
  24253. // SetBotWxid sets the "bot_wxid" field.
  24254. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  24255. m.bot_wxid = &s
  24256. }
  24257. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  24258. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  24259. v := m.bot_wxid
  24260. if v == nil {
  24261. return
  24262. }
  24263. return *v, true
  24264. }
  24265. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  24266. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24268. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  24269. if !m.op.Is(OpUpdateOne) {
  24270. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  24271. }
  24272. if m.id == nil || m.oldValue == nil {
  24273. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  24274. }
  24275. oldValue, err := m.oldValue(ctx)
  24276. if err != nil {
  24277. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  24278. }
  24279. return oldValue.BotWxid, nil
  24280. }
  24281. // ResetBotWxid resets all changes to the "bot_wxid" field.
  24282. func (m *MessageRecordsMutation) ResetBotWxid() {
  24283. m.bot_wxid = nil
  24284. }
  24285. // SetContactID sets the "contact_id" field.
  24286. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  24287. m.message_contact = &u
  24288. }
  24289. // ContactID returns the value of the "contact_id" field in the mutation.
  24290. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  24291. v := m.message_contact
  24292. if v == nil {
  24293. return
  24294. }
  24295. return *v, true
  24296. }
  24297. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  24298. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24300. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  24301. if !m.op.Is(OpUpdateOne) {
  24302. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  24303. }
  24304. if m.id == nil || m.oldValue == nil {
  24305. return v, errors.New("OldContactID requires an ID field in the mutation")
  24306. }
  24307. oldValue, err := m.oldValue(ctx)
  24308. if err != nil {
  24309. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  24310. }
  24311. return oldValue.ContactID, nil
  24312. }
  24313. // ClearContactID clears the value of the "contact_id" field.
  24314. func (m *MessageRecordsMutation) ClearContactID() {
  24315. m.message_contact = nil
  24316. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24317. }
  24318. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  24319. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  24320. _, ok := m.clearedFields[messagerecords.FieldContactID]
  24321. return ok
  24322. }
  24323. // ResetContactID resets all changes to the "contact_id" field.
  24324. func (m *MessageRecordsMutation) ResetContactID() {
  24325. m.message_contact = nil
  24326. delete(m.clearedFields, messagerecords.FieldContactID)
  24327. }
  24328. // SetContactType sets the "contact_type" field.
  24329. func (m *MessageRecordsMutation) SetContactType(i int) {
  24330. m.contact_type = &i
  24331. m.addcontact_type = nil
  24332. }
  24333. // ContactType returns the value of the "contact_type" field in the mutation.
  24334. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  24335. v := m.contact_type
  24336. if v == nil {
  24337. return
  24338. }
  24339. return *v, true
  24340. }
  24341. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  24342. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24344. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  24345. if !m.op.Is(OpUpdateOne) {
  24346. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  24347. }
  24348. if m.id == nil || m.oldValue == nil {
  24349. return v, errors.New("OldContactType requires an ID field in the mutation")
  24350. }
  24351. oldValue, err := m.oldValue(ctx)
  24352. if err != nil {
  24353. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  24354. }
  24355. return oldValue.ContactType, nil
  24356. }
  24357. // AddContactType adds i to the "contact_type" field.
  24358. func (m *MessageRecordsMutation) AddContactType(i int) {
  24359. if m.addcontact_type != nil {
  24360. *m.addcontact_type += i
  24361. } else {
  24362. m.addcontact_type = &i
  24363. }
  24364. }
  24365. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  24366. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  24367. v := m.addcontact_type
  24368. if v == nil {
  24369. return
  24370. }
  24371. return *v, true
  24372. }
  24373. // ResetContactType resets all changes to the "contact_type" field.
  24374. func (m *MessageRecordsMutation) ResetContactType() {
  24375. m.contact_type = nil
  24376. m.addcontact_type = nil
  24377. }
  24378. // SetContactWxid sets the "contact_wxid" field.
  24379. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  24380. m.contact_wxid = &s
  24381. }
  24382. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  24383. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  24384. v := m.contact_wxid
  24385. if v == nil {
  24386. return
  24387. }
  24388. return *v, true
  24389. }
  24390. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  24391. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24393. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  24394. if !m.op.Is(OpUpdateOne) {
  24395. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  24396. }
  24397. if m.id == nil || m.oldValue == nil {
  24398. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  24399. }
  24400. oldValue, err := m.oldValue(ctx)
  24401. if err != nil {
  24402. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  24403. }
  24404. return oldValue.ContactWxid, nil
  24405. }
  24406. // ResetContactWxid resets all changes to the "contact_wxid" field.
  24407. func (m *MessageRecordsMutation) ResetContactWxid() {
  24408. m.contact_wxid = nil
  24409. }
  24410. // SetContentType sets the "content_type" field.
  24411. func (m *MessageRecordsMutation) SetContentType(i int) {
  24412. m.content_type = &i
  24413. m.addcontent_type = nil
  24414. }
  24415. // ContentType returns the value of the "content_type" field in the mutation.
  24416. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  24417. v := m.content_type
  24418. if v == nil {
  24419. return
  24420. }
  24421. return *v, true
  24422. }
  24423. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  24424. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24426. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  24427. if !m.op.Is(OpUpdateOne) {
  24428. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  24429. }
  24430. if m.id == nil || m.oldValue == nil {
  24431. return v, errors.New("OldContentType requires an ID field in the mutation")
  24432. }
  24433. oldValue, err := m.oldValue(ctx)
  24434. if err != nil {
  24435. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  24436. }
  24437. return oldValue.ContentType, nil
  24438. }
  24439. // AddContentType adds i to the "content_type" field.
  24440. func (m *MessageRecordsMutation) AddContentType(i int) {
  24441. if m.addcontent_type != nil {
  24442. *m.addcontent_type += i
  24443. } else {
  24444. m.addcontent_type = &i
  24445. }
  24446. }
  24447. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  24448. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  24449. v := m.addcontent_type
  24450. if v == nil {
  24451. return
  24452. }
  24453. return *v, true
  24454. }
  24455. // ResetContentType resets all changes to the "content_type" field.
  24456. func (m *MessageRecordsMutation) ResetContentType() {
  24457. m.content_type = nil
  24458. m.addcontent_type = nil
  24459. }
  24460. // SetContent sets the "content" field.
  24461. func (m *MessageRecordsMutation) SetContent(s string) {
  24462. m.content = &s
  24463. }
  24464. // Content returns the value of the "content" field in the mutation.
  24465. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  24466. v := m.content
  24467. if v == nil {
  24468. return
  24469. }
  24470. return *v, true
  24471. }
  24472. // OldContent returns the old "content" 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) OldContent(ctx context.Context) (v string, err error) {
  24476. if !m.op.Is(OpUpdateOne) {
  24477. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24478. }
  24479. if m.id == nil || m.oldValue == nil {
  24480. return v, errors.New("OldContent 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 OldContent: %w", err)
  24485. }
  24486. return oldValue.Content, nil
  24487. }
  24488. // ResetContent resets all changes to the "content" field.
  24489. func (m *MessageRecordsMutation) ResetContent() {
  24490. m.content = nil
  24491. }
  24492. // SetMeta sets the "meta" field.
  24493. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  24494. m.meta = &ct
  24495. }
  24496. // Meta returns the value of the "meta" field in the mutation.
  24497. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  24498. v := m.meta
  24499. if v == nil {
  24500. return
  24501. }
  24502. return *v, true
  24503. }
  24504. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  24505. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24507. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  24508. if !m.op.Is(OpUpdateOne) {
  24509. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  24510. }
  24511. if m.id == nil || m.oldValue == nil {
  24512. return v, errors.New("OldMeta requires an ID field in the mutation")
  24513. }
  24514. oldValue, err := m.oldValue(ctx)
  24515. if err != nil {
  24516. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  24517. }
  24518. return oldValue.Meta, nil
  24519. }
  24520. // ClearMeta clears the value of the "meta" field.
  24521. func (m *MessageRecordsMutation) ClearMeta() {
  24522. m.meta = nil
  24523. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  24524. }
  24525. // MetaCleared returns if the "meta" field was cleared in this mutation.
  24526. func (m *MessageRecordsMutation) MetaCleared() bool {
  24527. _, ok := m.clearedFields[messagerecords.FieldMeta]
  24528. return ok
  24529. }
  24530. // ResetMeta resets all changes to the "meta" field.
  24531. func (m *MessageRecordsMutation) ResetMeta() {
  24532. m.meta = nil
  24533. delete(m.clearedFields, messagerecords.FieldMeta)
  24534. }
  24535. // SetErrorDetail sets the "error_detail" field.
  24536. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  24537. m.error_detail = &s
  24538. }
  24539. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  24540. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  24541. v := m.error_detail
  24542. if v == nil {
  24543. return
  24544. }
  24545. return *v, true
  24546. }
  24547. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  24548. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24550. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  24551. if !m.op.Is(OpUpdateOne) {
  24552. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  24553. }
  24554. if m.id == nil || m.oldValue == nil {
  24555. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  24556. }
  24557. oldValue, err := m.oldValue(ctx)
  24558. if err != nil {
  24559. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  24560. }
  24561. return oldValue.ErrorDetail, nil
  24562. }
  24563. // ResetErrorDetail resets all changes to the "error_detail" field.
  24564. func (m *MessageRecordsMutation) ResetErrorDetail() {
  24565. m.error_detail = nil
  24566. }
  24567. // SetSendTime sets the "send_time" field.
  24568. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  24569. m.send_time = &t
  24570. }
  24571. // SendTime returns the value of the "send_time" field in the mutation.
  24572. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  24573. v := m.send_time
  24574. if v == nil {
  24575. return
  24576. }
  24577. return *v, true
  24578. }
  24579. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  24580. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24582. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  24583. if !m.op.Is(OpUpdateOne) {
  24584. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  24585. }
  24586. if m.id == nil || m.oldValue == nil {
  24587. return v, errors.New("OldSendTime requires an ID field in the mutation")
  24588. }
  24589. oldValue, err := m.oldValue(ctx)
  24590. if err != nil {
  24591. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  24592. }
  24593. return oldValue.SendTime, nil
  24594. }
  24595. // ClearSendTime clears the value of the "send_time" field.
  24596. func (m *MessageRecordsMutation) ClearSendTime() {
  24597. m.send_time = nil
  24598. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  24599. }
  24600. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  24601. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  24602. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  24603. return ok
  24604. }
  24605. // ResetSendTime resets all changes to the "send_time" field.
  24606. func (m *MessageRecordsMutation) ResetSendTime() {
  24607. m.send_time = nil
  24608. delete(m.clearedFields, messagerecords.FieldSendTime)
  24609. }
  24610. // SetSourceType sets the "source_type" field.
  24611. func (m *MessageRecordsMutation) SetSourceType(i int) {
  24612. m.source_type = &i
  24613. m.addsource_type = nil
  24614. }
  24615. // SourceType returns the value of the "source_type" field in the mutation.
  24616. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  24617. v := m.source_type
  24618. if v == nil {
  24619. return
  24620. }
  24621. return *v, true
  24622. }
  24623. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  24624. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24626. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  24627. if !m.op.Is(OpUpdateOne) {
  24628. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  24629. }
  24630. if m.id == nil || m.oldValue == nil {
  24631. return v, errors.New("OldSourceType requires an ID field in the mutation")
  24632. }
  24633. oldValue, err := m.oldValue(ctx)
  24634. if err != nil {
  24635. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  24636. }
  24637. return oldValue.SourceType, nil
  24638. }
  24639. // AddSourceType adds i to the "source_type" field.
  24640. func (m *MessageRecordsMutation) AddSourceType(i int) {
  24641. if m.addsource_type != nil {
  24642. *m.addsource_type += i
  24643. } else {
  24644. m.addsource_type = &i
  24645. }
  24646. }
  24647. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  24648. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  24649. v := m.addsource_type
  24650. if v == nil {
  24651. return
  24652. }
  24653. return *v, true
  24654. }
  24655. // ResetSourceType resets all changes to the "source_type" field.
  24656. func (m *MessageRecordsMutation) ResetSourceType() {
  24657. m.source_type = nil
  24658. m.addsource_type = nil
  24659. }
  24660. // SetSourceID sets the "source_id" field.
  24661. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  24662. m.sop_stage = &u
  24663. }
  24664. // SourceID returns the value of the "source_id" field in the mutation.
  24665. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  24666. v := m.sop_stage
  24667. if v == nil {
  24668. return
  24669. }
  24670. return *v, true
  24671. }
  24672. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  24673. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24675. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  24676. if !m.op.Is(OpUpdateOne) {
  24677. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  24678. }
  24679. if m.id == nil || m.oldValue == nil {
  24680. return v, errors.New("OldSourceID requires an ID field in the mutation")
  24681. }
  24682. oldValue, err := m.oldValue(ctx)
  24683. if err != nil {
  24684. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  24685. }
  24686. return oldValue.SourceID, nil
  24687. }
  24688. // ClearSourceID clears the value of the "source_id" field.
  24689. func (m *MessageRecordsMutation) ClearSourceID() {
  24690. m.sop_stage = nil
  24691. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24692. }
  24693. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  24694. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  24695. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  24696. return ok
  24697. }
  24698. // ResetSourceID resets all changes to the "source_id" field.
  24699. func (m *MessageRecordsMutation) ResetSourceID() {
  24700. m.sop_stage = nil
  24701. delete(m.clearedFields, messagerecords.FieldSourceID)
  24702. }
  24703. // SetSubSourceID sets the "sub_source_id" field.
  24704. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  24705. m.sop_node = &u
  24706. }
  24707. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  24708. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  24709. v := m.sop_node
  24710. if v == nil {
  24711. return
  24712. }
  24713. return *v, true
  24714. }
  24715. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  24716. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24718. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  24719. if !m.op.Is(OpUpdateOne) {
  24720. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  24721. }
  24722. if m.id == nil || m.oldValue == nil {
  24723. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  24724. }
  24725. oldValue, err := m.oldValue(ctx)
  24726. if err != nil {
  24727. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  24728. }
  24729. return oldValue.SubSourceID, nil
  24730. }
  24731. // ClearSubSourceID clears the value of the "sub_source_id" field.
  24732. func (m *MessageRecordsMutation) ClearSubSourceID() {
  24733. m.sop_node = nil
  24734. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24735. }
  24736. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  24737. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  24738. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  24739. return ok
  24740. }
  24741. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  24742. func (m *MessageRecordsMutation) ResetSubSourceID() {
  24743. m.sop_node = nil
  24744. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  24745. }
  24746. // SetOrganizationID sets the "organization_id" field.
  24747. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  24748. m.organization_id = &u
  24749. m.addorganization_id = nil
  24750. }
  24751. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24752. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  24753. v := m.organization_id
  24754. if v == nil {
  24755. return
  24756. }
  24757. return *v, true
  24758. }
  24759. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  24760. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24762. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24763. if !m.op.Is(OpUpdateOne) {
  24764. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24765. }
  24766. if m.id == nil || m.oldValue == nil {
  24767. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24768. }
  24769. oldValue, err := m.oldValue(ctx)
  24770. if err != nil {
  24771. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24772. }
  24773. return oldValue.OrganizationID, nil
  24774. }
  24775. // AddOrganizationID adds u to the "organization_id" field.
  24776. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  24777. if m.addorganization_id != nil {
  24778. *m.addorganization_id += u
  24779. } else {
  24780. m.addorganization_id = &u
  24781. }
  24782. }
  24783. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24784. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  24785. v := m.addorganization_id
  24786. if v == nil {
  24787. return
  24788. }
  24789. return *v, true
  24790. }
  24791. // ClearOrganizationID clears the value of the "organization_id" field.
  24792. func (m *MessageRecordsMutation) ClearOrganizationID() {
  24793. m.organization_id = nil
  24794. m.addorganization_id = nil
  24795. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  24796. }
  24797. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24798. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  24799. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  24800. return ok
  24801. }
  24802. // ResetOrganizationID resets all changes to the "organization_id" field.
  24803. func (m *MessageRecordsMutation) ResetOrganizationID() {
  24804. m.organization_id = nil
  24805. m.addorganization_id = nil
  24806. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  24807. }
  24808. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24809. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  24810. m.sop_stage = &id
  24811. }
  24812. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24813. func (m *MessageRecordsMutation) ClearSopStage() {
  24814. m.clearedsop_stage = true
  24815. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24816. }
  24817. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24818. func (m *MessageRecordsMutation) SopStageCleared() bool {
  24819. return m.SourceIDCleared() || m.clearedsop_stage
  24820. }
  24821. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24822. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  24823. if m.sop_stage != nil {
  24824. return *m.sop_stage, true
  24825. }
  24826. return
  24827. }
  24828. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24829. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24830. // SopStageID instead. It exists only for internal usage by the builders.
  24831. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  24832. if id := m.sop_stage; id != nil {
  24833. ids = append(ids, *id)
  24834. }
  24835. return
  24836. }
  24837. // ResetSopStage resets all changes to the "sop_stage" edge.
  24838. func (m *MessageRecordsMutation) ResetSopStage() {
  24839. m.sop_stage = nil
  24840. m.clearedsop_stage = false
  24841. }
  24842. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  24843. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  24844. m.sop_node = &id
  24845. }
  24846. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  24847. func (m *MessageRecordsMutation) ClearSopNode() {
  24848. m.clearedsop_node = true
  24849. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24850. }
  24851. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  24852. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  24853. return m.SubSourceIDCleared() || m.clearedsop_node
  24854. }
  24855. // SopNodeID returns the "sop_node" edge ID in the mutation.
  24856. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  24857. if m.sop_node != nil {
  24858. return *m.sop_node, true
  24859. }
  24860. return
  24861. }
  24862. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  24863. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24864. // SopNodeID instead. It exists only for internal usage by the builders.
  24865. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  24866. if id := m.sop_node; id != nil {
  24867. ids = append(ids, *id)
  24868. }
  24869. return
  24870. }
  24871. // ResetSopNode resets all changes to the "sop_node" edge.
  24872. func (m *MessageRecordsMutation) ResetSopNode() {
  24873. m.sop_node = nil
  24874. m.clearedsop_node = false
  24875. }
  24876. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  24877. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  24878. m.message_contact = &id
  24879. }
  24880. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  24881. func (m *MessageRecordsMutation) ClearMessageContact() {
  24882. m.clearedmessage_contact = true
  24883. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24884. }
  24885. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  24886. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  24887. return m.ContactIDCleared() || m.clearedmessage_contact
  24888. }
  24889. // MessageContactID returns the "message_contact" edge ID in the mutation.
  24890. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  24891. if m.message_contact != nil {
  24892. return *m.message_contact, true
  24893. }
  24894. return
  24895. }
  24896. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  24897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24898. // MessageContactID instead. It exists only for internal usage by the builders.
  24899. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  24900. if id := m.message_contact; id != nil {
  24901. ids = append(ids, *id)
  24902. }
  24903. return
  24904. }
  24905. // ResetMessageContact resets all changes to the "message_contact" edge.
  24906. func (m *MessageRecordsMutation) ResetMessageContact() {
  24907. m.message_contact = nil
  24908. m.clearedmessage_contact = false
  24909. }
  24910. // Where appends a list predicates to the MessageRecordsMutation builder.
  24911. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  24912. m.predicates = append(m.predicates, ps...)
  24913. }
  24914. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  24915. // users can use type-assertion to append predicates that do not depend on any generated package.
  24916. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  24917. p := make([]predicate.MessageRecords, len(ps))
  24918. for i := range ps {
  24919. p[i] = ps[i]
  24920. }
  24921. m.Where(p...)
  24922. }
  24923. // Op returns the operation name.
  24924. func (m *MessageRecordsMutation) Op() Op {
  24925. return m.op
  24926. }
  24927. // SetOp allows setting the mutation operation.
  24928. func (m *MessageRecordsMutation) SetOp(op Op) {
  24929. m.op = op
  24930. }
  24931. // Type returns the node type of this mutation (MessageRecords).
  24932. func (m *MessageRecordsMutation) Type() string {
  24933. return m.typ
  24934. }
  24935. // Fields returns all fields that were changed during this mutation. Note that in
  24936. // order to get all numeric fields that were incremented/decremented, call
  24937. // AddedFields().
  24938. func (m *MessageRecordsMutation) Fields() []string {
  24939. fields := make([]string, 0, 16)
  24940. if m.created_at != nil {
  24941. fields = append(fields, messagerecords.FieldCreatedAt)
  24942. }
  24943. if m.updated_at != nil {
  24944. fields = append(fields, messagerecords.FieldUpdatedAt)
  24945. }
  24946. if m.status != nil {
  24947. fields = append(fields, messagerecords.FieldStatus)
  24948. }
  24949. if m.bot_wxid != nil {
  24950. fields = append(fields, messagerecords.FieldBotWxid)
  24951. }
  24952. if m.message_contact != nil {
  24953. fields = append(fields, messagerecords.FieldContactID)
  24954. }
  24955. if m.contact_type != nil {
  24956. fields = append(fields, messagerecords.FieldContactType)
  24957. }
  24958. if m.contact_wxid != nil {
  24959. fields = append(fields, messagerecords.FieldContactWxid)
  24960. }
  24961. if m.content_type != nil {
  24962. fields = append(fields, messagerecords.FieldContentType)
  24963. }
  24964. if m.content != nil {
  24965. fields = append(fields, messagerecords.FieldContent)
  24966. }
  24967. if m.meta != nil {
  24968. fields = append(fields, messagerecords.FieldMeta)
  24969. }
  24970. if m.error_detail != nil {
  24971. fields = append(fields, messagerecords.FieldErrorDetail)
  24972. }
  24973. if m.send_time != nil {
  24974. fields = append(fields, messagerecords.FieldSendTime)
  24975. }
  24976. if m.source_type != nil {
  24977. fields = append(fields, messagerecords.FieldSourceType)
  24978. }
  24979. if m.sop_stage != nil {
  24980. fields = append(fields, messagerecords.FieldSourceID)
  24981. }
  24982. if m.sop_node != nil {
  24983. fields = append(fields, messagerecords.FieldSubSourceID)
  24984. }
  24985. if m.organization_id != nil {
  24986. fields = append(fields, messagerecords.FieldOrganizationID)
  24987. }
  24988. return fields
  24989. }
  24990. // Field returns the value of a field with the given name. The second boolean
  24991. // return value indicates that this field was not set, or was not defined in the
  24992. // schema.
  24993. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  24994. switch name {
  24995. case messagerecords.FieldCreatedAt:
  24996. return m.CreatedAt()
  24997. case messagerecords.FieldUpdatedAt:
  24998. return m.UpdatedAt()
  24999. case messagerecords.FieldStatus:
  25000. return m.Status()
  25001. case messagerecords.FieldBotWxid:
  25002. return m.BotWxid()
  25003. case messagerecords.FieldContactID:
  25004. return m.ContactID()
  25005. case messagerecords.FieldContactType:
  25006. return m.ContactType()
  25007. case messagerecords.FieldContactWxid:
  25008. return m.ContactWxid()
  25009. case messagerecords.FieldContentType:
  25010. return m.ContentType()
  25011. case messagerecords.FieldContent:
  25012. return m.Content()
  25013. case messagerecords.FieldMeta:
  25014. return m.Meta()
  25015. case messagerecords.FieldErrorDetail:
  25016. return m.ErrorDetail()
  25017. case messagerecords.FieldSendTime:
  25018. return m.SendTime()
  25019. case messagerecords.FieldSourceType:
  25020. return m.SourceType()
  25021. case messagerecords.FieldSourceID:
  25022. return m.SourceID()
  25023. case messagerecords.FieldSubSourceID:
  25024. return m.SubSourceID()
  25025. case messagerecords.FieldOrganizationID:
  25026. return m.OrganizationID()
  25027. }
  25028. return nil, false
  25029. }
  25030. // OldField returns the old value of the field from the database. An error is
  25031. // returned if the mutation operation is not UpdateOne, or the query to the
  25032. // database failed.
  25033. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25034. switch name {
  25035. case messagerecords.FieldCreatedAt:
  25036. return m.OldCreatedAt(ctx)
  25037. case messagerecords.FieldUpdatedAt:
  25038. return m.OldUpdatedAt(ctx)
  25039. case messagerecords.FieldStatus:
  25040. return m.OldStatus(ctx)
  25041. case messagerecords.FieldBotWxid:
  25042. return m.OldBotWxid(ctx)
  25043. case messagerecords.FieldContactID:
  25044. return m.OldContactID(ctx)
  25045. case messagerecords.FieldContactType:
  25046. return m.OldContactType(ctx)
  25047. case messagerecords.FieldContactWxid:
  25048. return m.OldContactWxid(ctx)
  25049. case messagerecords.FieldContentType:
  25050. return m.OldContentType(ctx)
  25051. case messagerecords.FieldContent:
  25052. return m.OldContent(ctx)
  25053. case messagerecords.FieldMeta:
  25054. return m.OldMeta(ctx)
  25055. case messagerecords.FieldErrorDetail:
  25056. return m.OldErrorDetail(ctx)
  25057. case messagerecords.FieldSendTime:
  25058. return m.OldSendTime(ctx)
  25059. case messagerecords.FieldSourceType:
  25060. return m.OldSourceType(ctx)
  25061. case messagerecords.FieldSourceID:
  25062. return m.OldSourceID(ctx)
  25063. case messagerecords.FieldSubSourceID:
  25064. return m.OldSubSourceID(ctx)
  25065. case messagerecords.FieldOrganizationID:
  25066. return m.OldOrganizationID(ctx)
  25067. }
  25068. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  25069. }
  25070. // SetField sets the value of a field with the given name. It returns an error if
  25071. // the field is not defined in the schema, or if the type mismatched the field
  25072. // type.
  25073. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  25074. switch name {
  25075. case messagerecords.FieldCreatedAt:
  25076. v, ok := value.(time.Time)
  25077. if !ok {
  25078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25079. }
  25080. m.SetCreatedAt(v)
  25081. return nil
  25082. case messagerecords.FieldUpdatedAt:
  25083. v, ok := value.(time.Time)
  25084. if !ok {
  25085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25086. }
  25087. m.SetUpdatedAt(v)
  25088. return nil
  25089. case messagerecords.FieldStatus:
  25090. v, ok := value.(uint8)
  25091. if !ok {
  25092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25093. }
  25094. m.SetStatus(v)
  25095. return nil
  25096. case messagerecords.FieldBotWxid:
  25097. v, ok := value.(string)
  25098. if !ok {
  25099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25100. }
  25101. m.SetBotWxid(v)
  25102. return nil
  25103. case messagerecords.FieldContactID:
  25104. v, ok := value.(uint64)
  25105. if !ok {
  25106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25107. }
  25108. m.SetContactID(v)
  25109. return nil
  25110. case messagerecords.FieldContactType:
  25111. v, ok := value.(int)
  25112. if !ok {
  25113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25114. }
  25115. m.SetContactType(v)
  25116. return nil
  25117. case messagerecords.FieldContactWxid:
  25118. v, ok := value.(string)
  25119. if !ok {
  25120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25121. }
  25122. m.SetContactWxid(v)
  25123. return nil
  25124. case messagerecords.FieldContentType:
  25125. v, ok := value.(int)
  25126. if !ok {
  25127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25128. }
  25129. m.SetContentType(v)
  25130. return nil
  25131. case messagerecords.FieldContent:
  25132. v, ok := value.(string)
  25133. if !ok {
  25134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25135. }
  25136. m.SetContent(v)
  25137. return nil
  25138. case messagerecords.FieldMeta:
  25139. v, ok := value.(custom_types.Meta)
  25140. if !ok {
  25141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25142. }
  25143. m.SetMeta(v)
  25144. return nil
  25145. case messagerecords.FieldErrorDetail:
  25146. v, ok := value.(string)
  25147. if !ok {
  25148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25149. }
  25150. m.SetErrorDetail(v)
  25151. return nil
  25152. case messagerecords.FieldSendTime:
  25153. v, ok := value.(time.Time)
  25154. if !ok {
  25155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25156. }
  25157. m.SetSendTime(v)
  25158. return nil
  25159. case messagerecords.FieldSourceType:
  25160. v, ok := value.(int)
  25161. if !ok {
  25162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25163. }
  25164. m.SetSourceType(v)
  25165. return nil
  25166. case messagerecords.FieldSourceID:
  25167. v, ok := value.(uint64)
  25168. if !ok {
  25169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25170. }
  25171. m.SetSourceID(v)
  25172. return nil
  25173. case messagerecords.FieldSubSourceID:
  25174. v, ok := value.(uint64)
  25175. if !ok {
  25176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25177. }
  25178. m.SetSubSourceID(v)
  25179. return nil
  25180. case messagerecords.FieldOrganizationID:
  25181. v, ok := value.(uint64)
  25182. if !ok {
  25183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25184. }
  25185. m.SetOrganizationID(v)
  25186. return nil
  25187. }
  25188. return fmt.Errorf("unknown MessageRecords field %s", name)
  25189. }
  25190. // AddedFields returns all numeric fields that were incremented/decremented during
  25191. // this mutation.
  25192. func (m *MessageRecordsMutation) AddedFields() []string {
  25193. var fields []string
  25194. if m.addstatus != nil {
  25195. fields = append(fields, messagerecords.FieldStatus)
  25196. }
  25197. if m.addcontact_type != nil {
  25198. fields = append(fields, messagerecords.FieldContactType)
  25199. }
  25200. if m.addcontent_type != nil {
  25201. fields = append(fields, messagerecords.FieldContentType)
  25202. }
  25203. if m.addsource_type != nil {
  25204. fields = append(fields, messagerecords.FieldSourceType)
  25205. }
  25206. if m.addorganization_id != nil {
  25207. fields = append(fields, messagerecords.FieldOrganizationID)
  25208. }
  25209. return fields
  25210. }
  25211. // AddedField returns the numeric value that was incremented/decremented on a field
  25212. // with the given name. The second boolean return value indicates that this field
  25213. // was not set, or was not defined in the schema.
  25214. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  25215. switch name {
  25216. case messagerecords.FieldStatus:
  25217. return m.AddedStatus()
  25218. case messagerecords.FieldContactType:
  25219. return m.AddedContactType()
  25220. case messagerecords.FieldContentType:
  25221. return m.AddedContentType()
  25222. case messagerecords.FieldSourceType:
  25223. return m.AddedSourceType()
  25224. case messagerecords.FieldOrganizationID:
  25225. return m.AddedOrganizationID()
  25226. }
  25227. return nil, false
  25228. }
  25229. // AddField adds the value to the field with the given name. It returns an error if
  25230. // the field is not defined in the schema, or if the type mismatched the field
  25231. // type.
  25232. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  25233. switch name {
  25234. case messagerecords.FieldStatus:
  25235. v, ok := value.(int8)
  25236. if !ok {
  25237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25238. }
  25239. m.AddStatus(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.AddContactType(v)
  25247. return nil
  25248. case messagerecords.FieldContentType:
  25249. v, ok := value.(int)
  25250. if !ok {
  25251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25252. }
  25253. m.AddContentType(v)
  25254. return nil
  25255. case messagerecords.FieldSourceType:
  25256. v, ok := value.(int)
  25257. if !ok {
  25258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25259. }
  25260. m.AddSourceType(v)
  25261. return nil
  25262. case messagerecords.FieldOrganizationID:
  25263. v, ok := value.(int64)
  25264. if !ok {
  25265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25266. }
  25267. m.AddOrganizationID(v)
  25268. return nil
  25269. }
  25270. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  25271. }
  25272. // ClearedFields returns all nullable fields that were cleared during this
  25273. // mutation.
  25274. func (m *MessageRecordsMutation) ClearedFields() []string {
  25275. var fields []string
  25276. if m.FieldCleared(messagerecords.FieldStatus) {
  25277. fields = append(fields, messagerecords.FieldStatus)
  25278. }
  25279. if m.FieldCleared(messagerecords.FieldContactID) {
  25280. fields = append(fields, messagerecords.FieldContactID)
  25281. }
  25282. if m.FieldCleared(messagerecords.FieldMeta) {
  25283. fields = append(fields, messagerecords.FieldMeta)
  25284. }
  25285. if m.FieldCleared(messagerecords.FieldSendTime) {
  25286. fields = append(fields, messagerecords.FieldSendTime)
  25287. }
  25288. if m.FieldCleared(messagerecords.FieldSourceID) {
  25289. fields = append(fields, messagerecords.FieldSourceID)
  25290. }
  25291. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  25292. fields = append(fields, messagerecords.FieldSubSourceID)
  25293. }
  25294. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  25295. fields = append(fields, messagerecords.FieldOrganizationID)
  25296. }
  25297. return fields
  25298. }
  25299. // FieldCleared returns a boolean indicating if a field with the given name was
  25300. // cleared in this mutation.
  25301. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  25302. _, ok := m.clearedFields[name]
  25303. return ok
  25304. }
  25305. // ClearField clears the value of the field with the given name. It returns an
  25306. // error if the field is not defined in the schema.
  25307. func (m *MessageRecordsMutation) ClearField(name string) error {
  25308. switch name {
  25309. case messagerecords.FieldStatus:
  25310. m.ClearStatus()
  25311. return nil
  25312. case messagerecords.FieldContactID:
  25313. m.ClearContactID()
  25314. return nil
  25315. case messagerecords.FieldMeta:
  25316. m.ClearMeta()
  25317. return nil
  25318. case messagerecords.FieldSendTime:
  25319. m.ClearSendTime()
  25320. return nil
  25321. case messagerecords.FieldSourceID:
  25322. m.ClearSourceID()
  25323. return nil
  25324. case messagerecords.FieldSubSourceID:
  25325. m.ClearSubSourceID()
  25326. return nil
  25327. case messagerecords.FieldOrganizationID:
  25328. m.ClearOrganizationID()
  25329. return nil
  25330. }
  25331. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  25332. }
  25333. // ResetField resets all changes in the mutation for the field with the given name.
  25334. // It returns an error if the field is not defined in the schema.
  25335. func (m *MessageRecordsMutation) ResetField(name string) error {
  25336. switch name {
  25337. case messagerecords.FieldCreatedAt:
  25338. m.ResetCreatedAt()
  25339. return nil
  25340. case messagerecords.FieldUpdatedAt:
  25341. m.ResetUpdatedAt()
  25342. return nil
  25343. case messagerecords.FieldStatus:
  25344. m.ResetStatus()
  25345. return nil
  25346. case messagerecords.FieldBotWxid:
  25347. m.ResetBotWxid()
  25348. return nil
  25349. case messagerecords.FieldContactID:
  25350. m.ResetContactID()
  25351. return nil
  25352. case messagerecords.FieldContactType:
  25353. m.ResetContactType()
  25354. return nil
  25355. case messagerecords.FieldContactWxid:
  25356. m.ResetContactWxid()
  25357. return nil
  25358. case messagerecords.FieldContentType:
  25359. m.ResetContentType()
  25360. return nil
  25361. case messagerecords.FieldContent:
  25362. m.ResetContent()
  25363. return nil
  25364. case messagerecords.FieldMeta:
  25365. m.ResetMeta()
  25366. return nil
  25367. case messagerecords.FieldErrorDetail:
  25368. m.ResetErrorDetail()
  25369. return nil
  25370. case messagerecords.FieldSendTime:
  25371. m.ResetSendTime()
  25372. return nil
  25373. case messagerecords.FieldSourceType:
  25374. m.ResetSourceType()
  25375. return nil
  25376. case messagerecords.FieldSourceID:
  25377. m.ResetSourceID()
  25378. return nil
  25379. case messagerecords.FieldSubSourceID:
  25380. m.ResetSubSourceID()
  25381. return nil
  25382. case messagerecords.FieldOrganizationID:
  25383. m.ResetOrganizationID()
  25384. return nil
  25385. }
  25386. return fmt.Errorf("unknown MessageRecords field %s", name)
  25387. }
  25388. // AddedEdges returns all edge names that were set/added in this mutation.
  25389. func (m *MessageRecordsMutation) AddedEdges() []string {
  25390. edges := make([]string, 0, 3)
  25391. if m.sop_stage != nil {
  25392. edges = append(edges, messagerecords.EdgeSopStage)
  25393. }
  25394. if m.sop_node != nil {
  25395. edges = append(edges, messagerecords.EdgeSopNode)
  25396. }
  25397. if m.message_contact != nil {
  25398. edges = append(edges, messagerecords.EdgeMessageContact)
  25399. }
  25400. return edges
  25401. }
  25402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25403. // name in this mutation.
  25404. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  25405. switch name {
  25406. case messagerecords.EdgeSopStage:
  25407. if id := m.sop_stage; id != nil {
  25408. return []ent.Value{*id}
  25409. }
  25410. case messagerecords.EdgeSopNode:
  25411. if id := m.sop_node; id != nil {
  25412. return []ent.Value{*id}
  25413. }
  25414. case messagerecords.EdgeMessageContact:
  25415. if id := m.message_contact; id != nil {
  25416. return []ent.Value{*id}
  25417. }
  25418. }
  25419. return nil
  25420. }
  25421. // RemovedEdges returns all edge names that were removed in this mutation.
  25422. func (m *MessageRecordsMutation) RemovedEdges() []string {
  25423. edges := make([]string, 0, 3)
  25424. return edges
  25425. }
  25426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25427. // the given name in this mutation.
  25428. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  25429. return nil
  25430. }
  25431. // ClearedEdges returns all edge names that were cleared in this mutation.
  25432. func (m *MessageRecordsMutation) ClearedEdges() []string {
  25433. edges := make([]string, 0, 3)
  25434. if m.clearedsop_stage {
  25435. edges = append(edges, messagerecords.EdgeSopStage)
  25436. }
  25437. if m.clearedsop_node {
  25438. edges = append(edges, messagerecords.EdgeSopNode)
  25439. }
  25440. if m.clearedmessage_contact {
  25441. edges = append(edges, messagerecords.EdgeMessageContact)
  25442. }
  25443. return edges
  25444. }
  25445. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25446. // was cleared in this mutation.
  25447. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  25448. switch name {
  25449. case messagerecords.EdgeSopStage:
  25450. return m.clearedsop_stage
  25451. case messagerecords.EdgeSopNode:
  25452. return m.clearedsop_node
  25453. case messagerecords.EdgeMessageContact:
  25454. return m.clearedmessage_contact
  25455. }
  25456. return false
  25457. }
  25458. // ClearEdge clears the value of the edge with the given name. It returns an error
  25459. // if that edge is not defined in the schema.
  25460. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  25461. switch name {
  25462. case messagerecords.EdgeSopStage:
  25463. m.ClearSopStage()
  25464. return nil
  25465. case messagerecords.EdgeSopNode:
  25466. m.ClearSopNode()
  25467. return nil
  25468. case messagerecords.EdgeMessageContact:
  25469. m.ClearMessageContact()
  25470. return nil
  25471. }
  25472. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  25473. }
  25474. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25475. // It returns an error if the edge is not defined in the schema.
  25476. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  25477. switch name {
  25478. case messagerecords.EdgeSopStage:
  25479. m.ResetSopStage()
  25480. return nil
  25481. case messagerecords.EdgeSopNode:
  25482. m.ResetSopNode()
  25483. return nil
  25484. case messagerecords.EdgeMessageContact:
  25485. m.ResetMessageContact()
  25486. return nil
  25487. }
  25488. return fmt.Errorf("unknown MessageRecords edge %s", name)
  25489. }
  25490. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  25491. type MsgMutation struct {
  25492. config
  25493. op Op
  25494. typ string
  25495. id *uint64
  25496. created_at *time.Time
  25497. updated_at *time.Time
  25498. deleted_at *time.Time
  25499. status *uint8
  25500. addstatus *int8
  25501. fromwxid *string
  25502. toid *string
  25503. msgtype *int32
  25504. addmsgtype *int32
  25505. msg *string
  25506. batch_no *string
  25507. cc *string
  25508. phone *string
  25509. clearedFields map[string]struct{}
  25510. done bool
  25511. oldValue func(context.Context) (*Msg, error)
  25512. predicates []predicate.Msg
  25513. }
  25514. var _ ent.Mutation = (*MsgMutation)(nil)
  25515. // msgOption allows management of the mutation configuration using functional options.
  25516. type msgOption func(*MsgMutation)
  25517. // newMsgMutation creates new mutation for the Msg entity.
  25518. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  25519. m := &MsgMutation{
  25520. config: c,
  25521. op: op,
  25522. typ: TypeMsg,
  25523. clearedFields: make(map[string]struct{}),
  25524. }
  25525. for _, opt := range opts {
  25526. opt(m)
  25527. }
  25528. return m
  25529. }
  25530. // withMsgID sets the ID field of the mutation.
  25531. func withMsgID(id uint64) msgOption {
  25532. return func(m *MsgMutation) {
  25533. var (
  25534. err error
  25535. once sync.Once
  25536. value *Msg
  25537. )
  25538. m.oldValue = func(ctx context.Context) (*Msg, error) {
  25539. once.Do(func() {
  25540. if m.done {
  25541. err = errors.New("querying old values post mutation is not allowed")
  25542. } else {
  25543. value, err = m.Client().Msg.Get(ctx, id)
  25544. }
  25545. })
  25546. return value, err
  25547. }
  25548. m.id = &id
  25549. }
  25550. }
  25551. // withMsg sets the old Msg of the mutation.
  25552. func withMsg(node *Msg) msgOption {
  25553. return func(m *MsgMutation) {
  25554. m.oldValue = func(context.Context) (*Msg, error) {
  25555. return node, nil
  25556. }
  25557. m.id = &node.ID
  25558. }
  25559. }
  25560. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25561. // executed in a transaction (ent.Tx), a transactional client is returned.
  25562. func (m MsgMutation) Client() *Client {
  25563. client := &Client{config: m.config}
  25564. client.init()
  25565. return client
  25566. }
  25567. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25568. // it returns an error otherwise.
  25569. func (m MsgMutation) Tx() (*Tx, error) {
  25570. if _, ok := m.driver.(*txDriver); !ok {
  25571. return nil, errors.New("ent: mutation is not running in a transaction")
  25572. }
  25573. tx := &Tx{config: m.config}
  25574. tx.init()
  25575. return tx, nil
  25576. }
  25577. // SetID sets the value of the id field. Note that this
  25578. // operation is only accepted on creation of Msg entities.
  25579. func (m *MsgMutation) SetID(id uint64) {
  25580. m.id = &id
  25581. }
  25582. // ID returns the ID value in the mutation. Note that the ID is only available
  25583. // if it was provided to the builder or after it was returned from the database.
  25584. func (m *MsgMutation) ID() (id uint64, exists bool) {
  25585. if m.id == nil {
  25586. return
  25587. }
  25588. return *m.id, true
  25589. }
  25590. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25591. // That means, if the mutation is applied within a transaction with an isolation level such
  25592. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25593. // or updated by the mutation.
  25594. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  25595. switch {
  25596. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25597. id, exists := m.ID()
  25598. if exists {
  25599. return []uint64{id}, nil
  25600. }
  25601. fallthrough
  25602. case m.op.Is(OpUpdate | OpDelete):
  25603. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  25604. default:
  25605. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25606. }
  25607. }
  25608. // SetCreatedAt sets the "created_at" field.
  25609. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  25610. m.created_at = &t
  25611. }
  25612. // CreatedAt returns the value of the "created_at" field in the mutation.
  25613. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  25614. v := m.created_at
  25615. if v == nil {
  25616. return
  25617. }
  25618. return *v, true
  25619. }
  25620. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  25621. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25623. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25624. if !m.op.Is(OpUpdateOne) {
  25625. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25626. }
  25627. if m.id == nil || m.oldValue == nil {
  25628. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25629. }
  25630. oldValue, err := m.oldValue(ctx)
  25631. if err != nil {
  25632. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25633. }
  25634. return oldValue.CreatedAt, nil
  25635. }
  25636. // ResetCreatedAt resets all changes to the "created_at" field.
  25637. func (m *MsgMutation) ResetCreatedAt() {
  25638. m.created_at = nil
  25639. }
  25640. // SetUpdatedAt sets the "updated_at" field.
  25641. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  25642. m.updated_at = &t
  25643. }
  25644. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25645. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  25646. v := m.updated_at
  25647. if v == nil {
  25648. return
  25649. }
  25650. return *v, true
  25651. }
  25652. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  25653. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25655. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25656. if !m.op.Is(OpUpdateOne) {
  25657. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25658. }
  25659. if m.id == nil || m.oldValue == nil {
  25660. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25661. }
  25662. oldValue, err := m.oldValue(ctx)
  25663. if err != nil {
  25664. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25665. }
  25666. return oldValue.UpdatedAt, nil
  25667. }
  25668. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25669. func (m *MsgMutation) ResetUpdatedAt() {
  25670. m.updated_at = nil
  25671. }
  25672. // SetDeletedAt sets the "deleted_at" field.
  25673. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  25674. m.deleted_at = &t
  25675. }
  25676. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25677. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  25678. v := m.deleted_at
  25679. if v == nil {
  25680. return
  25681. }
  25682. return *v, true
  25683. }
  25684. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  25685. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25687. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25688. if !m.op.Is(OpUpdateOne) {
  25689. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25690. }
  25691. if m.id == nil || m.oldValue == nil {
  25692. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25693. }
  25694. oldValue, err := m.oldValue(ctx)
  25695. if err != nil {
  25696. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25697. }
  25698. return oldValue.DeletedAt, nil
  25699. }
  25700. // ClearDeletedAt clears the value of the "deleted_at" field.
  25701. func (m *MsgMutation) ClearDeletedAt() {
  25702. m.deleted_at = nil
  25703. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  25704. }
  25705. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25706. func (m *MsgMutation) DeletedAtCleared() bool {
  25707. _, ok := m.clearedFields[msg.FieldDeletedAt]
  25708. return ok
  25709. }
  25710. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25711. func (m *MsgMutation) ResetDeletedAt() {
  25712. m.deleted_at = nil
  25713. delete(m.clearedFields, msg.FieldDeletedAt)
  25714. }
  25715. // SetStatus sets the "status" field.
  25716. func (m *MsgMutation) SetStatus(u uint8) {
  25717. m.status = &u
  25718. m.addstatus = nil
  25719. }
  25720. // Status returns the value of the "status" field in the mutation.
  25721. func (m *MsgMutation) Status() (r uint8, exists bool) {
  25722. v := m.status
  25723. if v == nil {
  25724. return
  25725. }
  25726. return *v, true
  25727. }
  25728. // OldStatus returns the old "status" field's value of the Msg entity.
  25729. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25731. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25732. if !m.op.Is(OpUpdateOne) {
  25733. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25734. }
  25735. if m.id == nil || m.oldValue == nil {
  25736. return v, errors.New("OldStatus requires an ID field in the mutation")
  25737. }
  25738. oldValue, err := m.oldValue(ctx)
  25739. if err != nil {
  25740. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25741. }
  25742. return oldValue.Status, nil
  25743. }
  25744. // AddStatus adds u to the "status" field.
  25745. func (m *MsgMutation) AddStatus(u int8) {
  25746. if m.addstatus != nil {
  25747. *m.addstatus += u
  25748. } else {
  25749. m.addstatus = &u
  25750. }
  25751. }
  25752. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25753. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  25754. v := m.addstatus
  25755. if v == nil {
  25756. return
  25757. }
  25758. return *v, true
  25759. }
  25760. // ClearStatus clears the value of the "status" field.
  25761. func (m *MsgMutation) ClearStatus() {
  25762. m.status = nil
  25763. m.addstatus = nil
  25764. m.clearedFields[msg.FieldStatus] = struct{}{}
  25765. }
  25766. // StatusCleared returns if the "status" field was cleared in this mutation.
  25767. func (m *MsgMutation) StatusCleared() bool {
  25768. _, ok := m.clearedFields[msg.FieldStatus]
  25769. return ok
  25770. }
  25771. // ResetStatus resets all changes to the "status" field.
  25772. func (m *MsgMutation) ResetStatus() {
  25773. m.status = nil
  25774. m.addstatus = nil
  25775. delete(m.clearedFields, msg.FieldStatus)
  25776. }
  25777. // SetFromwxid sets the "fromwxid" field.
  25778. func (m *MsgMutation) SetFromwxid(s string) {
  25779. m.fromwxid = &s
  25780. }
  25781. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  25782. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  25783. v := m.fromwxid
  25784. if v == nil {
  25785. return
  25786. }
  25787. return *v, true
  25788. }
  25789. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  25790. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25792. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  25793. if !m.op.Is(OpUpdateOne) {
  25794. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  25795. }
  25796. if m.id == nil || m.oldValue == nil {
  25797. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  25798. }
  25799. oldValue, err := m.oldValue(ctx)
  25800. if err != nil {
  25801. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  25802. }
  25803. return oldValue.Fromwxid, nil
  25804. }
  25805. // ClearFromwxid clears the value of the "fromwxid" field.
  25806. func (m *MsgMutation) ClearFromwxid() {
  25807. m.fromwxid = nil
  25808. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  25809. }
  25810. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  25811. func (m *MsgMutation) FromwxidCleared() bool {
  25812. _, ok := m.clearedFields[msg.FieldFromwxid]
  25813. return ok
  25814. }
  25815. // ResetFromwxid resets all changes to the "fromwxid" field.
  25816. func (m *MsgMutation) ResetFromwxid() {
  25817. m.fromwxid = nil
  25818. delete(m.clearedFields, msg.FieldFromwxid)
  25819. }
  25820. // SetToid sets the "toid" field.
  25821. func (m *MsgMutation) SetToid(s string) {
  25822. m.toid = &s
  25823. }
  25824. // Toid returns the value of the "toid" field in the mutation.
  25825. func (m *MsgMutation) Toid() (r string, exists bool) {
  25826. v := m.toid
  25827. if v == nil {
  25828. return
  25829. }
  25830. return *v, true
  25831. }
  25832. // OldToid returns the old "toid" field's value of the Msg entity.
  25833. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25835. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  25836. if !m.op.Is(OpUpdateOne) {
  25837. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  25838. }
  25839. if m.id == nil || m.oldValue == nil {
  25840. return v, errors.New("OldToid requires an ID field in the mutation")
  25841. }
  25842. oldValue, err := m.oldValue(ctx)
  25843. if err != nil {
  25844. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  25845. }
  25846. return oldValue.Toid, nil
  25847. }
  25848. // ClearToid clears the value of the "toid" field.
  25849. func (m *MsgMutation) ClearToid() {
  25850. m.toid = nil
  25851. m.clearedFields[msg.FieldToid] = struct{}{}
  25852. }
  25853. // ToidCleared returns if the "toid" field was cleared in this mutation.
  25854. func (m *MsgMutation) ToidCleared() bool {
  25855. _, ok := m.clearedFields[msg.FieldToid]
  25856. return ok
  25857. }
  25858. // ResetToid resets all changes to the "toid" field.
  25859. func (m *MsgMutation) ResetToid() {
  25860. m.toid = nil
  25861. delete(m.clearedFields, msg.FieldToid)
  25862. }
  25863. // SetMsgtype sets the "msgtype" field.
  25864. func (m *MsgMutation) SetMsgtype(i int32) {
  25865. m.msgtype = &i
  25866. m.addmsgtype = nil
  25867. }
  25868. // Msgtype returns the value of the "msgtype" field in the mutation.
  25869. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  25870. v := m.msgtype
  25871. if v == nil {
  25872. return
  25873. }
  25874. return *v, true
  25875. }
  25876. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  25877. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25879. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  25880. if !m.op.Is(OpUpdateOne) {
  25881. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  25882. }
  25883. if m.id == nil || m.oldValue == nil {
  25884. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  25885. }
  25886. oldValue, err := m.oldValue(ctx)
  25887. if err != nil {
  25888. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  25889. }
  25890. return oldValue.Msgtype, nil
  25891. }
  25892. // AddMsgtype adds i to the "msgtype" field.
  25893. func (m *MsgMutation) AddMsgtype(i int32) {
  25894. if m.addmsgtype != nil {
  25895. *m.addmsgtype += i
  25896. } else {
  25897. m.addmsgtype = &i
  25898. }
  25899. }
  25900. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  25901. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  25902. v := m.addmsgtype
  25903. if v == nil {
  25904. return
  25905. }
  25906. return *v, true
  25907. }
  25908. // ClearMsgtype clears the value of the "msgtype" field.
  25909. func (m *MsgMutation) ClearMsgtype() {
  25910. m.msgtype = nil
  25911. m.addmsgtype = nil
  25912. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  25913. }
  25914. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  25915. func (m *MsgMutation) MsgtypeCleared() bool {
  25916. _, ok := m.clearedFields[msg.FieldMsgtype]
  25917. return ok
  25918. }
  25919. // ResetMsgtype resets all changes to the "msgtype" field.
  25920. func (m *MsgMutation) ResetMsgtype() {
  25921. m.msgtype = nil
  25922. m.addmsgtype = nil
  25923. delete(m.clearedFields, msg.FieldMsgtype)
  25924. }
  25925. // SetMsg sets the "msg" field.
  25926. func (m *MsgMutation) SetMsg(s string) {
  25927. m.msg = &s
  25928. }
  25929. // Msg returns the value of the "msg" field in the mutation.
  25930. func (m *MsgMutation) Msg() (r string, exists bool) {
  25931. v := m.msg
  25932. if v == nil {
  25933. return
  25934. }
  25935. return *v, true
  25936. }
  25937. // OldMsg returns the old "msg" field's value of the Msg entity.
  25938. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25940. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  25941. if !m.op.Is(OpUpdateOne) {
  25942. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  25943. }
  25944. if m.id == nil || m.oldValue == nil {
  25945. return v, errors.New("OldMsg requires an ID field in the mutation")
  25946. }
  25947. oldValue, err := m.oldValue(ctx)
  25948. if err != nil {
  25949. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  25950. }
  25951. return oldValue.Msg, nil
  25952. }
  25953. // ClearMsg clears the value of the "msg" field.
  25954. func (m *MsgMutation) ClearMsg() {
  25955. m.msg = nil
  25956. m.clearedFields[msg.FieldMsg] = struct{}{}
  25957. }
  25958. // MsgCleared returns if the "msg" field was cleared in this mutation.
  25959. func (m *MsgMutation) MsgCleared() bool {
  25960. _, ok := m.clearedFields[msg.FieldMsg]
  25961. return ok
  25962. }
  25963. // ResetMsg resets all changes to the "msg" field.
  25964. func (m *MsgMutation) ResetMsg() {
  25965. m.msg = nil
  25966. delete(m.clearedFields, msg.FieldMsg)
  25967. }
  25968. // SetBatchNo sets the "batch_no" field.
  25969. func (m *MsgMutation) SetBatchNo(s string) {
  25970. m.batch_no = &s
  25971. }
  25972. // BatchNo returns the value of the "batch_no" field in the mutation.
  25973. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  25974. v := m.batch_no
  25975. if v == nil {
  25976. return
  25977. }
  25978. return *v, true
  25979. }
  25980. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  25981. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25983. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  25984. if !m.op.Is(OpUpdateOne) {
  25985. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  25986. }
  25987. if m.id == nil || m.oldValue == nil {
  25988. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  25989. }
  25990. oldValue, err := m.oldValue(ctx)
  25991. if err != nil {
  25992. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  25993. }
  25994. return oldValue.BatchNo, nil
  25995. }
  25996. // ClearBatchNo clears the value of the "batch_no" field.
  25997. func (m *MsgMutation) ClearBatchNo() {
  25998. m.batch_no = nil
  25999. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  26000. }
  26001. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  26002. func (m *MsgMutation) BatchNoCleared() bool {
  26003. _, ok := m.clearedFields[msg.FieldBatchNo]
  26004. return ok
  26005. }
  26006. // ResetBatchNo resets all changes to the "batch_no" field.
  26007. func (m *MsgMutation) ResetBatchNo() {
  26008. m.batch_no = nil
  26009. delete(m.clearedFields, msg.FieldBatchNo)
  26010. }
  26011. // SetCc sets the "cc" field.
  26012. func (m *MsgMutation) SetCc(s string) {
  26013. m.cc = &s
  26014. }
  26015. // Cc returns the value of the "cc" field in the mutation.
  26016. func (m *MsgMutation) Cc() (r string, exists bool) {
  26017. v := m.cc
  26018. if v == nil {
  26019. return
  26020. }
  26021. return *v, true
  26022. }
  26023. // OldCc returns the old "cc" field's value of the Msg entity.
  26024. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26026. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  26027. if !m.op.Is(OpUpdateOne) {
  26028. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  26029. }
  26030. if m.id == nil || m.oldValue == nil {
  26031. return v, errors.New("OldCc requires an ID field in the mutation")
  26032. }
  26033. oldValue, err := m.oldValue(ctx)
  26034. if err != nil {
  26035. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  26036. }
  26037. return oldValue.Cc, nil
  26038. }
  26039. // ResetCc resets all changes to the "cc" field.
  26040. func (m *MsgMutation) ResetCc() {
  26041. m.cc = nil
  26042. }
  26043. // SetPhone sets the "phone" field.
  26044. func (m *MsgMutation) SetPhone(s string) {
  26045. m.phone = &s
  26046. }
  26047. // Phone returns the value of the "phone" field in the mutation.
  26048. func (m *MsgMutation) Phone() (r string, exists bool) {
  26049. v := m.phone
  26050. if v == nil {
  26051. return
  26052. }
  26053. return *v, true
  26054. }
  26055. // OldPhone returns the old "phone" field's value of the Msg entity.
  26056. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26058. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  26059. if !m.op.Is(OpUpdateOne) {
  26060. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26061. }
  26062. if m.id == nil || m.oldValue == nil {
  26063. return v, errors.New("OldPhone requires an ID field in the mutation")
  26064. }
  26065. oldValue, err := m.oldValue(ctx)
  26066. if err != nil {
  26067. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26068. }
  26069. return oldValue.Phone, nil
  26070. }
  26071. // ResetPhone resets all changes to the "phone" field.
  26072. func (m *MsgMutation) ResetPhone() {
  26073. m.phone = nil
  26074. }
  26075. // Where appends a list predicates to the MsgMutation builder.
  26076. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  26077. m.predicates = append(m.predicates, ps...)
  26078. }
  26079. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  26080. // users can use type-assertion to append predicates that do not depend on any generated package.
  26081. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  26082. p := make([]predicate.Msg, len(ps))
  26083. for i := range ps {
  26084. p[i] = ps[i]
  26085. }
  26086. m.Where(p...)
  26087. }
  26088. // Op returns the operation name.
  26089. func (m *MsgMutation) Op() Op {
  26090. return m.op
  26091. }
  26092. // SetOp allows setting the mutation operation.
  26093. func (m *MsgMutation) SetOp(op Op) {
  26094. m.op = op
  26095. }
  26096. // Type returns the node type of this mutation (Msg).
  26097. func (m *MsgMutation) Type() string {
  26098. return m.typ
  26099. }
  26100. // Fields returns all fields that were changed during this mutation. Note that in
  26101. // order to get all numeric fields that were incremented/decremented, call
  26102. // AddedFields().
  26103. func (m *MsgMutation) Fields() []string {
  26104. fields := make([]string, 0, 11)
  26105. if m.created_at != nil {
  26106. fields = append(fields, msg.FieldCreatedAt)
  26107. }
  26108. if m.updated_at != nil {
  26109. fields = append(fields, msg.FieldUpdatedAt)
  26110. }
  26111. if m.deleted_at != nil {
  26112. fields = append(fields, msg.FieldDeletedAt)
  26113. }
  26114. if m.status != nil {
  26115. fields = append(fields, msg.FieldStatus)
  26116. }
  26117. if m.fromwxid != nil {
  26118. fields = append(fields, msg.FieldFromwxid)
  26119. }
  26120. if m.toid != nil {
  26121. fields = append(fields, msg.FieldToid)
  26122. }
  26123. if m.msgtype != nil {
  26124. fields = append(fields, msg.FieldMsgtype)
  26125. }
  26126. if m.msg != nil {
  26127. fields = append(fields, msg.FieldMsg)
  26128. }
  26129. if m.batch_no != nil {
  26130. fields = append(fields, msg.FieldBatchNo)
  26131. }
  26132. if m.cc != nil {
  26133. fields = append(fields, msg.FieldCc)
  26134. }
  26135. if m.phone != nil {
  26136. fields = append(fields, msg.FieldPhone)
  26137. }
  26138. return fields
  26139. }
  26140. // Field returns the value of a field with the given name. The second boolean
  26141. // return value indicates that this field was not set, or was not defined in the
  26142. // schema.
  26143. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  26144. switch name {
  26145. case msg.FieldCreatedAt:
  26146. return m.CreatedAt()
  26147. case msg.FieldUpdatedAt:
  26148. return m.UpdatedAt()
  26149. case msg.FieldDeletedAt:
  26150. return m.DeletedAt()
  26151. case msg.FieldStatus:
  26152. return m.Status()
  26153. case msg.FieldFromwxid:
  26154. return m.Fromwxid()
  26155. case msg.FieldToid:
  26156. return m.Toid()
  26157. case msg.FieldMsgtype:
  26158. return m.Msgtype()
  26159. case msg.FieldMsg:
  26160. return m.Msg()
  26161. case msg.FieldBatchNo:
  26162. return m.BatchNo()
  26163. case msg.FieldCc:
  26164. return m.Cc()
  26165. case msg.FieldPhone:
  26166. return m.Phone()
  26167. }
  26168. return nil, false
  26169. }
  26170. // OldField returns the old value of the field from the database. An error is
  26171. // returned if the mutation operation is not UpdateOne, or the query to the
  26172. // database failed.
  26173. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26174. switch name {
  26175. case msg.FieldCreatedAt:
  26176. return m.OldCreatedAt(ctx)
  26177. case msg.FieldUpdatedAt:
  26178. return m.OldUpdatedAt(ctx)
  26179. case msg.FieldDeletedAt:
  26180. return m.OldDeletedAt(ctx)
  26181. case msg.FieldStatus:
  26182. return m.OldStatus(ctx)
  26183. case msg.FieldFromwxid:
  26184. return m.OldFromwxid(ctx)
  26185. case msg.FieldToid:
  26186. return m.OldToid(ctx)
  26187. case msg.FieldMsgtype:
  26188. return m.OldMsgtype(ctx)
  26189. case msg.FieldMsg:
  26190. return m.OldMsg(ctx)
  26191. case msg.FieldBatchNo:
  26192. return m.OldBatchNo(ctx)
  26193. case msg.FieldCc:
  26194. return m.OldCc(ctx)
  26195. case msg.FieldPhone:
  26196. return m.OldPhone(ctx)
  26197. }
  26198. return nil, fmt.Errorf("unknown Msg field %s", name)
  26199. }
  26200. // SetField sets the value of a field with the given name. It returns an error if
  26201. // the field is not defined in the schema, or if the type mismatched the field
  26202. // type.
  26203. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  26204. switch name {
  26205. case msg.FieldCreatedAt:
  26206. v, ok := value.(time.Time)
  26207. if !ok {
  26208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26209. }
  26210. m.SetCreatedAt(v)
  26211. return nil
  26212. case msg.FieldUpdatedAt:
  26213. v, ok := value.(time.Time)
  26214. if !ok {
  26215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26216. }
  26217. m.SetUpdatedAt(v)
  26218. return nil
  26219. case msg.FieldDeletedAt:
  26220. v, ok := value.(time.Time)
  26221. if !ok {
  26222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26223. }
  26224. m.SetDeletedAt(v)
  26225. return nil
  26226. case msg.FieldStatus:
  26227. v, ok := value.(uint8)
  26228. if !ok {
  26229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26230. }
  26231. m.SetStatus(v)
  26232. return nil
  26233. case msg.FieldFromwxid:
  26234. v, ok := value.(string)
  26235. if !ok {
  26236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26237. }
  26238. m.SetFromwxid(v)
  26239. return nil
  26240. case msg.FieldToid:
  26241. v, ok := value.(string)
  26242. if !ok {
  26243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26244. }
  26245. m.SetToid(v)
  26246. return nil
  26247. case msg.FieldMsgtype:
  26248. v, ok := value.(int32)
  26249. if !ok {
  26250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26251. }
  26252. m.SetMsgtype(v)
  26253. return nil
  26254. case msg.FieldMsg:
  26255. v, ok := value.(string)
  26256. if !ok {
  26257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26258. }
  26259. m.SetMsg(v)
  26260. return nil
  26261. case msg.FieldBatchNo:
  26262. v, ok := value.(string)
  26263. if !ok {
  26264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26265. }
  26266. m.SetBatchNo(v)
  26267. return nil
  26268. case msg.FieldCc:
  26269. v, ok := value.(string)
  26270. if !ok {
  26271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26272. }
  26273. m.SetCc(v)
  26274. return nil
  26275. case msg.FieldPhone:
  26276. v, ok := value.(string)
  26277. if !ok {
  26278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26279. }
  26280. m.SetPhone(v)
  26281. return nil
  26282. }
  26283. return fmt.Errorf("unknown Msg field %s", name)
  26284. }
  26285. // AddedFields returns all numeric fields that were incremented/decremented during
  26286. // this mutation.
  26287. func (m *MsgMutation) AddedFields() []string {
  26288. var fields []string
  26289. if m.addstatus != nil {
  26290. fields = append(fields, msg.FieldStatus)
  26291. }
  26292. if m.addmsgtype != nil {
  26293. fields = append(fields, msg.FieldMsgtype)
  26294. }
  26295. return fields
  26296. }
  26297. // AddedField returns the numeric value that was incremented/decremented on a field
  26298. // with the given name. The second boolean return value indicates that this field
  26299. // was not set, or was not defined in the schema.
  26300. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  26301. switch name {
  26302. case msg.FieldStatus:
  26303. return m.AddedStatus()
  26304. case msg.FieldMsgtype:
  26305. return m.AddedMsgtype()
  26306. }
  26307. return nil, false
  26308. }
  26309. // AddField adds the value to the field with the given name. It returns an error if
  26310. // the field is not defined in the schema, or if the type mismatched the field
  26311. // type.
  26312. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  26313. switch name {
  26314. case msg.FieldStatus:
  26315. v, ok := value.(int8)
  26316. if !ok {
  26317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26318. }
  26319. m.AddStatus(v)
  26320. return nil
  26321. case msg.FieldMsgtype:
  26322. v, ok := value.(int32)
  26323. if !ok {
  26324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26325. }
  26326. m.AddMsgtype(v)
  26327. return nil
  26328. }
  26329. return fmt.Errorf("unknown Msg numeric field %s", name)
  26330. }
  26331. // ClearedFields returns all nullable fields that were cleared during this
  26332. // mutation.
  26333. func (m *MsgMutation) ClearedFields() []string {
  26334. var fields []string
  26335. if m.FieldCleared(msg.FieldDeletedAt) {
  26336. fields = append(fields, msg.FieldDeletedAt)
  26337. }
  26338. if m.FieldCleared(msg.FieldStatus) {
  26339. fields = append(fields, msg.FieldStatus)
  26340. }
  26341. if m.FieldCleared(msg.FieldFromwxid) {
  26342. fields = append(fields, msg.FieldFromwxid)
  26343. }
  26344. if m.FieldCleared(msg.FieldToid) {
  26345. fields = append(fields, msg.FieldToid)
  26346. }
  26347. if m.FieldCleared(msg.FieldMsgtype) {
  26348. fields = append(fields, msg.FieldMsgtype)
  26349. }
  26350. if m.FieldCleared(msg.FieldMsg) {
  26351. fields = append(fields, msg.FieldMsg)
  26352. }
  26353. if m.FieldCleared(msg.FieldBatchNo) {
  26354. fields = append(fields, msg.FieldBatchNo)
  26355. }
  26356. return fields
  26357. }
  26358. // FieldCleared returns a boolean indicating if a field with the given name was
  26359. // cleared in this mutation.
  26360. func (m *MsgMutation) FieldCleared(name string) bool {
  26361. _, ok := m.clearedFields[name]
  26362. return ok
  26363. }
  26364. // ClearField clears the value of the field with the given name. It returns an
  26365. // error if the field is not defined in the schema.
  26366. func (m *MsgMutation) ClearField(name string) error {
  26367. switch name {
  26368. case msg.FieldDeletedAt:
  26369. m.ClearDeletedAt()
  26370. return nil
  26371. case msg.FieldStatus:
  26372. m.ClearStatus()
  26373. return nil
  26374. case msg.FieldFromwxid:
  26375. m.ClearFromwxid()
  26376. return nil
  26377. case msg.FieldToid:
  26378. m.ClearToid()
  26379. return nil
  26380. case msg.FieldMsgtype:
  26381. m.ClearMsgtype()
  26382. return nil
  26383. case msg.FieldMsg:
  26384. m.ClearMsg()
  26385. return nil
  26386. case msg.FieldBatchNo:
  26387. m.ClearBatchNo()
  26388. return nil
  26389. }
  26390. return fmt.Errorf("unknown Msg nullable field %s", name)
  26391. }
  26392. // ResetField resets all changes in the mutation for the field with the given name.
  26393. // It returns an error if the field is not defined in the schema.
  26394. func (m *MsgMutation) ResetField(name string) error {
  26395. switch name {
  26396. case msg.FieldCreatedAt:
  26397. m.ResetCreatedAt()
  26398. return nil
  26399. case msg.FieldUpdatedAt:
  26400. m.ResetUpdatedAt()
  26401. return nil
  26402. case msg.FieldDeletedAt:
  26403. m.ResetDeletedAt()
  26404. return nil
  26405. case msg.FieldStatus:
  26406. m.ResetStatus()
  26407. return nil
  26408. case msg.FieldFromwxid:
  26409. m.ResetFromwxid()
  26410. return nil
  26411. case msg.FieldToid:
  26412. m.ResetToid()
  26413. return nil
  26414. case msg.FieldMsgtype:
  26415. m.ResetMsgtype()
  26416. return nil
  26417. case msg.FieldMsg:
  26418. m.ResetMsg()
  26419. return nil
  26420. case msg.FieldBatchNo:
  26421. m.ResetBatchNo()
  26422. return nil
  26423. case msg.FieldCc:
  26424. m.ResetCc()
  26425. return nil
  26426. case msg.FieldPhone:
  26427. m.ResetPhone()
  26428. return nil
  26429. }
  26430. return fmt.Errorf("unknown Msg field %s", name)
  26431. }
  26432. // AddedEdges returns all edge names that were set/added in this mutation.
  26433. func (m *MsgMutation) AddedEdges() []string {
  26434. edges := make([]string, 0, 0)
  26435. return edges
  26436. }
  26437. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26438. // name in this mutation.
  26439. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  26440. return nil
  26441. }
  26442. // RemovedEdges returns all edge names that were removed in this mutation.
  26443. func (m *MsgMutation) RemovedEdges() []string {
  26444. edges := make([]string, 0, 0)
  26445. return edges
  26446. }
  26447. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26448. // the given name in this mutation.
  26449. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  26450. return nil
  26451. }
  26452. // ClearedEdges returns all edge names that were cleared in this mutation.
  26453. func (m *MsgMutation) ClearedEdges() []string {
  26454. edges := make([]string, 0, 0)
  26455. return edges
  26456. }
  26457. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26458. // was cleared in this mutation.
  26459. func (m *MsgMutation) EdgeCleared(name string) bool {
  26460. return false
  26461. }
  26462. // ClearEdge clears the value of the edge with the given name. It returns an error
  26463. // if that edge is not defined in the schema.
  26464. func (m *MsgMutation) ClearEdge(name string) error {
  26465. return fmt.Errorf("unknown Msg unique edge %s", name)
  26466. }
  26467. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26468. // It returns an error if the edge is not defined in the schema.
  26469. func (m *MsgMutation) ResetEdge(name string) error {
  26470. return fmt.Errorf("unknown Msg edge %s", name)
  26471. }
  26472. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  26473. type PayRechargeMutation struct {
  26474. config
  26475. op Op
  26476. typ string
  26477. id *uint64
  26478. created_at *time.Time
  26479. updated_at *time.Time
  26480. deleted_at *time.Time
  26481. user_id *string
  26482. number *float32
  26483. addnumber *float32
  26484. status *int
  26485. addstatus *int
  26486. money *float32
  26487. addmoney *float32
  26488. out_trade_no *string
  26489. organization_id *uint64
  26490. addorganization_id *int64
  26491. clearedFields map[string]struct{}
  26492. done bool
  26493. oldValue func(context.Context) (*PayRecharge, error)
  26494. predicates []predicate.PayRecharge
  26495. }
  26496. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  26497. // payrechargeOption allows management of the mutation configuration using functional options.
  26498. type payrechargeOption func(*PayRechargeMutation)
  26499. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  26500. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  26501. m := &PayRechargeMutation{
  26502. config: c,
  26503. op: op,
  26504. typ: TypePayRecharge,
  26505. clearedFields: make(map[string]struct{}),
  26506. }
  26507. for _, opt := range opts {
  26508. opt(m)
  26509. }
  26510. return m
  26511. }
  26512. // withPayRechargeID sets the ID field of the mutation.
  26513. func withPayRechargeID(id uint64) payrechargeOption {
  26514. return func(m *PayRechargeMutation) {
  26515. var (
  26516. err error
  26517. once sync.Once
  26518. value *PayRecharge
  26519. )
  26520. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  26521. once.Do(func() {
  26522. if m.done {
  26523. err = errors.New("querying old values post mutation is not allowed")
  26524. } else {
  26525. value, err = m.Client().PayRecharge.Get(ctx, id)
  26526. }
  26527. })
  26528. return value, err
  26529. }
  26530. m.id = &id
  26531. }
  26532. }
  26533. // withPayRecharge sets the old PayRecharge of the mutation.
  26534. func withPayRecharge(node *PayRecharge) payrechargeOption {
  26535. return func(m *PayRechargeMutation) {
  26536. m.oldValue = func(context.Context) (*PayRecharge, error) {
  26537. return node, nil
  26538. }
  26539. m.id = &node.ID
  26540. }
  26541. }
  26542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26543. // executed in a transaction (ent.Tx), a transactional client is returned.
  26544. func (m PayRechargeMutation) Client() *Client {
  26545. client := &Client{config: m.config}
  26546. client.init()
  26547. return client
  26548. }
  26549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26550. // it returns an error otherwise.
  26551. func (m PayRechargeMutation) Tx() (*Tx, error) {
  26552. if _, ok := m.driver.(*txDriver); !ok {
  26553. return nil, errors.New("ent: mutation is not running in a transaction")
  26554. }
  26555. tx := &Tx{config: m.config}
  26556. tx.init()
  26557. return tx, nil
  26558. }
  26559. // SetID sets the value of the id field. Note that this
  26560. // operation is only accepted on creation of PayRecharge entities.
  26561. func (m *PayRechargeMutation) SetID(id uint64) {
  26562. m.id = &id
  26563. }
  26564. // ID returns the ID value in the mutation. Note that the ID is only available
  26565. // if it was provided to the builder or after it was returned from the database.
  26566. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  26567. if m.id == nil {
  26568. return
  26569. }
  26570. return *m.id, true
  26571. }
  26572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26573. // That means, if the mutation is applied within a transaction with an isolation level such
  26574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26575. // or updated by the mutation.
  26576. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26577. switch {
  26578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26579. id, exists := m.ID()
  26580. if exists {
  26581. return []uint64{id}, nil
  26582. }
  26583. fallthrough
  26584. case m.op.Is(OpUpdate | OpDelete):
  26585. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  26586. default:
  26587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26588. }
  26589. }
  26590. // SetCreatedAt sets the "created_at" field.
  26591. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  26592. m.created_at = &t
  26593. }
  26594. // CreatedAt returns the value of the "created_at" field in the mutation.
  26595. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  26596. v := m.created_at
  26597. if v == nil {
  26598. return
  26599. }
  26600. return *v, true
  26601. }
  26602. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  26603. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26605. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26606. if !m.op.Is(OpUpdateOne) {
  26607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26608. }
  26609. if m.id == nil || m.oldValue == nil {
  26610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26611. }
  26612. oldValue, err := m.oldValue(ctx)
  26613. if err != nil {
  26614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26615. }
  26616. return oldValue.CreatedAt, nil
  26617. }
  26618. // ResetCreatedAt resets all changes to the "created_at" field.
  26619. func (m *PayRechargeMutation) ResetCreatedAt() {
  26620. m.created_at = nil
  26621. }
  26622. // SetUpdatedAt sets the "updated_at" field.
  26623. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  26624. m.updated_at = &t
  26625. }
  26626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26627. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  26628. v := m.updated_at
  26629. if v == nil {
  26630. return
  26631. }
  26632. return *v, true
  26633. }
  26634. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  26635. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26637. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26638. if !m.op.Is(OpUpdateOne) {
  26639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26640. }
  26641. if m.id == nil || m.oldValue == nil {
  26642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26643. }
  26644. oldValue, err := m.oldValue(ctx)
  26645. if err != nil {
  26646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26647. }
  26648. return oldValue.UpdatedAt, nil
  26649. }
  26650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26651. func (m *PayRechargeMutation) ResetUpdatedAt() {
  26652. m.updated_at = nil
  26653. }
  26654. // SetDeletedAt sets the "deleted_at" field.
  26655. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  26656. m.deleted_at = &t
  26657. }
  26658. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26659. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  26660. v := m.deleted_at
  26661. if v == nil {
  26662. return
  26663. }
  26664. return *v, true
  26665. }
  26666. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  26667. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26669. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26670. if !m.op.Is(OpUpdateOne) {
  26671. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26672. }
  26673. if m.id == nil || m.oldValue == nil {
  26674. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26675. }
  26676. oldValue, err := m.oldValue(ctx)
  26677. if err != nil {
  26678. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26679. }
  26680. return oldValue.DeletedAt, nil
  26681. }
  26682. // ClearDeletedAt clears the value of the "deleted_at" field.
  26683. func (m *PayRechargeMutation) ClearDeletedAt() {
  26684. m.deleted_at = nil
  26685. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  26686. }
  26687. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26688. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  26689. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  26690. return ok
  26691. }
  26692. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26693. func (m *PayRechargeMutation) ResetDeletedAt() {
  26694. m.deleted_at = nil
  26695. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  26696. }
  26697. // SetUserID sets the "user_id" field.
  26698. func (m *PayRechargeMutation) SetUserID(s string) {
  26699. m.user_id = &s
  26700. }
  26701. // UserID returns the value of the "user_id" field in the mutation.
  26702. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  26703. v := m.user_id
  26704. if v == nil {
  26705. return
  26706. }
  26707. return *v, true
  26708. }
  26709. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  26710. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26712. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  26713. if !m.op.Is(OpUpdateOne) {
  26714. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26715. }
  26716. if m.id == nil || m.oldValue == nil {
  26717. return v, errors.New("OldUserID requires an ID field in the mutation")
  26718. }
  26719. oldValue, err := m.oldValue(ctx)
  26720. if err != nil {
  26721. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26722. }
  26723. return oldValue.UserID, nil
  26724. }
  26725. // ResetUserID resets all changes to the "user_id" field.
  26726. func (m *PayRechargeMutation) ResetUserID() {
  26727. m.user_id = nil
  26728. }
  26729. // SetNumber sets the "number" field.
  26730. func (m *PayRechargeMutation) SetNumber(f float32) {
  26731. m.number = &f
  26732. m.addnumber = nil
  26733. }
  26734. // Number returns the value of the "number" field in the mutation.
  26735. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  26736. v := m.number
  26737. if v == nil {
  26738. return
  26739. }
  26740. return *v, true
  26741. }
  26742. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  26743. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26745. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  26746. if !m.op.Is(OpUpdateOne) {
  26747. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  26748. }
  26749. if m.id == nil || m.oldValue == nil {
  26750. return v, errors.New("OldNumber requires an ID field in the mutation")
  26751. }
  26752. oldValue, err := m.oldValue(ctx)
  26753. if err != nil {
  26754. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  26755. }
  26756. return oldValue.Number, nil
  26757. }
  26758. // AddNumber adds f to the "number" field.
  26759. func (m *PayRechargeMutation) AddNumber(f float32) {
  26760. if m.addnumber != nil {
  26761. *m.addnumber += f
  26762. } else {
  26763. m.addnumber = &f
  26764. }
  26765. }
  26766. // AddedNumber returns the value that was added to the "number" field in this mutation.
  26767. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  26768. v := m.addnumber
  26769. if v == nil {
  26770. return
  26771. }
  26772. return *v, true
  26773. }
  26774. // ResetNumber resets all changes to the "number" field.
  26775. func (m *PayRechargeMutation) ResetNumber() {
  26776. m.number = nil
  26777. m.addnumber = nil
  26778. }
  26779. // SetStatus sets the "status" field.
  26780. func (m *PayRechargeMutation) SetStatus(i int) {
  26781. m.status = &i
  26782. m.addstatus = nil
  26783. }
  26784. // Status returns the value of the "status" field in the mutation.
  26785. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  26786. v := m.status
  26787. if v == nil {
  26788. return
  26789. }
  26790. return *v, true
  26791. }
  26792. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  26793. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26795. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  26796. if !m.op.Is(OpUpdateOne) {
  26797. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26798. }
  26799. if m.id == nil || m.oldValue == nil {
  26800. return v, errors.New("OldStatus requires an ID field in the mutation")
  26801. }
  26802. oldValue, err := m.oldValue(ctx)
  26803. if err != nil {
  26804. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26805. }
  26806. return oldValue.Status, nil
  26807. }
  26808. // AddStatus adds i to the "status" field.
  26809. func (m *PayRechargeMutation) AddStatus(i int) {
  26810. if m.addstatus != nil {
  26811. *m.addstatus += i
  26812. } else {
  26813. m.addstatus = &i
  26814. }
  26815. }
  26816. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26817. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  26818. v := m.addstatus
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // ClearStatus clears the value of the "status" field.
  26825. func (m *PayRechargeMutation) ClearStatus() {
  26826. m.status = nil
  26827. m.addstatus = nil
  26828. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  26829. }
  26830. // StatusCleared returns if the "status" field was cleared in this mutation.
  26831. func (m *PayRechargeMutation) StatusCleared() bool {
  26832. _, ok := m.clearedFields[payrecharge.FieldStatus]
  26833. return ok
  26834. }
  26835. // ResetStatus resets all changes to the "status" field.
  26836. func (m *PayRechargeMutation) ResetStatus() {
  26837. m.status = nil
  26838. m.addstatus = nil
  26839. delete(m.clearedFields, payrecharge.FieldStatus)
  26840. }
  26841. // SetMoney sets the "money" field.
  26842. func (m *PayRechargeMutation) SetMoney(f float32) {
  26843. m.money = &f
  26844. m.addmoney = nil
  26845. }
  26846. // Money returns the value of the "money" field in the mutation.
  26847. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  26848. v := m.money
  26849. if v == nil {
  26850. return
  26851. }
  26852. return *v, true
  26853. }
  26854. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  26855. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26857. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  26858. if !m.op.Is(OpUpdateOne) {
  26859. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  26860. }
  26861. if m.id == nil || m.oldValue == nil {
  26862. return v, errors.New("OldMoney requires an ID field in the mutation")
  26863. }
  26864. oldValue, err := m.oldValue(ctx)
  26865. if err != nil {
  26866. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  26867. }
  26868. return oldValue.Money, nil
  26869. }
  26870. // AddMoney adds f to the "money" field.
  26871. func (m *PayRechargeMutation) AddMoney(f float32) {
  26872. if m.addmoney != nil {
  26873. *m.addmoney += f
  26874. } else {
  26875. m.addmoney = &f
  26876. }
  26877. }
  26878. // AddedMoney returns the value that was added to the "money" field in this mutation.
  26879. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  26880. v := m.addmoney
  26881. if v == nil {
  26882. return
  26883. }
  26884. return *v, true
  26885. }
  26886. // ClearMoney clears the value of the "money" field.
  26887. func (m *PayRechargeMutation) ClearMoney() {
  26888. m.money = nil
  26889. m.addmoney = nil
  26890. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  26891. }
  26892. // MoneyCleared returns if the "money" field was cleared in this mutation.
  26893. func (m *PayRechargeMutation) MoneyCleared() bool {
  26894. _, ok := m.clearedFields[payrecharge.FieldMoney]
  26895. return ok
  26896. }
  26897. // ResetMoney resets all changes to the "money" field.
  26898. func (m *PayRechargeMutation) ResetMoney() {
  26899. m.money = nil
  26900. m.addmoney = nil
  26901. delete(m.clearedFields, payrecharge.FieldMoney)
  26902. }
  26903. // SetOutTradeNo sets the "out_trade_no" field.
  26904. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  26905. m.out_trade_no = &s
  26906. }
  26907. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  26908. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  26909. v := m.out_trade_no
  26910. if v == nil {
  26911. return
  26912. }
  26913. return *v, true
  26914. }
  26915. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  26916. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26918. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  26919. if !m.op.Is(OpUpdateOne) {
  26920. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  26921. }
  26922. if m.id == nil || m.oldValue == nil {
  26923. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  26924. }
  26925. oldValue, err := m.oldValue(ctx)
  26926. if err != nil {
  26927. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  26928. }
  26929. return oldValue.OutTradeNo, nil
  26930. }
  26931. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  26932. func (m *PayRechargeMutation) ClearOutTradeNo() {
  26933. m.out_trade_no = nil
  26934. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  26935. }
  26936. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  26937. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  26938. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  26939. return ok
  26940. }
  26941. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  26942. func (m *PayRechargeMutation) ResetOutTradeNo() {
  26943. m.out_trade_no = nil
  26944. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  26945. }
  26946. // SetOrganizationID sets the "organization_id" field.
  26947. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  26948. m.organization_id = &u
  26949. m.addorganization_id = nil
  26950. }
  26951. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26952. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  26953. v := m.organization_id
  26954. if v == nil {
  26955. return
  26956. }
  26957. return *v, true
  26958. }
  26959. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  26960. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26962. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26963. if !m.op.Is(OpUpdateOne) {
  26964. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26965. }
  26966. if m.id == nil || m.oldValue == nil {
  26967. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26968. }
  26969. oldValue, err := m.oldValue(ctx)
  26970. if err != nil {
  26971. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26972. }
  26973. return oldValue.OrganizationID, nil
  26974. }
  26975. // AddOrganizationID adds u to the "organization_id" field.
  26976. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  26977. if m.addorganization_id != nil {
  26978. *m.addorganization_id += u
  26979. } else {
  26980. m.addorganization_id = &u
  26981. }
  26982. }
  26983. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26984. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  26985. v := m.addorganization_id
  26986. if v == nil {
  26987. return
  26988. }
  26989. return *v, true
  26990. }
  26991. // ResetOrganizationID resets all changes to the "organization_id" field.
  26992. func (m *PayRechargeMutation) ResetOrganizationID() {
  26993. m.organization_id = nil
  26994. m.addorganization_id = nil
  26995. }
  26996. // Where appends a list predicates to the PayRechargeMutation builder.
  26997. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  26998. m.predicates = append(m.predicates, ps...)
  26999. }
  27000. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  27001. // users can use type-assertion to append predicates that do not depend on any generated package.
  27002. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  27003. p := make([]predicate.PayRecharge, len(ps))
  27004. for i := range ps {
  27005. p[i] = ps[i]
  27006. }
  27007. m.Where(p...)
  27008. }
  27009. // Op returns the operation name.
  27010. func (m *PayRechargeMutation) Op() Op {
  27011. return m.op
  27012. }
  27013. // SetOp allows setting the mutation operation.
  27014. func (m *PayRechargeMutation) SetOp(op Op) {
  27015. m.op = op
  27016. }
  27017. // Type returns the node type of this mutation (PayRecharge).
  27018. func (m *PayRechargeMutation) Type() string {
  27019. return m.typ
  27020. }
  27021. // Fields returns all fields that were changed during this mutation. Note that in
  27022. // order to get all numeric fields that were incremented/decremented, call
  27023. // AddedFields().
  27024. func (m *PayRechargeMutation) Fields() []string {
  27025. fields := make([]string, 0, 9)
  27026. if m.created_at != nil {
  27027. fields = append(fields, payrecharge.FieldCreatedAt)
  27028. }
  27029. if m.updated_at != nil {
  27030. fields = append(fields, payrecharge.FieldUpdatedAt)
  27031. }
  27032. if m.deleted_at != nil {
  27033. fields = append(fields, payrecharge.FieldDeletedAt)
  27034. }
  27035. if m.user_id != nil {
  27036. fields = append(fields, payrecharge.FieldUserID)
  27037. }
  27038. if m.number != nil {
  27039. fields = append(fields, payrecharge.FieldNumber)
  27040. }
  27041. if m.status != nil {
  27042. fields = append(fields, payrecharge.FieldStatus)
  27043. }
  27044. if m.money != nil {
  27045. fields = append(fields, payrecharge.FieldMoney)
  27046. }
  27047. if m.out_trade_no != nil {
  27048. fields = append(fields, payrecharge.FieldOutTradeNo)
  27049. }
  27050. if m.organization_id != nil {
  27051. fields = append(fields, payrecharge.FieldOrganizationID)
  27052. }
  27053. return fields
  27054. }
  27055. // Field returns the value of a field with the given name. The second boolean
  27056. // return value indicates that this field was not set, or was not defined in the
  27057. // schema.
  27058. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  27059. switch name {
  27060. case payrecharge.FieldCreatedAt:
  27061. return m.CreatedAt()
  27062. case payrecharge.FieldUpdatedAt:
  27063. return m.UpdatedAt()
  27064. case payrecharge.FieldDeletedAt:
  27065. return m.DeletedAt()
  27066. case payrecharge.FieldUserID:
  27067. return m.UserID()
  27068. case payrecharge.FieldNumber:
  27069. return m.Number()
  27070. case payrecharge.FieldStatus:
  27071. return m.Status()
  27072. case payrecharge.FieldMoney:
  27073. return m.Money()
  27074. case payrecharge.FieldOutTradeNo:
  27075. return m.OutTradeNo()
  27076. case payrecharge.FieldOrganizationID:
  27077. return m.OrganizationID()
  27078. }
  27079. return nil, false
  27080. }
  27081. // OldField returns the old value of the field from the database. An error is
  27082. // returned if the mutation operation is not UpdateOne, or the query to the
  27083. // database failed.
  27084. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27085. switch name {
  27086. case payrecharge.FieldCreatedAt:
  27087. return m.OldCreatedAt(ctx)
  27088. case payrecharge.FieldUpdatedAt:
  27089. return m.OldUpdatedAt(ctx)
  27090. case payrecharge.FieldDeletedAt:
  27091. return m.OldDeletedAt(ctx)
  27092. case payrecharge.FieldUserID:
  27093. return m.OldUserID(ctx)
  27094. case payrecharge.FieldNumber:
  27095. return m.OldNumber(ctx)
  27096. case payrecharge.FieldStatus:
  27097. return m.OldStatus(ctx)
  27098. case payrecharge.FieldMoney:
  27099. return m.OldMoney(ctx)
  27100. case payrecharge.FieldOutTradeNo:
  27101. return m.OldOutTradeNo(ctx)
  27102. case payrecharge.FieldOrganizationID:
  27103. return m.OldOrganizationID(ctx)
  27104. }
  27105. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  27106. }
  27107. // SetField sets the value of a field with the given name. It returns an error if
  27108. // the field is not defined in the schema, or if the type mismatched the field
  27109. // type.
  27110. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  27111. switch name {
  27112. case payrecharge.FieldCreatedAt:
  27113. v, ok := value.(time.Time)
  27114. if !ok {
  27115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27116. }
  27117. m.SetCreatedAt(v)
  27118. return nil
  27119. case payrecharge.FieldUpdatedAt:
  27120. v, ok := value.(time.Time)
  27121. if !ok {
  27122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27123. }
  27124. m.SetUpdatedAt(v)
  27125. return nil
  27126. case payrecharge.FieldDeletedAt:
  27127. v, ok := value.(time.Time)
  27128. if !ok {
  27129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27130. }
  27131. m.SetDeletedAt(v)
  27132. return nil
  27133. case payrecharge.FieldUserID:
  27134. v, ok := value.(string)
  27135. if !ok {
  27136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27137. }
  27138. m.SetUserID(v)
  27139. return nil
  27140. case payrecharge.FieldNumber:
  27141. v, ok := value.(float32)
  27142. if !ok {
  27143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27144. }
  27145. m.SetNumber(v)
  27146. return nil
  27147. case payrecharge.FieldStatus:
  27148. v, ok := value.(int)
  27149. if !ok {
  27150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27151. }
  27152. m.SetStatus(v)
  27153. return nil
  27154. case payrecharge.FieldMoney:
  27155. v, ok := value.(float32)
  27156. if !ok {
  27157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27158. }
  27159. m.SetMoney(v)
  27160. return nil
  27161. case payrecharge.FieldOutTradeNo:
  27162. v, ok := value.(string)
  27163. if !ok {
  27164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27165. }
  27166. m.SetOutTradeNo(v)
  27167. return nil
  27168. case payrecharge.FieldOrganizationID:
  27169. v, ok := value.(uint64)
  27170. if !ok {
  27171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27172. }
  27173. m.SetOrganizationID(v)
  27174. return nil
  27175. }
  27176. return fmt.Errorf("unknown PayRecharge field %s", name)
  27177. }
  27178. // AddedFields returns all numeric fields that were incremented/decremented during
  27179. // this mutation.
  27180. func (m *PayRechargeMutation) AddedFields() []string {
  27181. var fields []string
  27182. if m.addnumber != nil {
  27183. fields = append(fields, payrecharge.FieldNumber)
  27184. }
  27185. if m.addstatus != nil {
  27186. fields = append(fields, payrecharge.FieldStatus)
  27187. }
  27188. if m.addmoney != nil {
  27189. fields = append(fields, payrecharge.FieldMoney)
  27190. }
  27191. if m.addorganization_id != nil {
  27192. fields = append(fields, payrecharge.FieldOrganizationID)
  27193. }
  27194. return fields
  27195. }
  27196. // AddedField returns the numeric value that was incremented/decremented on a field
  27197. // with the given name. The second boolean return value indicates that this field
  27198. // was not set, or was not defined in the schema.
  27199. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  27200. switch name {
  27201. case payrecharge.FieldNumber:
  27202. return m.AddedNumber()
  27203. case payrecharge.FieldStatus:
  27204. return m.AddedStatus()
  27205. case payrecharge.FieldMoney:
  27206. return m.AddedMoney()
  27207. case payrecharge.FieldOrganizationID:
  27208. return m.AddedOrganizationID()
  27209. }
  27210. return nil, false
  27211. }
  27212. // AddField adds the value to the field with the given name. It returns an error if
  27213. // the field is not defined in the schema, or if the type mismatched the field
  27214. // type.
  27215. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  27216. switch name {
  27217. case payrecharge.FieldNumber:
  27218. v, ok := value.(float32)
  27219. if !ok {
  27220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27221. }
  27222. m.AddNumber(v)
  27223. return nil
  27224. case payrecharge.FieldStatus:
  27225. v, ok := value.(int)
  27226. if !ok {
  27227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27228. }
  27229. m.AddStatus(v)
  27230. return nil
  27231. case payrecharge.FieldMoney:
  27232. v, ok := value.(float32)
  27233. if !ok {
  27234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27235. }
  27236. m.AddMoney(v)
  27237. return nil
  27238. case payrecharge.FieldOrganizationID:
  27239. v, ok := value.(int64)
  27240. if !ok {
  27241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27242. }
  27243. m.AddOrganizationID(v)
  27244. return nil
  27245. }
  27246. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  27247. }
  27248. // ClearedFields returns all nullable fields that were cleared during this
  27249. // mutation.
  27250. func (m *PayRechargeMutation) ClearedFields() []string {
  27251. var fields []string
  27252. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  27253. fields = append(fields, payrecharge.FieldDeletedAt)
  27254. }
  27255. if m.FieldCleared(payrecharge.FieldStatus) {
  27256. fields = append(fields, payrecharge.FieldStatus)
  27257. }
  27258. if m.FieldCleared(payrecharge.FieldMoney) {
  27259. fields = append(fields, payrecharge.FieldMoney)
  27260. }
  27261. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  27262. fields = append(fields, payrecharge.FieldOutTradeNo)
  27263. }
  27264. return fields
  27265. }
  27266. // FieldCleared returns a boolean indicating if a field with the given name was
  27267. // cleared in this mutation.
  27268. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  27269. _, ok := m.clearedFields[name]
  27270. return ok
  27271. }
  27272. // ClearField clears the value of the field with the given name. It returns an
  27273. // error if the field is not defined in the schema.
  27274. func (m *PayRechargeMutation) ClearField(name string) error {
  27275. switch name {
  27276. case payrecharge.FieldDeletedAt:
  27277. m.ClearDeletedAt()
  27278. return nil
  27279. case payrecharge.FieldStatus:
  27280. m.ClearStatus()
  27281. return nil
  27282. case payrecharge.FieldMoney:
  27283. m.ClearMoney()
  27284. return nil
  27285. case payrecharge.FieldOutTradeNo:
  27286. m.ClearOutTradeNo()
  27287. return nil
  27288. }
  27289. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  27290. }
  27291. // ResetField resets all changes in the mutation for the field with the given name.
  27292. // It returns an error if the field is not defined in the schema.
  27293. func (m *PayRechargeMutation) ResetField(name string) error {
  27294. switch name {
  27295. case payrecharge.FieldCreatedAt:
  27296. m.ResetCreatedAt()
  27297. return nil
  27298. case payrecharge.FieldUpdatedAt:
  27299. m.ResetUpdatedAt()
  27300. return nil
  27301. case payrecharge.FieldDeletedAt:
  27302. m.ResetDeletedAt()
  27303. return nil
  27304. case payrecharge.FieldUserID:
  27305. m.ResetUserID()
  27306. return nil
  27307. case payrecharge.FieldNumber:
  27308. m.ResetNumber()
  27309. return nil
  27310. case payrecharge.FieldStatus:
  27311. m.ResetStatus()
  27312. return nil
  27313. case payrecharge.FieldMoney:
  27314. m.ResetMoney()
  27315. return nil
  27316. case payrecharge.FieldOutTradeNo:
  27317. m.ResetOutTradeNo()
  27318. return nil
  27319. case payrecharge.FieldOrganizationID:
  27320. m.ResetOrganizationID()
  27321. return nil
  27322. }
  27323. return fmt.Errorf("unknown PayRecharge field %s", name)
  27324. }
  27325. // AddedEdges returns all edge names that were set/added in this mutation.
  27326. func (m *PayRechargeMutation) AddedEdges() []string {
  27327. edges := make([]string, 0, 0)
  27328. return edges
  27329. }
  27330. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27331. // name in this mutation.
  27332. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  27333. return nil
  27334. }
  27335. // RemovedEdges returns all edge names that were removed in this mutation.
  27336. func (m *PayRechargeMutation) RemovedEdges() []string {
  27337. edges := make([]string, 0, 0)
  27338. return edges
  27339. }
  27340. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27341. // the given name in this mutation.
  27342. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  27343. return nil
  27344. }
  27345. // ClearedEdges returns all edge names that were cleared in this mutation.
  27346. func (m *PayRechargeMutation) ClearedEdges() []string {
  27347. edges := make([]string, 0, 0)
  27348. return edges
  27349. }
  27350. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27351. // was cleared in this mutation.
  27352. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  27353. return false
  27354. }
  27355. // ClearEdge clears the value of the edge with the given name. It returns an error
  27356. // if that edge is not defined in the schema.
  27357. func (m *PayRechargeMutation) ClearEdge(name string) error {
  27358. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  27359. }
  27360. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27361. // It returns an error if the edge is not defined in the schema.
  27362. func (m *PayRechargeMutation) ResetEdge(name string) error {
  27363. return fmt.Errorf("unknown PayRecharge edge %s", name)
  27364. }
  27365. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  27366. type ServerMutation struct {
  27367. config
  27368. op Op
  27369. typ string
  27370. id *uint64
  27371. created_at *time.Time
  27372. updated_at *time.Time
  27373. status *uint8
  27374. addstatus *int8
  27375. deleted_at *time.Time
  27376. name *string
  27377. public_ip *string
  27378. private_ip *string
  27379. admin_port *string
  27380. clearedFields map[string]struct{}
  27381. wxs map[uint64]struct{}
  27382. removedwxs map[uint64]struct{}
  27383. clearedwxs bool
  27384. done bool
  27385. oldValue func(context.Context) (*Server, error)
  27386. predicates []predicate.Server
  27387. }
  27388. var _ ent.Mutation = (*ServerMutation)(nil)
  27389. // serverOption allows management of the mutation configuration using functional options.
  27390. type serverOption func(*ServerMutation)
  27391. // newServerMutation creates new mutation for the Server entity.
  27392. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  27393. m := &ServerMutation{
  27394. config: c,
  27395. op: op,
  27396. typ: TypeServer,
  27397. clearedFields: make(map[string]struct{}),
  27398. }
  27399. for _, opt := range opts {
  27400. opt(m)
  27401. }
  27402. return m
  27403. }
  27404. // withServerID sets the ID field of the mutation.
  27405. func withServerID(id uint64) serverOption {
  27406. return func(m *ServerMutation) {
  27407. var (
  27408. err error
  27409. once sync.Once
  27410. value *Server
  27411. )
  27412. m.oldValue = func(ctx context.Context) (*Server, error) {
  27413. once.Do(func() {
  27414. if m.done {
  27415. err = errors.New("querying old values post mutation is not allowed")
  27416. } else {
  27417. value, err = m.Client().Server.Get(ctx, id)
  27418. }
  27419. })
  27420. return value, err
  27421. }
  27422. m.id = &id
  27423. }
  27424. }
  27425. // withServer sets the old Server of the mutation.
  27426. func withServer(node *Server) serverOption {
  27427. return func(m *ServerMutation) {
  27428. m.oldValue = func(context.Context) (*Server, error) {
  27429. return node, nil
  27430. }
  27431. m.id = &node.ID
  27432. }
  27433. }
  27434. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27435. // executed in a transaction (ent.Tx), a transactional client is returned.
  27436. func (m ServerMutation) Client() *Client {
  27437. client := &Client{config: m.config}
  27438. client.init()
  27439. return client
  27440. }
  27441. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27442. // it returns an error otherwise.
  27443. func (m ServerMutation) Tx() (*Tx, error) {
  27444. if _, ok := m.driver.(*txDriver); !ok {
  27445. return nil, errors.New("ent: mutation is not running in a transaction")
  27446. }
  27447. tx := &Tx{config: m.config}
  27448. tx.init()
  27449. return tx, nil
  27450. }
  27451. // SetID sets the value of the id field. Note that this
  27452. // operation is only accepted on creation of Server entities.
  27453. func (m *ServerMutation) SetID(id uint64) {
  27454. m.id = &id
  27455. }
  27456. // ID returns the ID value in the mutation. Note that the ID is only available
  27457. // if it was provided to the builder or after it was returned from the database.
  27458. func (m *ServerMutation) ID() (id uint64, exists bool) {
  27459. if m.id == nil {
  27460. return
  27461. }
  27462. return *m.id, true
  27463. }
  27464. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27465. // That means, if the mutation is applied within a transaction with an isolation level such
  27466. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27467. // or updated by the mutation.
  27468. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  27469. switch {
  27470. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27471. id, exists := m.ID()
  27472. if exists {
  27473. return []uint64{id}, nil
  27474. }
  27475. fallthrough
  27476. case m.op.Is(OpUpdate | OpDelete):
  27477. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  27478. default:
  27479. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27480. }
  27481. }
  27482. // SetCreatedAt sets the "created_at" field.
  27483. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  27484. m.created_at = &t
  27485. }
  27486. // CreatedAt returns the value of the "created_at" field in the mutation.
  27487. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  27488. v := m.created_at
  27489. if v == nil {
  27490. return
  27491. }
  27492. return *v, true
  27493. }
  27494. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  27495. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27497. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27498. if !m.op.Is(OpUpdateOne) {
  27499. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27500. }
  27501. if m.id == nil || m.oldValue == nil {
  27502. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27503. }
  27504. oldValue, err := m.oldValue(ctx)
  27505. if err != nil {
  27506. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27507. }
  27508. return oldValue.CreatedAt, nil
  27509. }
  27510. // ResetCreatedAt resets all changes to the "created_at" field.
  27511. func (m *ServerMutation) ResetCreatedAt() {
  27512. m.created_at = nil
  27513. }
  27514. // SetUpdatedAt sets the "updated_at" field.
  27515. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  27516. m.updated_at = &t
  27517. }
  27518. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27519. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  27520. v := m.updated_at
  27521. if v == nil {
  27522. return
  27523. }
  27524. return *v, true
  27525. }
  27526. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  27527. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27529. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27530. if !m.op.Is(OpUpdateOne) {
  27531. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27532. }
  27533. if m.id == nil || m.oldValue == nil {
  27534. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27535. }
  27536. oldValue, err := m.oldValue(ctx)
  27537. if err != nil {
  27538. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27539. }
  27540. return oldValue.UpdatedAt, nil
  27541. }
  27542. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27543. func (m *ServerMutation) ResetUpdatedAt() {
  27544. m.updated_at = nil
  27545. }
  27546. // SetStatus sets the "status" field.
  27547. func (m *ServerMutation) SetStatus(u uint8) {
  27548. m.status = &u
  27549. m.addstatus = nil
  27550. }
  27551. // Status returns the value of the "status" field in the mutation.
  27552. func (m *ServerMutation) Status() (r uint8, exists bool) {
  27553. v := m.status
  27554. if v == nil {
  27555. return
  27556. }
  27557. return *v, true
  27558. }
  27559. // OldStatus returns the old "status" field's value of the Server entity.
  27560. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27562. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27563. if !m.op.Is(OpUpdateOne) {
  27564. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27565. }
  27566. if m.id == nil || m.oldValue == nil {
  27567. return v, errors.New("OldStatus requires an ID field in the mutation")
  27568. }
  27569. oldValue, err := m.oldValue(ctx)
  27570. if err != nil {
  27571. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27572. }
  27573. return oldValue.Status, nil
  27574. }
  27575. // AddStatus adds u to the "status" field.
  27576. func (m *ServerMutation) AddStatus(u int8) {
  27577. if m.addstatus != nil {
  27578. *m.addstatus += u
  27579. } else {
  27580. m.addstatus = &u
  27581. }
  27582. }
  27583. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27584. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  27585. v := m.addstatus
  27586. if v == nil {
  27587. return
  27588. }
  27589. return *v, true
  27590. }
  27591. // ClearStatus clears the value of the "status" field.
  27592. func (m *ServerMutation) ClearStatus() {
  27593. m.status = nil
  27594. m.addstatus = nil
  27595. m.clearedFields[server.FieldStatus] = struct{}{}
  27596. }
  27597. // StatusCleared returns if the "status" field was cleared in this mutation.
  27598. func (m *ServerMutation) StatusCleared() bool {
  27599. _, ok := m.clearedFields[server.FieldStatus]
  27600. return ok
  27601. }
  27602. // ResetStatus resets all changes to the "status" field.
  27603. func (m *ServerMutation) ResetStatus() {
  27604. m.status = nil
  27605. m.addstatus = nil
  27606. delete(m.clearedFields, server.FieldStatus)
  27607. }
  27608. // SetDeletedAt sets the "deleted_at" field.
  27609. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  27610. m.deleted_at = &t
  27611. }
  27612. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27613. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  27614. v := m.deleted_at
  27615. if v == nil {
  27616. return
  27617. }
  27618. return *v, true
  27619. }
  27620. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  27621. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27623. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27624. if !m.op.Is(OpUpdateOne) {
  27625. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27626. }
  27627. if m.id == nil || m.oldValue == nil {
  27628. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27629. }
  27630. oldValue, err := m.oldValue(ctx)
  27631. if err != nil {
  27632. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27633. }
  27634. return oldValue.DeletedAt, nil
  27635. }
  27636. // ClearDeletedAt clears the value of the "deleted_at" field.
  27637. func (m *ServerMutation) ClearDeletedAt() {
  27638. m.deleted_at = nil
  27639. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  27640. }
  27641. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27642. func (m *ServerMutation) DeletedAtCleared() bool {
  27643. _, ok := m.clearedFields[server.FieldDeletedAt]
  27644. return ok
  27645. }
  27646. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27647. func (m *ServerMutation) ResetDeletedAt() {
  27648. m.deleted_at = nil
  27649. delete(m.clearedFields, server.FieldDeletedAt)
  27650. }
  27651. // SetName sets the "name" field.
  27652. func (m *ServerMutation) SetName(s string) {
  27653. m.name = &s
  27654. }
  27655. // Name returns the value of the "name" field in the mutation.
  27656. func (m *ServerMutation) Name() (r string, exists bool) {
  27657. v := m.name
  27658. if v == nil {
  27659. return
  27660. }
  27661. return *v, true
  27662. }
  27663. // OldName returns the old "name" field's value of the Server entity.
  27664. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27666. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  27667. if !m.op.Is(OpUpdateOne) {
  27668. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27669. }
  27670. if m.id == nil || m.oldValue == nil {
  27671. return v, errors.New("OldName requires an ID field in the mutation")
  27672. }
  27673. oldValue, err := m.oldValue(ctx)
  27674. if err != nil {
  27675. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27676. }
  27677. return oldValue.Name, nil
  27678. }
  27679. // ResetName resets all changes to the "name" field.
  27680. func (m *ServerMutation) ResetName() {
  27681. m.name = nil
  27682. }
  27683. // SetPublicIP sets the "public_ip" field.
  27684. func (m *ServerMutation) SetPublicIP(s string) {
  27685. m.public_ip = &s
  27686. }
  27687. // PublicIP returns the value of the "public_ip" field in the mutation.
  27688. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  27689. v := m.public_ip
  27690. if v == nil {
  27691. return
  27692. }
  27693. return *v, true
  27694. }
  27695. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  27696. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27698. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  27699. if !m.op.Is(OpUpdateOne) {
  27700. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  27701. }
  27702. if m.id == nil || m.oldValue == nil {
  27703. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  27704. }
  27705. oldValue, err := m.oldValue(ctx)
  27706. if err != nil {
  27707. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  27708. }
  27709. return oldValue.PublicIP, nil
  27710. }
  27711. // ResetPublicIP resets all changes to the "public_ip" field.
  27712. func (m *ServerMutation) ResetPublicIP() {
  27713. m.public_ip = nil
  27714. }
  27715. // SetPrivateIP sets the "private_ip" field.
  27716. func (m *ServerMutation) SetPrivateIP(s string) {
  27717. m.private_ip = &s
  27718. }
  27719. // PrivateIP returns the value of the "private_ip" field in the mutation.
  27720. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  27721. v := m.private_ip
  27722. if v == nil {
  27723. return
  27724. }
  27725. return *v, true
  27726. }
  27727. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  27728. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27730. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  27731. if !m.op.Is(OpUpdateOne) {
  27732. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  27733. }
  27734. if m.id == nil || m.oldValue == nil {
  27735. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  27736. }
  27737. oldValue, err := m.oldValue(ctx)
  27738. if err != nil {
  27739. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  27740. }
  27741. return oldValue.PrivateIP, nil
  27742. }
  27743. // ResetPrivateIP resets all changes to the "private_ip" field.
  27744. func (m *ServerMutation) ResetPrivateIP() {
  27745. m.private_ip = nil
  27746. }
  27747. // SetAdminPort sets the "admin_port" field.
  27748. func (m *ServerMutation) SetAdminPort(s string) {
  27749. m.admin_port = &s
  27750. }
  27751. // AdminPort returns the value of the "admin_port" field in the mutation.
  27752. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  27753. v := m.admin_port
  27754. if v == nil {
  27755. return
  27756. }
  27757. return *v, true
  27758. }
  27759. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  27760. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27762. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  27763. if !m.op.Is(OpUpdateOne) {
  27764. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  27765. }
  27766. if m.id == nil || m.oldValue == nil {
  27767. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  27768. }
  27769. oldValue, err := m.oldValue(ctx)
  27770. if err != nil {
  27771. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  27772. }
  27773. return oldValue.AdminPort, nil
  27774. }
  27775. // ResetAdminPort resets all changes to the "admin_port" field.
  27776. func (m *ServerMutation) ResetAdminPort() {
  27777. m.admin_port = nil
  27778. }
  27779. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  27780. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  27781. if m.wxs == nil {
  27782. m.wxs = make(map[uint64]struct{})
  27783. }
  27784. for i := range ids {
  27785. m.wxs[ids[i]] = struct{}{}
  27786. }
  27787. }
  27788. // ClearWxs clears the "wxs" edge to the Wx entity.
  27789. func (m *ServerMutation) ClearWxs() {
  27790. m.clearedwxs = true
  27791. }
  27792. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  27793. func (m *ServerMutation) WxsCleared() bool {
  27794. return m.clearedwxs
  27795. }
  27796. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  27797. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  27798. if m.removedwxs == nil {
  27799. m.removedwxs = make(map[uint64]struct{})
  27800. }
  27801. for i := range ids {
  27802. delete(m.wxs, ids[i])
  27803. m.removedwxs[ids[i]] = struct{}{}
  27804. }
  27805. }
  27806. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  27807. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  27808. for id := range m.removedwxs {
  27809. ids = append(ids, id)
  27810. }
  27811. return
  27812. }
  27813. // WxsIDs returns the "wxs" edge IDs in the mutation.
  27814. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  27815. for id := range m.wxs {
  27816. ids = append(ids, id)
  27817. }
  27818. return
  27819. }
  27820. // ResetWxs resets all changes to the "wxs" edge.
  27821. func (m *ServerMutation) ResetWxs() {
  27822. m.wxs = nil
  27823. m.clearedwxs = false
  27824. m.removedwxs = nil
  27825. }
  27826. // Where appends a list predicates to the ServerMutation builder.
  27827. func (m *ServerMutation) Where(ps ...predicate.Server) {
  27828. m.predicates = append(m.predicates, ps...)
  27829. }
  27830. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  27831. // users can use type-assertion to append predicates that do not depend on any generated package.
  27832. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  27833. p := make([]predicate.Server, len(ps))
  27834. for i := range ps {
  27835. p[i] = ps[i]
  27836. }
  27837. m.Where(p...)
  27838. }
  27839. // Op returns the operation name.
  27840. func (m *ServerMutation) Op() Op {
  27841. return m.op
  27842. }
  27843. // SetOp allows setting the mutation operation.
  27844. func (m *ServerMutation) SetOp(op Op) {
  27845. m.op = op
  27846. }
  27847. // Type returns the node type of this mutation (Server).
  27848. func (m *ServerMutation) Type() string {
  27849. return m.typ
  27850. }
  27851. // Fields returns all fields that were changed during this mutation. Note that in
  27852. // order to get all numeric fields that were incremented/decremented, call
  27853. // AddedFields().
  27854. func (m *ServerMutation) Fields() []string {
  27855. fields := make([]string, 0, 8)
  27856. if m.created_at != nil {
  27857. fields = append(fields, server.FieldCreatedAt)
  27858. }
  27859. if m.updated_at != nil {
  27860. fields = append(fields, server.FieldUpdatedAt)
  27861. }
  27862. if m.status != nil {
  27863. fields = append(fields, server.FieldStatus)
  27864. }
  27865. if m.deleted_at != nil {
  27866. fields = append(fields, server.FieldDeletedAt)
  27867. }
  27868. if m.name != nil {
  27869. fields = append(fields, server.FieldName)
  27870. }
  27871. if m.public_ip != nil {
  27872. fields = append(fields, server.FieldPublicIP)
  27873. }
  27874. if m.private_ip != nil {
  27875. fields = append(fields, server.FieldPrivateIP)
  27876. }
  27877. if m.admin_port != nil {
  27878. fields = append(fields, server.FieldAdminPort)
  27879. }
  27880. return fields
  27881. }
  27882. // Field returns the value of a field with the given name. The second boolean
  27883. // return value indicates that this field was not set, or was not defined in the
  27884. // schema.
  27885. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  27886. switch name {
  27887. case server.FieldCreatedAt:
  27888. return m.CreatedAt()
  27889. case server.FieldUpdatedAt:
  27890. return m.UpdatedAt()
  27891. case server.FieldStatus:
  27892. return m.Status()
  27893. case server.FieldDeletedAt:
  27894. return m.DeletedAt()
  27895. case server.FieldName:
  27896. return m.Name()
  27897. case server.FieldPublicIP:
  27898. return m.PublicIP()
  27899. case server.FieldPrivateIP:
  27900. return m.PrivateIP()
  27901. case server.FieldAdminPort:
  27902. return m.AdminPort()
  27903. }
  27904. return nil, false
  27905. }
  27906. // OldField returns the old value of the field from the database. An error is
  27907. // returned if the mutation operation is not UpdateOne, or the query to the
  27908. // database failed.
  27909. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27910. switch name {
  27911. case server.FieldCreatedAt:
  27912. return m.OldCreatedAt(ctx)
  27913. case server.FieldUpdatedAt:
  27914. return m.OldUpdatedAt(ctx)
  27915. case server.FieldStatus:
  27916. return m.OldStatus(ctx)
  27917. case server.FieldDeletedAt:
  27918. return m.OldDeletedAt(ctx)
  27919. case server.FieldName:
  27920. return m.OldName(ctx)
  27921. case server.FieldPublicIP:
  27922. return m.OldPublicIP(ctx)
  27923. case server.FieldPrivateIP:
  27924. return m.OldPrivateIP(ctx)
  27925. case server.FieldAdminPort:
  27926. return m.OldAdminPort(ctx)
  27927. }
  27928. return nil, fmt.Errorf("unknown Server field %s", name)
  27929. }
  27930. // SetField sets the value of a field with the given name. It returns an error if
  27931. // the field is not defined in the schema, or if the type mismatched the field
  27932. // type.
  27933. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  27934. switch name {
  27935. case server.FieldCreatedAt:
  27936. v, ok := value.(time.Time)
  27937. if !ok {
  27938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27939. }
  27940. m.SetCreatedAt(v)
  27941. return nil
  27942. case server.FieldUpdatedAt:
  27943. v, ok := value.(time.Time)
  27944. if !ok {
  27945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27946. }
  27947. m.SetUpdatedAt(v)
  27948. return nil
  27949. case server.FieldStatus:
  27950. v, ok := value.(uint8)
  27951. if !ok {
  27952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27953. }
  27954. m.SetStatus(v)
  27955. return nil
  27956. case server.FieldDeletedAt:
  27957. v, ok := value.(time.Time)
  27958. if !ok {
  27959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27960. }
  27961. m.SetDeletedAt(v)
  27962. return nil
  27963. case server.FieldName:
  27964. v, ok := value.(string)
  27965. if !ok {
  27966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27967. }
  27968. m.SetName(v)
  27969. return nil
  27970. case server.FieldPublicIP:
  27971. v, ok := value.(string)
  27972. if !ok {
  27973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27974. }
  27975. m.SetPublicIP(v)
  27976. return nil
  27977. case server.FieldPrivateIP:
  27978. v, ok := value.(string)
  27979. if !ok {
  27980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27981. }
  27982. m.SetPrivateIP(v)
  27983. return nil
  27984. case server.FieldAdminPort:
  27985. v, ok := value.(string)
  27986. if !ok {
  27987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27988. }
  27989. m.SetAdminPort(v)
  27990. return nil
  27991. }
  27992. return fmt.Errorf("unknown Server field %s", name)
  27993. }
  27994. // AddedFields returns all numeric fields that were incremented/decremented during
  27995. // this mutation.
  27996. func (m *ServerMutation) AddedFields() []string {
  27997. var fields []string
  27998. if m.addstatus != nil {
  27999. fields = append(fields, server.FieldStatus)
  28000. }
  28001. return fields
  28002. }
  28003. // AddedField returns the numeric value that was incremented/decremented on a field
  28004. // with the given name. The second boolean return value indicates that this field
  28005. // was not set, or was not defined in the schema.
  28006. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  28007. switch name {
  28008. case server.FieldStatus:
  28009. return m.AddedStatus()
  28010. }
  28011. return nil, false
  28012. }
  28013. // AddField adds the value to the field with the given name. It returns an error if
  28014. // the field is not defined in the schema, or if the type mismatched the field
  28015. // type.
  28016. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  28017. switch name {
  28018. case server.FieldStatus:
  28019. v, ok := value.(int8)
  28020. if !ok {
  28021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28022. }
  28023. m.AddStatus(v)
  28024. return nil
  28025. }
  28026. return fmt.Errorf("unknown Server numeric field %s", name)
  28027. }
  28028. // ClearedFields returns all nullable fields that were cleared during this
  28029. // mutation.
  28030. func (m *ServerMutation) ClearedFields() []string {
  28031. var fields []string
  28032. if m.FieldCleared(server.FieldStatus) {
  28033. fields = append(fields, server.FieldStatus)
  28034. }
  28035. if m.FieldCleared(server.FieldDeletedAt) {
  28036. fields = append(fields, server.FieldDeletedAt)
  28037. }
  28038. return fields
  28039. }
  28040. // FieldCleared returns a boolean indicating if a field with the given name was
  28041. // cleared in this mutation.
  28042. func (m *ServerMutation) FieldCleared(name string) bool {
  28043. _, ok := m.clearedFields[name]
  28044. return ok
  28045. }
  28046. // ClearField clears the value of the field with the given name. It returns an
  28047. // error if the field is not defined in the schema.
  28048. func (m *ServerMutation) ClearField(name string) error {
  28049. switch name {
  28050. case server.FieldStatus:
  28051. m.ClearStatus()
  28052. return nil
  28053. case server.FieldDeletedAt:
  28054. m.ClearDeletedAt()
  28055. return nil
  28056. }
  28057. return fmt.Errorf("unknown Server nullable field %s", name)
  28058. }
  28059. // ResetField resets all changes in the mutation for the field with the given name.
  28060. // It returns an error if the field is not defined in the schema.
  28061. func (m *ServerMutation) ResetField(name string) error {
  28062. switch name {
  28063. case server.FieldCreatedAt:
  28064. m.ResetCreatedAt()
  28065. return nil
  28066. case server.FieldUpdatedAt:
  28067. m.ResetUpdatedAt()
  28068. return nil
  28069. case server.FieldStatus:
  28070. m.ResetStatus()
  28071. return nil
  28072. case server.FieldDeletedAt:
  28073. m.ResetDeletedAt()
  28074. return nil
  28075. case server.FieldName:
  28076. m.ResetName()
  28077. return nil
  28078. case server.FieldPublicIP:
  28079. m.ResetPublicIP()
  28080. return nil
  28081. case server.FieldPrivateIP:
  28082. m.ResetPrivateIP()
  28083. return nil
  28084. case server.FieldAdminPort:
  28085. m.ResetAdminPort()
  28086. return nil
  28087. }
  28088. return fmt.Errorf("unknown Server field %s", name)
  28089. }
  28090. // AddedEdges returns all edge names that were set/added in this mutation.
  28091. func (m *ServerMutation) AddedEdges() []string {
  28092. edges := make([]string, 0, 1)
  28093. if m.wxs != nil {
  28094. edges = append(edges, server.EdgeWxs)
  28095. }
  28096. return edges
  28097. }
  28098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28099. // name in this mutation.
  28100. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  28101. switch name {
  28102. case server.EdgeWxs:
  28103. ids := make([]ent.Value, 0, len(m.wxs))
  28104. for id := range m.wxs {
  28105. ids = append(ids, id)
  28106. }
  28107. return ids
  28108. }
  28109. return nil
  28110. }
  28111. // RemovedEdges returns all edge names that were removed in this mutation.
  28112. func (m *ServerMutation) RemovedEdges() []string {
  28113. edges := make([]string, 0, 1)
  28114. if m.removedwxs != nil {
  28115. edges = append(edges, server.EdgeWxs)
  28116. }
  28117. return edges
  28118. }
  28119. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28120. // the given name in this mutation.
  28121. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  28122. switch name {
  28123. case server.EdgeWxs:
  28124. ids := make([]ent.Value, 0, len(m.removedwxs))
  28125. for id := range m.removedwxs {
  28126. ids = append(ids, id)
  28127. }
  28128. return ids
  28129. }
  28130. return nil
  28131. }
  28132. // ClearedEdges returns all edge names that were cleared in this mutation.
  28133. func (m *ServerMutation) ClearedEdges() []string {
  28134. edges := make([]string, 0, 1)
  28135. if m.clearedwxs {
  28136. edges = append(edges, server.EdgeWxs)
  28137. }
  28138. return edges
  28139. }
  28140. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28141. // was cleared in this mutation.
  28142. func (m *ServerMutation) EdgeCleared(name string) bool {
  28143. switch name {
  28144. case server.EdgeWxs:
  28145. return m.clearedwxs
  28146. }
  28147. return false
  28148. }
  28149. // ClearEdge clears the value of the edge with the given name. It returns an error
  28150. // if that edge is not defined in the schema.
  28151. func (m *ServerMutation) ClearEdge(name string) error {
  28152. switch name {
  28153. }
  28154. return fmt.Errorf("unknown Server unique edge %s", name)
  28155. }
  28156. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28157. // It returns an error if the edge is not defined in the schema.
  28158. func (m *ServerMutation) ResetEdge(name string) error {
  28159. switch name {
  28160. case server.EdgeWxs:
  28161. m.ResetWxs()
  28162. return nil
  28163. }
  28164. return fmt.Errorf("unknown Server edge %s", name)
  28165. }
  28166. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  28167. type SopNodeMutation struct {
  28168. config
  28169. op Op
  28170. typ string
  28171. id *uint64
  28172. created_at *time.Time
  28173. updated_at *time.Time
  28174. status *uint8
  28175. addstatus *int8
  28176. deleted_at *time.Time
  28177. parent_id *uint64
  28178. addparent_id *int64
  28179. name *string
  28180. condition_type *int
  28181. addcondition_type *int
  28182. condition_list *[]string
  28183. appendcondition_list []string
  28184. no_reply_condition *uint64
  28185. addno_reply_condition *int64
  28186. no_reply_unit *string
  28187. action_message *[]custom_types.Action
  28188. appendaction_message []custom_types.Action
  28189. action_label_add *[]uint64
  28190. appendaction_label_add []uint64
  28191. action_label_del *[]uint64
  28192. appendaction_label_del []uint64
  28193. action_forward **custom_types.ActionForward
  28194. clearedFields map[string]struct{}
  28195. sop_stage *uint64
  28196. clearedsop_stage bool
  28197. node_messages map[uint64]struct{}
  28198. removednode_messages map[uint64]struct{}
  28199. clearednode_messages bool
  28200. done bool
  28201. oldValue func(context.Context) (*SopNode, error)
  28202. predicates []predicate.SopNode
  28203. }
  28204. var _ ent.Mutation = (*SopNodeMutation)(nil)
  28205. // sopnodeOption allows management of the mutation configuration using functional options.
  28206. type sopnodeOption func(*SopNodeMutation)
  28207. // newSopNodeMutation creates new mutation for the SopNode entity.
  28208. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  28209. m := &SopNodeMutation{
  28210. config: c,
  28211. op: op,
  28212. typ: TypeSopNode,
  28213. clearedFields: make(map[string]struct{}),
  28214. }
  28215. for _, opt := range opts {
  28216. opt(m)
  28217. }
  28218. return m
  28219. }
  28220. // withSopNodeID sets the ID field of the mutation.
  28221. func withSopNodeID(id uint64) sopnodeOption {
  28222. return func(m *SopNodeMutation) {
  28223. var (
  28224. err error
  28225. once sync.Once
  28226. value *SopNode
  28227. )
  28228. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  28229. once.Do(func() {
  28230. if m.done {
  28231. err = errors.New("querying old values post mutation is not allowed")
  28232. } else {
  28233. value, err = m.Client().SopNode.Get(ctx, id)
  28234. }
  28235. })
  28236. return value, err
  28237. }
  28238. m.id = &id
  28239. }
  28240. }
  28241. // withSopNode sets the old SopNode of the mutation.
  28242. func withSopNode(node *SopNode) sopnodeOption {
  28243. return func(m *SopNodeMutation) {
  28244. m.oldValue = func(context.Context) (*SopNode, error) {
  28245. return node, nil
  28246. }
  28247. m.id = &node.ID
  28248. }
  28249. }
  28250. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28251. // executed in a transaction (ent.Tx), a transactional client is returned.
  28252. func (m SopNodeMutation) Client() *Client {
  28253. client := &Client{config: m.config}
  28254. client.init()
  28255. return client
  28256. }
  28257. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28258. // it returns an error otherwise.
  28259. func (m SopNodeMutation) Tx() (*Tx, error) {
  28260. if _, ok := m.driver.(*txDriver); !ok {
  28261. return nil, errors.New("ent: mutation is not running in a transaction")
  28262. }
  28263. tx := &Tx{config: m.config}
  28264. tx.init()
  28265. return tx, nil
  28266. }
  28267. // SetID sets the value of the id field. Note that this
  28268. // operation is only accepted on creation of SopNode entities.
  28269. func (m *SopNodeMutation) SetID(id uint64) {
  28270. m.id = &id
  28271. }
  28272. // ID returns the ID value in the mutation. Note that the ID is only available
  28273. // if it was provided to the builder or after it was returned from the database.
  28274. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  28275. if m.id == nil {
  28276. return
  28277. }
  28278. return *m.id, true
  28279. }
  28280. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28281. // That means, if the mutation is applied within a transaction with an isolation level such
  28282. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28283. // or updated by the mutation.
  28284. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  28285. switch {
  28286. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28287. id, exists := m.ID()
  28288. if exists {
  28289. return []uint64{id}, nil
  28290. }
  28291. fallthrough
  28292. case m.op.Is(OpUpdate | OpDelete):
  28293. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  28294. default:
  28295. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28296. }
  28297. }
  28298. // SetCreatedAt sets the "created_at" field.
  28299. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  28300. m.created_at = &t
  28301. }
  28302. // CreatedAt returns the value of the "created_at" field in the mutation.
  28303. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  28304. v := m.created_at
  28305. if v == nil {
  28306. return
  28307. }
  28308. return *v, true
  28309. }
  28310. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  28311. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28313. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28314. if !m.op.Is(OpUpdateOne) {
  28315. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28316. }
  28317. if m.id == nil || m.oldValue == nil {
  28318. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28319. }
  28320. oldValue, err := m.oldValue(ctx)
  28321. if err != nil {
  28322. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28323. }
  28324. return oldValue.CreatedAt, nil
  28325. }
  28326. // ResetCreatedAt resets all changes to the "created_at" field.
  28327. func (m *SopNodeMutation) ResetCreatedAt() {
  28328. m.created_at = nil
  28329. }
  28330. // SetUpdatedAt sets the "updated_at" field.
  28331. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  28332. m.updated_at = &t
  28333. }
  28334. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28335. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  28336. v := m.updated_at
  28337. if v == nil {
  28338. return
  28339. }
  28340. return *v, true
  28341. }
  28342. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  28343. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28345. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28346. if !m.op.Is(OpUpdateOne) {
  28347. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28348. }
  28349. if m.id == nil || m.oldValue == nil {
  28350. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28351. }
  28352. oldValue, err := m.oldValue(ctx)
  28353. if err != nil {
  28354. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28355. }
  28356. return oldValue.UpdatedAt, nil
  28357. }
  28358. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28359. func (m *SopNodeMutation) ResetUpdatedAt() {
  28360. m.updated_at = nil
  28361. }
  28362. // SetStatus sets the "status" field.
  28363. func (m *SopNodeMutation) SetStatus(u uint8) {
  28364. m.status = &u
  28365. m.addstatus = nil
  28366. }
  28367. // Status returns the value of the "status" field in the mutation.
  28368. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  28369. v := m.status
  28370. if v == nil {
  28371. return
  28372. }
  28373. return *v, true
  28374. }
  28375. // OldStatus returns the old "status" field's value of the SopNode entity.
  28376. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28378. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28379. if !m.op.Is(OpUpdateOne) {
  28380. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28381. }
  28382. if m.id == nil || m.oldValue == nil {
  28383. return v, errors.New("OldStatus requires an ID field in the mutation")
  28384. }
  28385. oldValue, err := m.oldValue(ctx)
  28386. if err != nil {
  28387. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28388. }
  28389. return oldValue.Status, nil
  28390. }
  28391. // AddStatus adds u to the "status" field.
  28392. func (m *SopNodeMutation) AddStatus(u int8) {
  28393. if m.addstatus != nil {
  28394. *m.addstatus += u
  28395. } else {
  28396. m.addstatus = &u
  28397. }
  28398. }
  28399. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28400. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  28401. v := m.addstatus
  28402. if v == nil {
  28403. return
  28404. }
  28405. return *v, true
  28406. }
  28407. // ClearStatus clears the value of the "status" field.
  28408. func (m *SopNodeMutation) ClearStatus() {
  28409. m.status = nil
  28410. m.addstatus = nil
  28411. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  28412. }
  28413. // StatusCleared returns if the "status" field was cleared in this mutation.
  28414. func (m *SopNodeMutation) StatusCleared() bool {
  28415. _, ok := m.clearedFields[sopnode.FieldStatus]
  28416. return ok
  28417. }
  28418. // ResetStatus resets all changes to the "status" field.
  28419. func (m *SopNodeMutation) ResetStatus() {
  28420. m.status = nil
  28421. m.addstatus = nil
  28422. delete(m.clearedFields, sopnode.FieldStatus)
  28423. }
  28424. // SetDeletedAt sets the "deleted_at" field.
  28425. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  28426. m.deleted_at = &t
  28427. }
  28428. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28429. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  28430. v := m.deleted_at
  28431. if v == nil {
  28432. return
  28433. }
  28434. return *v, true
  28435. }
  28436. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  28437. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28439. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28440. if !m.op.Is(OpUpdateOne) {
  28441. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28442. }
  28443. if m.id == nil || m.oldValue == nil {
  28444. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28445. }
  28446. oldValue, err := m.oldValue(ctx)
  28447. if err != nil {
  28448. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28449. }
  28450. return oldValue.DeletedAt, nil
  28451. }
  28452. // ClearDeletedAt clears the value of the "deleted_at" field.
  28453. func (m *SopNodeMutation) ClearDeletedAt() {
  28454. m.deleted_at = nil
  28455. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  28456. }
  28457. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28458. func (m *SopNodeMutation) DeletedAtCleared() bool {
  28459. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  28460. return ok
  28461. }
  28462. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28463. func (m *SopNodeMutation) ResetDeletedAt() {
  28464. m.deleted_at = nil
  28465. delete(m.clearedFields, sopnode.FieldDeletedAt)
  28466. }
  28467. // SetStageID sets the "stage_id" field.
  28468. func (m *SopNodeMutation) SetStageID(u uint64) {
  28469. m.sop_stage = &u
  28470. }
  28471. // StageID returns the value of the "stage_id" field in the mutation.
  28472. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  28473. v := m.sop_stage
  28474. if v == nil {
  28475. return
  28476. }
  28477. return *v, true
  28478. }
  28479. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  28480. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28482. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  28483. if !m.op.Is(OpUpdateOne) {
  28484. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  28485. }
  28486. if m.id == nil || m.oldValue == nil {
  28487. return v, errors.New("OldStageID requires an ID field in the mutation")
  28488. }
  28489. oldValue, err := m.oldValue(ctx)
  28490. if err != nil {
  28491. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  28492. }
  28493. return oldValue.StageID, nil
  28494. }
  28495. // ResetStageID resets all changes to the "stage_id" field.
  28496. func (m *SopNodeMutation) ResetStageID() {
  28497. m.sop_stage = nil
  28498. }
  28499. // SetParentID sets the "parent_id" field.
  28500. func (m *SopNodeMutation) SetParentID(u uint64) {
  28501. m.parent_id = &u
  28502. m.addparent_id = nil
  28503. }
  28504. // ParentID returns the value of the "parent_id" field in the mutation.
  28505. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  28506. v := m.parent_id
  28507. if v == nil {
  28508. return
  28509. }
  28510. return *v, true
  28511. }
  28512. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  28513. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28515. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  28516. if !m.op.Is(OpUpdateOne) {
  28517. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  28518. }
  28519. if m.id == nil || m.oldValue == nil {
  28520. return v, errors.New("OldParentID requires an ID field in the mutation")
  28521. }
  28522. oldValue, err := m.oldValue(ctx)
  28523. if err != nil {
  28524. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  28525. }
  28526. return oldValue.ParentID, nil
  28527. }
  28528. // AddParentID adds u to the "parent_id" field.
  28529. func (m *SopNodeMutation) AddParentID(u int64) {
  28530. if m.addparent_id != nil {
  28531. *m.addparent_id += u
  28532. } else {
  28533. m.addparent_id = &u
  28534. }
  28535. }
  28536. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  28537. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  28538. v := m.addparent_id
  28539. if v == nil {
  28540. return
  28541. }
  28542. return *v, true
  28543. }
  28544. // ResetParentID resets all changes to the "parent_id" field.
  28545. func (m *SopNodeMutation) ResetParentID() {
  28546. m.parent_id = nil
  28547. m.addparent_id = nil
  28548. }
  28549. // SetName sets the "name" field.
  28550. func (m *SopNodeMutation) SetName(s string) {
  28551. m.name = &s
  28552. }
  28553. // Name returns the value of the "name" field in the mutation.
  28554. func (m *SopNodeMutation) Name() (r string, exists bool) {
  28555. v := m.name
  28556. if v == nil {
  28557. return
  28558. }
  28559. return *v, true
  28560. }
  28561. // OldName returns the old "name" field's value of the SopNode entity.
  28562. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28564. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  28565. if !m.op.Is(OpUpdateOne) {
  28566. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28567. }
  28568. if m.id == nil || m.oldValue == nil {
  28569. return v, errors.New("OldName requires an ID field in the mutation")
  28570. }
  28571. oldValue, err := m.oldValue(ctx)
  28572. if err != nil {
  28573. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28574. }
  28575. return oldValue.Name, nil
  28576. }
  28577. // ResetName resets all changes to the "name" field.
  28578. func (m *SopNodeMutation) ResetName() {
  28579. m.name = nil
  28580. }
  28581. // SetConditionType sets the "condition_type" field.
  28582. func (m *SopNodeMutation) SetConditionType(i int) {
  28583. m.condition_type = &i
  28584. m.addcondition_type = nil
  28585. }
  28586. // ConditionType returns the value of the "condition_type" field in the mutation.
  28587. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  28588. v := m.condition_type
  28589. if v == nil {
  28590. return
  28591. }
  28592. return *v, true
  28593. }
  28594. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  28595. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28597. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28598. if !m.op.Is(OpUpdateOne) {
  28599. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28600. }
  28601. if m.id == nil || m.oldValue == nil {
  28602. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28603. }
  28604. oldValue, err := m.oldValue(ctx)
  28605. if err != nil {
  28606. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28607. }
  28608. return oldValue.ConditionType, nil
  28609. }
  28610. // AddConditionType adds i to the "condition_type" field.
  28611. func (m *SopNodeMutation) AddConditionType(i int) {
  28612. if m.addcondition_type != nil {
  28613. *m.addcondition_type += i
  28614. } else {
  28615. m.addcondition_type = &i
  28616. }
  28617. }
  28618. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28619. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  28620. v := m.addcondition_type
  28621. if v == nil {
  28622. return
  28623. }
  28624. return *v, true
  28625. }
  28626. // ResetConditionType resets all changes to the "condition_type" field.
  28627. func (m *SopNodeMutation) ResetConditionType() {
  28628. m.condition_type = nil
  28629. m.addcondition_type = nil
  28630. }
  28631. // SetConditionList sets the "condition_list" field.
  28632. func (m *SopNodeMutation) SetConditionList(s []string) {
  28633. m.condition_list = &s
  28634. m.appendcondition_list = nil
  28635. }
  28636. // ConditionList returns the value of the "condition_list" field in the mutation.
  28637. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  28638. v := m.condition_list
  28639. if v == nil {
  28640. return
  28641. }
  28642. return *v, true
  28643. }
  28644. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  28645. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28647. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  28648. if !m.op.Is(OpUpdateOne) {
  28649. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28650. }
  28651. if m.id == nil || m.oldValue == nil {
  28652. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28653. }
  28654. oldValue, err := m.oldValue(ctx)
  28655. if err != nil {
  28656. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28657. }
  28658. return oldValue.ConditionList, nil
  28659. }
  28660. // AppendConditionList adds s to the "condition_list" field.
  28661. func (m *SopNodeMutation) AppendConditionList(s []string) {
  28662. m.appendcondition_list = append(m.appendcondition_list, s...)
  28663. }
  28664. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28665. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  28666. if len(m.appendcondition_list) == 0 {
  28667. return nil, false
  28668. }
  28669. return m.appendcondition_list, true
  28670. }
  28671. // ClearConditionList clears the value of the "condition_list" field.
  28672. func (m *SopNodeMutation) ClearConditionList() {
  28673. m.condition_list = nil
  28674. m.appendcondition_list = nil
  28675. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  28676. }
  28677. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  28678. func (m *SopNodeMutation) ConditionListCleared() bool {
  28679. _, ok := m.clearedFields[sopnode.FieldConditionList]
  28680. return ok
  28681. }
  28682. // ResetConditionList resets all changes to the "condition_list" field.
  28683. func (m *SopNodeMutation) ResetConditionList() {
  28684. m.condition_list = nil
  28685. m.appendcondition_list = nil
  28686. delete(m.clearedFields, sopnode.FieldConditionList)
  28687. }
  28688. // SetNoReplyCondition sets the "no_reply_condition" field.
  28689. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  28690. m.no_reply_condition = &u
  28691. m.addno_reply_condition = nil
  28692. }
  28693. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  28694. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  28695. v := m.no_reply_condition
  28696. if v == nil {
  28697. return
  28698. }
  28699. return *v, true
  28700. }
  28701. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  28702. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28704. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  28705. if !m.op.Is(OpUpdateOne) {
  28706. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  28707. }
  28708. if m.id == nil || m.oldValue == nil {
  28709. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  28710. }
  28711. oldValue, err := m.oldValue(ctx)
  28712. if err != nil {
  28713. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  28714. }
  28715. return oldValue.NoReplyCondition, nil
  28716. }
  28717. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  28718. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  28719. if m.addno_reply_condition != nil {
  28720. *m.addno_reply_condition += u
  28721. } else {
  28722. m.addno_reply_condition = &u
  28723. }
  28724. }
  28725. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  28726. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  28727. v := m.addno_reply_condition
  28728. if v == nil {
  28729. return
  28730. }
  28731. return *v, true
  28732. }
  28733. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  28734. func (m *SopNodeMutation) ResetNoReplyCondition() {
  28735. m.no_reply_condition = nil
  28736. m.addno_reply_condition = nil
  28737. }
  28738. // SetNoReplyUnit sets the "no_reply_unit" field.
  28739. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  28740. m.no_reply_unit = &s
  28741. }
  28742. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  28743. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  28744. v := m.no_reply_unit
  28745. if v == nil {
  28746. return
  28747. }
  28748. return *v, true
  28749. }
  28750. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  28751. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28753. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  28754. if !m.op.Is(OpUpdateOne) {
  28755. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  28756. }
  28757. if m.id == nil || m.oldValue == nil {
  28758. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  28759. }
  28760. oldValue, err := m.oldValue(ctx)
  28761. if err != nil {
  28762. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  28763. }
  28764. return oldValue.NoReplyUnit, nil
  28765. }
  28766. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  28767. func (m *SopNodeMutation) ResetNoReplyUnit() {
  28768. m.no_reply_unit = nil
  28769. }
  28770. // SetActionMessage sets the "action_message" field.
  28771. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  28772. m.action_message = &ct
  28773. m.appendaction_message = nil
  28774. }
  28775. // ActionMessage returns the value of the "action_message" field in the mutation.
  28776. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28777. v := m.action_message
  28778. if v == nil {
  28779. return
  28780. }
  28781. return *v, true
  28782. }
  28783. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  28784. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28786. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28787. if !m.op.Is(OpUpdateOne) {
  28788. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28789. }
  28790. if m.id == nil || m.oldValue == nil {
  28791. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28792. }
  28793. oldValue, err := m.oldValue(ctx)
  28794. if err != nil {
  28795. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28796. }
  28797. return oldValue.ActionMessage, nil
  28798. }
  28799. // AppendActionMessage adds ct to the "action_message" field.
  28800. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  28801. m.appendaction_message = append(m.appendaction_message, ct...)
  28802. }
  28803. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28804. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28805. if len(m.appendaction_message) == 0 {
  28806. return nil, false
  28807. }
  28808. return m.appendaction_message, true
  28809. }
  28810. // ClearActionMessage clears the value of the "action_message" field.
  28811. func (m *SopNodeMutation) ClearActionMessage() {
  28812. m.action_message = nil
  28813. m.appendaction_message = nil
  28814. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  28815. }
  28816. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28817. func (m *SopNodeMutation) ActionMessageCleared() bool {
  28818. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  28819. return ok
  28820. }
  28821. // ResetActionMessage resets all changes to the "action_message" field.
  28822. func (m *SopNodeMutation) ResetActionMessage() {
  28823. m.action_message = nil
  28824. m.appendaction_message = nil
  28825. delete(m.clearedFields, sopnode.FieldActionMessage)
  28826. }
  28827. // SetActionLabelAdd sets the "action_label_add" field.
  28828. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  28829. m.action_label_add = &u
  28830. m.appendaction_label_add = nil
  28831. }
  28832. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28833. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28834. v := m.action_label_add
  28835. if v == nil {
  28836. return
  28837. }
  28838. return *v, true
  28839. }
  28840. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  28841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28843. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28844. if !m.op.Is(OpUpdateOne) {
  28845. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28846. }
  28847. if m.id == nil || m.oldValue == nil {
  28848. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28849. }
  28850. oldValue, err := m.oldValue(ctx)
  28851. if err != nil {
  28852. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28853. }
  28854. return oldValue.ActionLabelAdd, nil
  28855. }
  28856. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28857. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  28858. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28859. }
  28860. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28861. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28862. if len(m.appendaction_label_add) == 0 {
  28863. return nil, false
  28864. }
  28865. return m.appendaction_label_add, true
  28866. }
  28867. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28868. func (m *SopNodeMutation) ClearActionLabelAdd() {
  28869. m.action_label_add = nil
  28870. m.appendaction_label_add = nil
  28871. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  28872. }
  28873. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28874. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  28875. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  28876. return ok
  28877. }
  28878. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28879. func (m *SopNodeMutation) ResetActionLabelAdd() {
  28880. m.action_label_add = nil
  28881. m.appendaction_label_add = nil
  28882. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  28883. }
  28884. // SetActionLabelDel sets the "action_label_del" field.
  28885. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  28886. m.action_label_del = &u
  28887. m.appendaction_label_del = nil
  28888. }
  28889. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28890. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  28891. v := m.action_label_del
  28892. if v == nil {
  28893. return
  28894. }
  28895. return *v, true
  28896. }
  28897. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  28898. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28900. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28901. if !m.op.Is(OpUpdateOne) {
  28902. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28903. }
  28904. if m.id == nil || m.oldValue == nil {
  28905. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28906. }
  28907. oldValue, err := m.oldValue(ctx)
  28908. if err != nil {
  28909. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28910. }
  28911. return oldValue.ActionLabelDel, nil
  28912. }
  28913. // AppendActionLabelDel adds u to the "action_label_del" field.
  28914. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  28915. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28916. }
  28917. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28918. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28919. if len(m.appendaction_label_del) == 0 {
  28920. return nil, false
  28921. }
  28922. return m.appendaction_label_del, true
  28923. }
  28924. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28925. func (m *SopNodeMutation) ClearActionLabelDel() {
  28926. m.action_label_del = nil
  28927. m.appendaction_label_del = nil
  28928. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  28929. }
  28930. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28931. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  28932. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  28933. return ok
  28934. }
  28935. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28936. func (m *SopNodeMutation) ResetActionLabelDel() {
  28937. m.action_label_del = nil
  28938. m.appendaction_label_del = nil
  28939. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  28940. }
  28941. // SetActionForward sets the "action_forward" field.
  28942. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28943. m.action_forward = &ctf
  28944. }
  28945. // ActionForward returns the value of the "action_forward" field in the mutation.
  28946. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28947. v := m.action_forward
  28948. if v == nil {
  28949. return
  28950. }
  28951. return *v, true
  28952. }
  28953. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  28954. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28956. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28957. if !m.op.Is(OpUpdateOne) {
  28958. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28959. }
  28960. if m.id == nil || m.oldValue == nil {
  28961. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28962. }
  28963. oldValue, err := m.oldValue(ctx)
  28964. if err != nil {
  28965. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28966. }
  28967. return oldValue.ActionForward, nil
  28968. }
  28969. // ClearActionForward clears the value of the "action_forward" field.
  28970. func (m *SopNodeMutation) ClearActionForward() {
  28971. m.action_forward = nil
  28972. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  28973. }
  28974. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28975. func (m *SopNodeMutation) ActionForwardCleared() bool {
  28976. _, ok := m.clearedFields[sopnode.FieldActionForward]
  28977. return ok
  28978. }
  28979. // ResetActionForward resets all changes to the "action_forward" field.
  28980. func (m *SopNodeMutation) ResetActionForward() {
  28981. m.action_forward = nil
  28982. delete(m.clearedFields, sopnode.FieldActionForward)
  28983. }
  28984. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  28985. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  28986. m.sop_stage = &id
  28987. }
  28988. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  28989. func (m *SopNodeMutation) ClearSopStage() {
  28990. m.clearedsop_stage = true
  28991. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  28992. }
  28993. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  28994. func (m *SopNodeMutation) SopStageCleared() bool {
  28995. return m.clearedsop_stage
  28996. }
  28997. // SopStageID returns the "sop_stage" edge ID in the mutation.
  28998. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  28999. if m.sop_stage != nil {
  29000. return *m.sop_stage, true
  29001. }
  29002. return
  29003. }
  29004. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  29005. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29006. // SopStageID instead. It exists only for internal usage by the builders.
  29007. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  29008. if id := m.sop_stage; id != nil {
  29009. ids = append(ids, *id)
  29010. }
  29011. return
  29012. }
  29013. // ResetSopStage resets all changes to the "sop_stage" edge.
  29014. func (m *SopNodeMutation) ResetSopStage() {
  29015. m.sop_stage = nil
  29016. m.clearedsop_stage = false
  29017. }
  29018. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  29019. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  29020. if m.node_messages == nil {
  29021. m.node_messages = make(map[uint64]struct{})
  29022. }
  29023. for i := range ids {
  29024. m.node_messages[ids[i]] = struct{}{}
  29025. }
  29026. }
  29027. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  29028. func (m *SopNodeMutation) ClearNodeMessages() {
  29029. m.clearednode_messages = true
  29030. }
  29031. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  29032. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  29033. return m.clearednode_messages
  29034. }
  29035. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  29036. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  29037. if m.removednode_messages == nil {
  29038. m.removednode_messages = make(map[uint64]struct{})
  29039. }
  29040. for i := range ids {
  29041. delete(m.node_messages, ids[i])
  29042. m.removednode_messages[ids[i]] = struct{}{}
  29043. }
  29044. }
  29045. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  29046. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  29047. for id := range m.removednode_messages {
  29048. ids = append(ids, id)
  29049. }
  29050. return
  29051. }
  29052. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  29053. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  29054. for id := range m.node_messages {
  29055. ids = append(ids, id)
  29056. }
  29057. return
  29058. }
  29059. // ResetNodeMessages resets all changes to the "node_messages" edge.
  29060. func (m *SopNodeMutation) ResetNodeMessages() {
  29061. m.node_messages = nil
  29062. m.clearednode_messages = false
  29063. m.removednode_messages = nil
  29064. }
  29065. // Where appends a list predicates to the SopNodeMutation builder.
  29066. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  29067. m.predicates = append(m.predicates, ps...)
  29068. }
  29069. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  29070. // users can use type-assertion to append predicates that do not depend on any generated package.
  29071. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  29072. p := make([]predicate.SopNode, len(ps))
  29073. for i := range ps {
  29074. p[i] = ps[i]
  29075. }
  29076. m.Where(p...)
  29077. }
  29078. // Op returns the operation name.
  29079. func (m *SopNodeMutation) Op() Op {
  29080. return m.op
  29081. }
  29082. // SetOp allows setting the mutation operation.
  29083. func (m *SopNodeMutation) SetOp(op Op) {
  29084. m.op = op
  29085. }
  29086. // Type returns the node type of this mutation (SopNode).
  29087. func (m *SopNodeMutation) Type() string {
  29088. return m.typ
  29089. }
  29090. // Fields returns all fields that were changed during this mutation. Note that in
  29091. // order to get all numeric fields that were incremented/decremented, call
  29092. // AddedFields().
  29093. func (m *SopNodeMutation) Fields() []string {
  29094. fields := make([]string, 0, 15)
  29095. if m.created_at != nil {
  29096. fields = append(fields, sopnode.FieldCreatedAt)
  29097. }
  29098. if m.updated_at != nil {
  29099. fields = append(fields, sopnode.FieldUpdatedAt)
  29100. }
  29101. if m.status != nil {
  29102. fields = append(fields, sopnode.FieldStatus)
  29103. }
  29104. if m.deleted_at != nil {
  29105. fields = append(fields, sopnode.FieldDeletedAt)
  29106. }
  29107. if m.sop_stage != nil {
  29108. fields = append(fields, sopnode.FieldStageID)
  29109. }
  29110. if m.parent_id != nil {
  29111. fields = append(fields, sopnode.FieldParentID)
  29112. }
  29113. if m.name != nil {
  29114. fields = append(fields, sopnode.FieldName)
  29115. }
  29116. if m.condition_type != nil {
  29117. fields = append(fields, sopnode.FieldConditionType)
  29118. }
  29119. if m.condition_list != nil {
  29120. fields = append(fields, sopnode.FieldConditionList)
  29121. }
  29122. if m.no_reply_condition != nil {
  29123. fields = append(fields, sopnode.FieldNoReplyCondition)
  29124. }
  29125. if m.no_reply_unit != nil {
  29126. fields = append(fields, sopnode.FieldNoReplyUnit)
  29127. }
  29128. if m.action_message != nil {
  29129. fields = append(fields, sopnode.FieldActionMessage)
  29130. }
  29131. if m.action_label_add != nil {
  29132. fields = append(fields, sopnode.FieldActionLabelAdd)
  29133. }
  29134. if m.action_label_del != nil {
  29135. fields = append(fields, sopnode.FieldActionLabelDel)
  29136. }
  29137. if m.action_forward != nil {
  29138. fields = append(fields, sopnode.FieldActionForward)
  29139. }
  29140. return fields
  29141. }
  29142. // Field returns the value of a field with the given name. The second boolean
  29143. // return value indicates that this field was not set, or was not defined in the
  29144. // schema.
  29145. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  29146. switch name {
  29147. case sopnode.FieldCreatedAt:
  29148. return m.CreatedAt()
  29149. case sopnode.FieldUpdatedAt:
  29150. return m.UpdatedAt()
  29151. case sopnode.FieldStatus:
  29152. return m.Status()
  29153. case sopnode.FieldDeletedAt:
  29154. return m.DeletedAt()
  29155. case sopnode.FieldStageID:
  29156. return m.StageID()
  29157. case sopnode.FieldParentID:
  29158. return m.ParentID()
  29159. case sopnode.FieldName:
  29160. return m.Name()
  29161. case sopnode.FieldConditionType:
  29162. return m.ConditionType()
  29163. case sopnode.FieldConditionList:
  29164. return m.ConditionList()
  29165. case sopnode.FieldNoReplyCondition:
  29166. return m.NoReplyCondition()
  29167. case sopnode.FieldNoReplyUnit:
  29168. return m.NoReplyUnit()
  29169. case sopnode.FieldActionMessage:
  29170. return m.ActionMessage()
  29171. case sopnode.FieldActionLabelAdd:
  29172. return m.ActionLabelAdd()
  29173. case sopnode.FieldActionLabelDel:
  29174. return m.ActionLabelDel()
  29175. case sopnode.FieldActionForward:
  29176. return m.ActionForward()
  29177. }
  29178. return nil, false
  29179. }
  29180. // OldField returns the old value of the field from the database. An error is
  29181. // returned if the mutation operation is not UpdateOne, or the query to the
  29182. // database failed.
  29183. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29184. switch name {
  29185. case sopnode.FieldCreatedAt:
  29186. return m.OldCreatedAt(ctx)
  29187. case sopnode.FieldUpdatedAt:
  29188. return m.OldUpdatedAt(ctx)
  29189. case sopnode.FieldStatus:
  29190. return m.OldStatus(ctx)
  29191. case sopnode.FieldDeletedAt:
  29192. return m.OldDeletedAt(ctx)
  29193. case sopnode.FieldStageID:
  29194. return m.OldStageID(ctx)
  29195. case sopnode.FieldParentID:
  29196. return m.OldParentID(ctx)
  29197. case sopnode.FieldName:
  29198. return m.OldName(ctx)
  29199. case sopnode.FieldConditionType:
  29200. return m.OldConditionType(ctx)
  29201. case sopnode.FieldConditionList:
  29202. return m.OldConditionList(ctx)
  29203. case sopnode.FieldNoReplyCondition:
  29204. return m.OldNoReplyCondition(ctx)
  29205. case sopnode.FieldNoReplyUnit:
  29206. return m.OldNoReplyUnit(ctx)
  29207. case sopnode.FieldActionMessage:
  29208. return m.OldActionMessage(ctx)
  29209. case sopnode.FieldActionLabelAdd:
  29210. return m.OldActionLabelAdd(ctx)
  29211. case sopnode.FieldActionLabelDel:
  29212. return m.OldActionLabelDel(ctx)
  29213. case sopnode.FieldActionForward:
  29214. return m.OldActionForward(ctx)
  29215. }
  29216. return nil, fmt.Errorf("unknown SopNode field %s", name)
  29217. }
  29218. // SetField sets the value of a field with the given name. It returns an error if
  29219. // the field is not defined in the schema, or if the type mismatched the field
  29220. // type.
  29221. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  29222. switch name {
  29223. case sopnode.FieldCreatedAt:
  29224. v, ok := value.(time.Time)
  29225. if !ok {
  29226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29227. }
  29228. m.SetCreatedAt(v)
  29229. return nil
  29230. case sopnode.FieldUpdatedAt:
  29231. v, ok := value.(time.Time)
  29232. if !ok {
  29233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29234. }
  29235. m.SetUpdatedAt(v)
  29236. return nil
  29237. case sopnode.FieldStatus:
  29238. v, ok := value.(uint8)
  29239. if !ok {
  29240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29241. }
  29242. m.SetStatus(v)
  29243. return nil
  29244. case sopnode.FieldDeletedAt:
  29245. v, ok := value.(time.Time)
  29246. if !ok {
  29247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29248. }
  29249. m.SetDeletedAt(v)
  29250. return nil
  29251. case sopnode.FieldStageID:
  29252. v, ok := value.(uint64)
  29253. if !ok {
  29254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29255. }
  29256. m.SetStageID(v)
  29257. return nil
  29258. case sopnode.FieldParentID:
  29259. v, ok := value.(uint64)
  29260. if !ok {
  29261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29262. }
  29263. m.SetParentID(v)
  29264. return nil
  29265. case sopnode.FieldName:
  29266. v, ok := value.(string)
  29267. if !ok {
  29268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29269. }
  29270. m.SetName(v)
  29271. return nil
  29272. case sopnode.FieldConditionType:
  29273. v, ok := value.(int)
  29274. if !ok {
  29275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29276. }
  29277. m.SetConditionType(v)
  29278. return nil
  29279. case sopnode.FieldConditionList:
  29280. v, ok := value.([]string)
  29281. if !ok {
  29282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29283. }
  29284. m.SetConditionList(v)
  29285. return nil
  29286. case sopnode.FieldNoReplyCondition:
  29287. v, ok := value.(uint64)
  29288. if !ok {
  29289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29290. }
  29291. m.SetNoReplyCondition(v)
  29292. return nil
  29293. case sopnode.FieldNoReplyUnit:
  29294. v, ok := value.(string)
  29295. if !ok {
  29296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29297. }
  29298. m.SetNoReplyUnit(v)
  29299. return nil
  29300. case sopnode.FieldActionMessage:
  29301. v, ok := value.([]custom_types.Action)
  29302. if !ok {
  29303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29304. }
  29305. m.SetActionMessage(v)
  29306. return nil
  29307. case sopnode.FieldActionLabelAdd:
  29308. v, ok := value.([]uint64)
  29309. if !ok {
  29310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29311. }
  29312. m.SetActionLabelAdd(v)
  29313. return nil
  29314. case sopnode.FieldActionLabelDel:
  29315. v, ok := value.([]uint64)
  29316. if !ok {
  29317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29318. }
  29319. m.SetActionLabelDel(v)
  29320. return nil
  29321. case sopnode.FieldActionForward:
  29322. v, ok := value.(*custom_types.ActionForward)
  29323. if !ok {
  29324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29325. }
  29326. m.SetActionForward(v)
  29327. return nil
  29328. }
  29329. return fmt.Errorf("unknown SopNode field %s", name)
  29330. }
  29331. // AddedFields returns all numeric fields that were incremented/decremented during
  29332. // this mutation.
  29333. func (m *SopNodeMutation) AddedFields() []string {
  29334. var fields []string
  29335. if m.addstatus != nil {
  29336. fields = append(fields, sopnode.FieldStatus)
  29337. }
  29338. if m.addparent_id != nil {
  29339. fields = append(fields, sopnode.FieldParentID)
  29340. }
  29341. if m.addcondition_type != nil {
  29342. fields = append(fields, sopnode.FieldConditionType)
  29343. }
  29344. if m.addno_reply_condition != nil {
  29345. fields = append(fields, sopnode.FieldNoReplyCondition)
  29346. }
  29347. return fields
  29348. }
  29349. // AddedField returns the numeric value that was incremented/decremented on a field
  29350. // with the given name. The second boolean return value indicates that this field
  29351. // was not set, or was not defined in the schema.
  29352. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  29353. switch name {
  29354. case sopnode.FieldStatus:
  29355. return m.AddedStatus()
  29356. case sopnode.FieldParentID:
  29357. return m.AddedParentID()
  29358. case sopnode.FieldConditionType:
  29359. return m.AddedConditionType()
  29360. case sopnode.FieldNoReplyCondition:
  29361. return m.AddedNoReplyCondition()
  29362. }
  29363. return nil, false
  29364. }
  29365. // AddField adds the value to the field with the given name. It returns an error if
  29366. // the field is not defined in the schema, or if the type mismatched the field
  29367. // type.
  29368. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  29369. switch name {
  29370. case sopnode.FieldStatus:
  29371. v, ok := value.(int8)
  29372. if !ok {
  29373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29374. }
  29375. m.AddStatus(v)
  29376. return nil
  29377. case sopnode.FieldParentID:
  29378. v, ok := value.(int64)
  29379. if !ok {
  29380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29381. }
  29382. m.AddParentID(v)
  29383. return nil
  29384. case sopnode.FieldConditionType:
  29385. v, ok := value.(int)
  29386. if !ok {
  29387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29388. }
  29389. m.AddConditionType(v)
  29390. return nil
  29391. case sopnode.FieldNoReplyCondition:
  29392. v, ok := value.(int64)
  29393. if !ok {
  29394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29395. }
  29396. m.AddNoReplyCondition(v)
  29397. return nil
  29398. }
  29399. return fmt.Errorf("unknown SopNode numeric field %s", name)
  29400. }
  29401. // ClearedFields returns all nullable fields that were cleared during this
  29402. // mutation.
  29403. func (m *SopNodeMutation) ClearedFields() []string {
  29404. var fields []string
  29405. if m.FieldCleared(sopnode.FieldStatus) {
  29406. fields = append(fields, sopnode.FieldStatus)
  29407. }
  29408. if m.FieldCleared(sopnode.FieldDeletedAt) {
  29409. fields = append(fields, sopnode.FieldDeletedAt)
  29410. }
  29411. if m.FieldCleared(sopnode.FieldConditionList) {
  29412. fields = append(fields, sopnode.FieldConditionList)
  29413. }
  29414. if m.FieldCleared(sopnode.FieldActionMessage) {
  29415. fields = append(fields, sopnode.FieldActionMessage)
  29416. }
  29417. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  29418. fields = append(fields, sopnode.FieldActionLabelAdd)
  29419. }
  29420. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  29421. fields = append(fields, sopnode.FieldActionLabelDel)
  29422. }
  29423. if m.FieldCleared(sopnode.FieldActionForward) {
  29424. fields = append(fields, sopnode.FieldActionForward)
  29425. }
  29426. return fields
  29427. }
  29428. // FieldCleared returns a boolean indicating if a field with the given name was
  29429. // cleared in this mutation.
  29430. func (m *SopNodeMutation) FieldCleared(name string) bool {
  29431. _, ok := m.clearedFields[name]
  29432. return ok
  29433. }
  29434. // ClearField clears the value of the field with the given name. It returns an
  29435. // error if the field is not defined in the schema.
  29436. func (m *SopNodeMutation) ClearField(name string) error {
  29437. switch name {
  29438. case sopnode.FieldStatus:
  29439. m.ClearStatus()
  29440. return nil
  29441. case sopnode.FieldDeletedAt:
  29442. m.ClearDeletedAt()
  29443. return nil
  29444. case sopnode.FieldConditionList:
  29445. m.ClearConditionList()
  29446. return nil
  29447. case sopnode.FieldActionMessage:
  29448. m.ClearActionMessage()
  29449. return nil
  29450. case sopnode.FieldActionLabelAdd:
  29451. m.ClearActionLabelAdd()
  29452. return nil
  29453. case sopnode.FieldActionLabelDel:
  29454. m.ClearActionLabelDel()
  29455. return nil
  29456. case sopnode.FieldActionForward:
  29457. m.ClearActionForward()
  29458. return nil
  29459. }
  29460. return fmt.Errorf("unknown SopNode nullable field %s", name)
  29461. }
  29462. // ResetField resets all changes in the mutation for the field with the given name.
  29463. // It returns an error if the field is not defined in the schema.
  29464. func (m *SopNodeMutation) ResetField(name string) error {
  29465. switch name {
  29466. case sopnode.FieldCreatedAt:
  29467. m.ResetCreatedAt()
  29468. return nil
  29469. case sopnode.FieldUpdatedAt:
  29470. m.ResetUpdatedAt()
  29471. return nil
  29472. case sopnode.FieldStatus:
  29473. m.ResetStatus()
  29474. return nil
  29475. case sopnode.FieldDeletedAt:
  29476. m.ResetDeletedAt()
  29477. return nil
  29478. case sopnode.FieldStageID:
  29479. m.ResetStageID()
  29480. return nil
  29481. case sopnode.FieldParentID:
  29482. m.ResetParentID()
  29483. return nil
  29484. case sopnode.FieldName:
  29485. m.ResetName()
  29486. return nil
  29487. case sopnode.FieldConditionType:
  29488. m.ResetConditionType()
  29489. return nil
  29490. case sopnode.FieldConditionList:
  29491. m.ResetConditionList()
  29492. return nil
  29493. case sopnode.FieldNoReplyCondition:
  29494. m.ResetNoReplyCondition()
  29495. return nil
  29496. case sopnode.FieldNoReplyUnit:
  29497. m.ResetNoReplyUnit()
  29498. return nil
  29499. case sopnode.FieldActionMessage:
  29500. m.ResetActionMessage()
  29501. return nil
  29502. case sopnode.FieldActionLabelAdd:
  29503. m.ResetActionLabelAdd()
  29504. return nil
  29505. case sopnode.FieldActionLabelDel:
  29506. m.ResetActionLabelDel()
  29507. return nil
  29508. case sopnode.FieldActionForward:
  29509. m.ResetActionForward()
  29510. return nil
  29511. }
  29512. return fmt.Errorf("unknown SopNode field %s", name)
  29513. }
  29514. // AddedEdges returns all edge names that were set/added in this mutation.
  29515. func (m *SopNodeMutation) AddedEdges() []string {
  29516. edges := make([]string, 0, 2)
  29517. if m.sop_stage != nil {
  29518. edges = append(edges, sopnode.EdgeSopStage)
  29519. }
  29520. if m.node_messages != nil {
  29521. edges = append(edges, sopnode.EdgeNodeMessages)
  29522. }
  29523. return edges
  29524. }
  29525. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29526. // name in this mutation.
  29527. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  29528. switch name {
  29529. case sopnode.EdgeSopStage:
  29530. if id := m.sop_stage; id != nil {
  29531. return []ent.Value{*id}
  29532. }
  29533. case sopnode.EdgeNodeMessages:
  29534. ids := make([]ent.Value, 0, len(m.node_messages))
  29535. for id := range m.node_messages {
  29536. ids = append(ids, id)
  29537. }
  29538. return ids
  29539. }
  29540. return nil
  29541. }
  29542. // RemovedEdges returns all edge names that were removed in this mutation.
  29543. func (m *SopNodeMutation) RemovedEdges() []string {
  29544. edges := make([]string, 0, 2)
  29545. if m.removednode_messages != nil {
  29546. edges = append(edges, sopnode.EdgeNodeMessages)
  29547. }
  29548. return edges
  29549. }
  29550. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29551. // the given name in this mutation.
  29552. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  29553. switch name {
  29554. case sopnode.EdgeNodeMessages:
  29555. ids := make([]ent.Value, 0, len(m.removednode_messages))
  29556. for id := range m.removednode_messages {
  29557. ids = append(ids, id)
  29558. }
  29559. return ids
  29560. }
  29561. return nil
  29562. }
  29563. // ClearedEdges returns all edge names that were cleared in this mutation.
  29564. func (m *SopNodeMutation) ClearedEdges() []string {
  29565. edges := make([]string, 0, 2)
  29566. if m.clearedsop_stage {
  29567. edges = append(edges, sopnode.EdgeSopStage)
  29568. }
  29569. if m.clearednode_messages {
  29570. edges = append(edges, sopnode.EdgeNodeMessages)
  29571. }
  29572. return edges
  29573. }
  29574. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29575. // was cleared in this mutation.
  29576. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  29577. switch name {
  29578. case sopnode.EdgeSopStage:
  29579. return m.clearedsop_stage
  29580. case sopnode.EdgeNodeMessages:
  29581. return m.clearednode_messages
  29582. }
  29583. return false
  29584. }
  29585. // ClearEdge clears the value of the edge with the given name. It returns an error
  29586. // if that edge is not defined in the schema.
  29587. func (m *SopNodeMutation) ClearEdge(name string) error {
  29588. switch name {
  29589. case sopnode.EdgeSopStage:
  29590. m.ClearSopStage()
  29591. return nil
  29592. }
  29593. return fmt.Errorf("unknown SopNode unique edge %s", name)
  29594. }
  29595. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29596. // It returns an error if the edge is not defined in the schema.
  29597. func (m *SopNodeMutation) ResetEdge(name string) error {
  29598. switch name {
  29599. case sopnode.EdgeSopStage:
  29600. m.ResetSopStage()
  29601. return nil
  29602. case sopnode.EdgeNodeMessages:
  29603. m.ResetNodeMessages()
  29604. return nil
  29605. }
  29606. return fmt.Errorf("unknown SopNode edge %s", name)
  29607. }
  29608. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  29609. type SopStageMutation struct {
  29610. config
  29611. op Op
  29612. typ string
  29613. id *uint64
  29614. created_at *time.Time
  29615. updated_at *time.Time
  29616. status *uint8
  29617. addstatus *int8
  29618. deleted_at *time.Time
  29619. name *string
  29620. condition_type *int
  29621. addcondition_type *int
  29622. condition_operator *int
  29623. addcondition_operator *int
  29624. condition_list *[]custom_types.Condition
  29625. appendcondition_list []custom_types.Condition
  29626. action_message *[]custom_types.Action
  29627. appendaction_message []custom_types.Action
  29628. action_label_add *[]uint64
  29629. appendaction_label_add []uint64
  29630. action_label_del *[]uint64
  29631. appendaction_label_del []uint64
  29632. action_forward **custom_types.ActionForward
  29633. index_sort *int
  29634. addindex_sort *int
  29635. clearedFields map[string]struct{}
  29636. sop_task *uint64
  29637. clearedsop_task bool
  29638. stage_nodes map[uint64]struct{}
  29639. removedstage_nodes map[uint64]struct{}
  29640. clearedstage_nodes bool
  29641. stage_messages map[uint64]struct{}
  29642. removedstage_messages map[uint64]struct{}
  29643. clearedstage_messages bool
  29644. done bool
  29645. oldValue func(context.Context) (*SopStage, error)
  29646. predicates []predicate.SopStage
  29647. }
  29648. var _ ent.Mutation = (*SopStageMutation)(nil)
  29649. // sopstageOption allows management of the mutation configuration using functional options.
  29650. type sopstageOption func(*SopStageMutation)
  29651. // newSopStageMutation creates new mutation for the SopStage entity.
  29652. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  29653. m := &SopStageMutation{
  29654. config: c,
  29655. op: op,
  29656. typ: TypeSopStage,
  29657. clearedFields: make(map[string]struct{}),
  29658. }
  29659. for _, opt := range opts {
  29660. opt(m)
  29661. }
  29662. return m
  29663. }
  29664. // withSopStageID sets the ID field of the mutation.
  29665. func withSopStageID(id uint64) sopstageOption {
  29666. return func(m *SopStageMutation) {
  29667. var (
  29668. err error
  29669. once sync.Once
  29670. value *SopStage
  29671. )
  29672. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  29673. once.Do(func() {
  29674. if m.done {
  29675. err = errors.New("querying old values post mutation is not allowed")
  29676. } else {
  29677. value, err = m.Client().SopStage.Get(ctx, id)
  29678. }
  29679. })
  29680. return value, err
  29681. }
  29682. m.id = &id
  29683. }
  29684. }
  29685. // withSopStage sets the old SopStage of the mutation.
  29686. func withSopStage(node *SopStage) sopstageOption {
  29687. return func(m *SopStageMutation) {
  29688. m.oldValue = func(context.Context) (*SopStage, error) {
  29689. return node, nil
  29690. }
  29691. m.id = &node.ID
  29692. }
  29693. }
  29694. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29695. // executed in a transaction (ent.Tx), a transactional client is returned.
  29696. func (m SopStageMutation) Client() *Client {
  29697. client := &Client{config: m.config}
  29698. client.init()
  29699. return client
  29700. }
  29701. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29702. // it returns an error otherwise.
  29703. func (m SopStageMutation) Tx() (*Tx, error) {
  29704. if _, ok := m.driver.(*txDriver); !ok {
  29705. return nil, errors.New("ent: mutation is not running in a transaction")
  29706. }
  29707. tx := &Tx{config: m.config}
  29708. tx.init()
  29709. return tx, nil
  29710. }
  29711. // SetID sets the value of the id field. Note that this
  29712. // operation is only accepted on creation of SopStage entities.
  29713. func (m *SopStageMutation) SetID(id uint64) {
  29714. m.id = &id
  29715. }
  29716. // ID returns the ID value in the mutation. Note that the ID is only available
  29717. // if it was provided to the builder or after it was returned from the database.
  29718. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  29719. if m.id == nil {
  29720. return
  29721. }
  29722. return *m.id, true
  29723. }
  29724. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29725. // That means, if the mutation is applied within a transaction with an isolation level such
  29726. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29727. // or updated by the mutation.
  29728. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  29729. switch {
  29730. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29731. id, exists := m.ID()
  29732. if exists {
  29733. return []uint64{id}, nil
  29734. }
  29735. fallthrough
  29736. case m.op.Is(OpUpdate | OpDelete):
  29737. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  29738. default:
  29739. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29740. }
  29741. }
  29742. // SetCreatedAt sets the "created_at" field.
  29743. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  29744. m.created_at = &t
  29745. }
  29746. // CreatedAt returns the value of the "created_at" field in the mutation.
  29747. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  29748. v := m.created_at
  29749. if v == nil {
  29750. return
  29751. }
  29752. return *v, true
  29753. }
  29754. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  29755. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29757. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29758. if !m.op.Is(OpUpdateOne) {
  29759. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29760. }
  29761. if m.id == nil || m.oldValue == nil {
  29762. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29763. }
  29764. oldValue, err := m.oldValue(ctx)
  29765. if err != nil {
  29766. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29767. }
  29768. return oldValue.CreatedAt, nil
  29769. }
  29770. // ResetCreatedAt resets all changes to the "created_at" field.
  29771. func (m *SopStageMutation) ResetCreatedAt() {
  29772. m.created_at = nil
  29773. }
  29774. // SetUpdatedAt sets the "updated_at" field.
  29775. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  29776. m.updated_at = &t
  29777. }
  29778. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29779. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  29780. v := m.updated_at
  29781. if v == nil {
  29782. return
  29783. }
  29784. return *v, true
  29785. }
  29786. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  29787. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29789. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29790. if !m.op.Is(OpUpdateOne) {
  29791. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29792. }
  29793. if m.id == nil || m.oldValue == nil {
  29794. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29795. }
  29796. oldValue, err := m.oldValue(ctx)
  29797. if err != nil {
  29798. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29799. }
  29800. return oldValue.UpdatedAt, nil
  29801. }
  29802. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29803. func (m *SopStageMutation) ResetUpdatedAt() {
  29804. m.updated_at = nil
  29805. }
  29806. // SetStatus sets the "status" field.
  29807. func (m *SopStageMutation) SetStatus(u uint8) {
  29808. m.status = &u
  29809. m.addstatus = nil
  29810. }
  29811. // Status returns the value of the "status" field in the mutation.
  29812. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  29813. v := m.status
  29814. if v == nil {
  29815. return
  29816. }
  29817. return *v, true
  29818. }
  29819. // OldStatus returns the old "status" field's value of the SopStage entity.
  29820. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29822. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29823. if !m.op.Is(OpUpdateOne) {
  29824. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29825. }
  29826. if m.id == nil || m.oldValue == nil {
  29827. return v, errors.New("OldStatus requires an ID field in the mutation")
  29828. }
  29829. oldValue, err := m.oldValue(ctx)
  29830. if err != nil {
  29831. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29832. }
  29833. return oldValue.Status, nil
  29834. }
  29835. // AddStatus adds u to the "status" field.
  29836. func (m *SopStageMutation) AddStatus(u int8) {
  29837. if m.addstatus != nil {
  29838. *m.addstatus += u
  29839. } else {
  29840. m.addstatus = &u
  29841. }
  29842. }
  29843. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29844. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  29845. v := m.addstatus
  29846. if v == nil {
  29847. return
  29848. }
  29849. return *v, true
  29850. }
  29851. // ClearStatus clears the value of the "status" field.
  29852. func (m *SopStageMutation) ClearStatus() {
  29853. m.status = nil
  29854. m.addstatus = nil
  29855. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  29856. }
  29857. // StatusCleared returns if the "status" field was cleared in this mutation.
  29858. func (m *SopStageMutation) StatusCleared() bool {
  29859. _, ok := m.clearedFields[sopstage.FieldStatus]
  29860. return ok
  29861. }
  29862. // ResetStatus resets all changes to the "status" field.
  29863. func (m *SopStageMutation) ResetStatus() {
  29864. m.status = nil
  29865. m.addstatus = nil
  29866. delete(m.clearedFields, sopstage.FieldStatus)
  29867. }
  29868. // SetDeletedAt sets the "deleted_at" field.
  29869. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  29870. m.deleted_at = &t
  29871. }
  29872. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29873. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  29874. v := m.deleted_at
  29875. if v == nil {
  29876. return
  29877. }
  29878. return *v, true
  29879. }
  29880. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  29881. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29883. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29884. if !m.op.Is(OpUpdateOne) {
  29885. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29886. }
  29887. if m.id == nil || m.oldValue == nil {
  29888. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29889. }
  29890. oldValue, err := m.oldValue(ctx)
  29891. if err != nil {
  29892. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29893. }
  29894. return oldValue.DeletedAt, nil
  29895. }
  29896. // ClearDeletedAt clears the value of the "deleted_at" field.
  29897. func (m *SopStageMutation) ClearDeletedAt() {
  29898. m.deleted_at = nil
  29899. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  29900. }
  29901. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29902. func (m *SopStageMutation) DeletedAtCleared() bool {
  29903. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  29904. return ok
  29905. }
  29906. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29907. func (m *SopStageMutation) ResetDeletedAt() {
  29908. m.deleted_at = nil
  29909. delete(m.clearedFields, sopstage.FieldDeletedAt)
  29910. }
  29911. // SetTaskID sets the "task_id" field.
  29912. func (m *SopStageMutation) SetTaskID(u uint64) {
  29913. m.sop_task = &u
  29914. }
  29915. // TaskID returns the value of the "task_id" field in the mutation.
  29916. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  29917. v := m.sop_task
  29918. if v == nil {
  29919. return
  29920. }
  29921. return *v, true
  29922. }
  29923. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  29924. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29926. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  29927. if !m.op.Is(OpUpdateOne) {
  29928. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  29929. }
  29930. if m.id == nil || m.oldValue == nil {
  29931. return v, errors.New("OldTaskID requires an ID field in the mutation")
  29932. }
  29933. oldValue, err := m.oldValue(ctx)
  29934. if err != nil {
  29935. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  29936. }
  29937. return oldValue.TaskID, nil
  29938. }
  29939. // ResetTaskID resets all changes to the "task_id" field.
  29940. func (m *SopStageMutation) ResetTaskID() {
  29941. m.sop_task = nil
  29942. }
  29943. // SetName sets the "name" field.
  29944. func (m *SopStageMutation) SetName(s string) {
  29945. m.name = &s
  29946. }
  29947. // Name returns the value of the "name" field in the mutation.
  29948. func (m *SopStageMutation) Name() (r string, exists bool) {
  29949. v := m.name
  29950. if v == nil {
  29951. return
  29952. }
  29953. return *v, true
  29954. }
  29955. // OldName returns the old "name" field's value of the SopStage entity.
  29956. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29958. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  29959. if !m.op.Is(OpUpdateOne) {
  29960. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29961. }
  29962. if m.id == nil || m.oldValue == nil {
  29963. return v, errors.New("OldName requires an ID field in the mutation")
  29964. }
  29965. oldValue, err := m.oldValue(ctx)
  29966. if err != nil {
  29967. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29968. }
  29969. return oldValue.Name, nil
  29970. }
  29971. // ResetName resets all changes to the "name" field.
  29972. func (m *SopStageMutation) ResetName() {
  29973. m.name = nil
  29974. }
  29975. // SetConditionType sets the "condition_type" field.
  29976. func (m *SopStageMutation) SetConditionType(i int) {
  29977. m.condition_type = &i
  29978. m.addcondition_type = nil
  29979. }
  29980. // ConditionType returns the value of the "condition_type" field in the mutation.
  29981. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  29982. v := m.condition_type
  29983. if v == nil {
  29984. return
  29985. }
  29986. return *v, true
  29987. }
  29988. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  29989. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29991. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  29992. if !m.op.Is(OpUpdateOne) {
  29993. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  29994. }
  29995. if m.id == nil || m.oldValue == nil {
  29996. return v, errors.New("OldConditionType requires an ID field in the mutation")
  29997. }
  29998. oldValue, err := m.oldValue(ctx)
  29999. if err != nil {
  30000. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  30001. }
  30002. return oldValue.ConditionType, nil
  30003. }
  30004. // AddConditionType adds i to the "condition_type" field.
  30005. func (m *SopStageMutation) AddConditionType(i int) {
  30006. if m.addcondition_type != nil {
  30007. *m.addcondition_type += i
  30008. } else {
  30009. m.addcondition_type = &i
  30010. }
  30011. }
  30012. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  30013. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  30014. v := m.addcondition_type
  30015. if v == nil {
  30016. return
  30017. }
  30018. return *v, true
  30019. }
  30020. // ResetConditionType resets all changes to the "condition_type" field.
  30021. func (m *SopStageMutation) ResetConditionType() {
  30022. m.condition_type = nil
  30023. m.addcondition_type = nil
  30024. }
  30025. // SetConditionOperator sets the "condition_operator" field.
  30026. func (m *SopStageMutation) SetConditionOperator(i int) {
  30027. m.condition_operator = &i
  30028. m.addcondition_operator = nil
  30029. }
  30030. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  30031. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  30032. v := m.condition_operator
  30033. if v == nil {
  30034. return
  30035. }
  30036. return *v, true
  30037. }
  30038. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  30039. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30041. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  30042. if !m.op.Is(OpUpdateOne) {
  30043. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  30044. }
  30045. if m.id == nil || m.oldValue == nil {
  30046. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  30047. }
  30048. oldValue, err := m.oldValue(ctx)
  30049. if err != nil {
  30050. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  30051. }
  30052. return oldValue.ConditionOperator, nil
  30053. }
  30054. // AddConditionOperator adds i to the "condition_operator" field.
  30055. func (m *SopStageMutation) AddConditionOperator(i int) {
  30056. if m.addcondition_operator != nil {
  30057. *m.addcondition_operator += i
  30058. } else {
  30059. m.addcondition_operator = &i
  30060. }
  30061. }
  30062. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  30063. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  30064. v := m.addcondition_operator
  30065. if v == nil {
  30066. return
  30067. }
  30068. return *v, true
  30069. }
  30070. // ResetConditionOperator resets all changes to the "condition_operator" field.
  30071. func (m *SopStageMutation) ResetConditionOperator() {
  30072. m.condition_operator = nil
  30073. m.addcondition_operator = nil
  30074. }
  30075. // SetConditionList sets the "condition_list" field.
  30076. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  30077. m.condition_list = &ct
  30078. m.appendcondition_list = nil
  30079. }
  30080. // ConditionList returns the value of the "condition_list" field in the mutation.
  30081. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  30082. v := m.condition_list
  30083. if v == nil {
  30084. return
  30085. }
  30086. return *v, true
  30087. }
  30088. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  30089. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30091. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  30092. if !m.op.Is(OpUpdateOne) {
  30093. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  30094. }
  30095. if m.id == nil || m.oldValue == nil {
  30096. return v, errors.New("OldConditionList requires an ID field in the mutation")
  30097. }
  30098. oldValue, err := m.oldValue(ctx)
  30099. if err != nil {
  30100. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  30101. }
  30102. return oldValue.ConditionList, nil
  30103. }
  30104. // AppendConditionList adds ct to the "condition_list" field.
  30105. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  30106. m.appendcondition_list = append(m.appendcondition_list, ct...)
  30107. }
  30108. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  30109. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  30110. if len(m.appendcondition_list) == 0 {
  30111. return nil, false
  30112. }
  30113. return m.appendcondition_list, true
  30114. }
  30115. // ResetConditionList resets all changes to the "condition_list" field.
  30116. func (m *SopStageMutation) ResetConditionList() {
  30117. m.condition_list = nil
  30118. m.appendcondition_list = nil
  30119. }
  30120. // SetActionMessage sets the "action_message" field.
  30121. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  30122. m.action_message = &ct
  30123. m.appendaction_message = nil
  30124. }
  30125. // ActionMessage returns the value of the "action_message" field in the mutation.
  30126. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  30127. v := m.action_message
  30128. if v == nil {
  30129. return
  30130. }
  30131. return *v, true
  30132. }
  30133. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  30134. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30136. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  30137. if !m.op.Is(OpUpdateOne) {
  30138. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  30139. }
  30140. if m.id == nil || m.oldValue == nil {
  30141. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  30142. }
  30143. oldValue, err := m.oldValue(ctx)
  30144. if err != nil {
  30145. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  30146. }
  30147. return oldValue.ActionMessage, nil
  30148. }
  30149. // AppendActionMessage adds ct to the "action_message" field.
  30150. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  30151. m.appendaction_message = append(m.appendaction_message, ct...)
  30152. }
  30153. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  30154. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  30155. if len(m.appendaction_message) == 0 {
  30156. return nil, false
  30157. }
  30158. return m.appendaction_message, true
  30159. }
  30160. // ClearActionMessage clears the value of the "action_message" field.
  30161. func (m *SopStageMutation) ClearActionMessage() {
  30162. m.action_message = nil
  30163. m.appendaction_message = nil
  30164. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  30165. }
  30166. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  30167. func (m *SopStageMutation) ActionMessageCleared() bool {
  30168. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  30169. return ok
  30170. }
  30171. // ResetActionMessage resets all changes to the "action_message" field.
  30172. func (m *SopStageMutation) ResetActionMessage() {
  30173. m.action_message = nil
  30174. m.appendaction_message = nil
  30175. delete(m.clearedFields, sopstage.FieldActionMessage)
  30176. }
  30177. // SetActionLabelAdd sets the "action_label_add" field.
  30178. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  30179. m.action_label_add = &u
  30180. m.appendaction_label_add = nil
  30181. }
  30182. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  30183. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  30184. v := m.action_label_add
  30185. if v == nil {
  30186. return
  30187. }
  30188. return *v, true
  30189. }
  30190. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  30191. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30193. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  30194. if !m.op.Is(OpUpdateOne) {
  30195. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  30196. }
  30197. if m.id == nil || m.oldValue == nil {
  30198. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  30199. }
  30200. oldValue, err := m.oldValue(ctx)
  30201. if err != nil {
  30202. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  30203. }
  30204. return oldValue.ActionLabelAdd, nil
  30205. }
  30206. // AppendActionLabelAdd adds u to the "action_label_add" field.
  30207. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  30208. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  30209. }
  30210. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  30211. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  30212. if len(m.appendaction_label_add) == 0 {
  30213. return nil, false
  30214. }
  30215. return m.appendaction_label_add, true
  30216. }
  30217. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  30218. func (m *SopStageMutation) ClearActionLabelAdd() {
  30219. m.action_label_add = nil
  30220. m.appendaction_label_add = nil
  30221. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  30222. }
  30223. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  30224. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  30225. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  30226. return ok
  30227. }
  30228. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  30229. func (m *SopStageMutation) ResetActionLabelAdd() {
  30230. m.action_label_add = nil
  30231. m.appendaction_label_add = nil
  30232. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  30233. }
  30234. // SetActionLabelDel sets the "action_label_del" field.
  30235. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  30236. m.action_label_del = &u
  30237. m.appendaction_label_del = nil
  30238. }
  30239. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  30240. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  30241. v := m.action_label_del
  30242. if v == nil {
  30243. return
  30244. }
  30245. return *v, true
  30246. }
  30247. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  30248. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30250. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  30251. if !m.op.Is(OpUpdateOne) {
  30252. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  30253. }
  30254. if m.id == nil || m.oldValue == nil {
  30255. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  30256. }
  30257. oldValue, err := m.oldValue(ctx)
  30258. if err != nil {
  30259. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  30260. }
  30261. return oldValue.ActionLabelDel, nil
  30262. }
  30263. // AppendActionLabelDel adds u to the "action_label_del" field.
  30264. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  30265. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  30266. }
  30267. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  30268. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  30269. if len(m.appendaction_label_del) == 0 {
  30270. return nil, false
  30271. }
  30272. return m.appendaction_label_del, true
  30273. }
  30274. // ClearActionLabelDel clears the value of the "action_label_del" field.
  30275. func (m *SopStageMutation) ClearActionLabelDel() {
  30276. m.action_label_del = nil
  30277. m.appendaction_label_del = nil
  30278. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  30279. }
  30280. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  30281. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  30282. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  30283. return ok
  30284. }
  30285. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  30286. func (m *SopStageMutation) ResetActionLabelDel() {
  30287. m.action_label_del = nil
  30288. m.appendaction_label_del = nil
  30289. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  30290. }
  30291. // SetActionForward sets the "action_forward" field.
  30292. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  30293. m.action_forward = &ctf
  30294. }
  30295. // ActionForward returns the value of the "action_forward" field in the mutation.
  30296. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  30297. v := m.action_forward
  30298. if v == nil {
  30299. return
  30300. }
  30301. return *v, true
  30302. }
  30303. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  30304. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30306. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  30307. if !m.op.Is(OpUpdateOne) {
  30308. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  30309. }
  30310. if m.id == nil || m.oldValue == nil {
  30311. return v, errors.New("OldActionForward requires an ID field in the mutation")
  30312. }
  30313. oldValue, err := m.oldValue(ctx)
  30314. if err != nil {
  30315. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  30316. }
  30317. return oldValue.ActionForward, nil
  30318. }
  30319. // ClearActionForward clears the value of the "action_forward" field.
  30320. func (m *SopStageMutation) ClearActionForward() {
  30321. m.action_forward = nil
  30322. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  30323. }
  30324. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  30325. func (m *SopStageMutation) ActionForwardCleared() bool {
  30326. _, ok := m.clearedFields[sopstage.FieldActionForward]
  30327. return ok
  30328. }
  30329. // ResetActionForward resets all changes to the "action_forward" field.
  30330. func (m *SopStageMutation) ResetActionForward() {
  30331. m.action_forward = nil
  30332. delete(m.clearedFields, sopstage.FieldActionForward)
  30333. }
  30334. // SetIndexSort sets the "index_sort" field.
  30335. func (m *SopStageMutation) SetIndexSort(i int) {
  30336. m.index_sort = &i
  30337. m.addindex_sort = nil
  30338. }
  30339. // IndexSort returns the value of the "index_sort" field in the mutation.
  30340. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  30341. v := m.index_sort
  30342. if v == nil {
  30343. return
  30344. }
  30345. return *v, true
  30346. }
  30347. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  30348. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30350. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  30351. if !m.op.Is(OpUpdateOne) {
  30352. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  30353. }
  30354. if m.id == nil || m.oldValue == nil {
  30355. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  30356. }
  30357. oldValue, err := m.oldValue(ctx)
  30358. if err != nil {
  30359. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  30360. }
  30361. return oldValue.IndexSort, nil
  30362. }
  30363. // AddIndexSort adds i to the "index_sort" field.
  30364. func (m *SopStageMutation) AddIndexSort(i int) {
  30365. if m.addindex_sort != nil {
  30366. *m.addindex_sort += i
  30367. } else {
  30368. m.addindex_sort = &i
  30369. }
  30370. }
  30371. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  30372. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  30373. v := m.addindex_sort
  30374. if v == nil {
  30375. return
  30376. }
  30377. return *v, true
  30378. }
  30379. // ClearIndexSort clears the value of the "index_sort" field.
  30380. func (m *SopStageMutation) ClearIndexSort() {
  30381. m.index_sort = nil
  30382. m.addindex_sort = nil
  30383. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  30384. }
  30385. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  30386. func (m *SopStageMutation) IndexSortCleared() bool {
  30387. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  30388. return ok
  30389. }
  30390. // ResetIndexSort resets all changes to the "index_sort" field.
  30391. func (m *SopStageMutation) ResetIndexSort() {
  30392. m.index_sort = nil
  30393. m.addindex_sort = nil
  30394. delete(m.clearedFields, sopstage.FieldIndexSort)
  30395. }
  30396. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  30397. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  30398. m.sop_task = &id
  30399. }
  30400. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  30401. func (m *SopStageMutation) ClearSopTask() {
  30402. m.clearedsop_task = true
  30403. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  30404. }
  30405. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  30406. func (m *SopStageMutation) SopTaskCleared() bool {
  30407. return m.clearedsop_task
  30408. }
  30409. // SopTaskID returns the "sop_task" edge ID in the mutation.
  30410. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  30411. if m.sop_task != nil {
  30412. return *m.sop_task, true
  30413. }
  30414. return
  30415. }
  30416. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  30417. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30418. // SopTaskID instead. It exists only for internal usage by the builders.
  30419. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  30420. if id := m.sop_task; id != nil {
  30421. ids = append(ids, *id)
  30422. }
  30423. return
  30424. }
  30425. // ResetSopTask resets all changes to the "sop_task" edge.
  30426. func (m *SopStageMutation) ResetSopTask() {
  30427. m.sop_task = nil
  30428. m.clearedsop_task = false
  30429. }
  30430. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  30431. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  30432. if m.stage_nodes == nil {
  30433. m.stage_nodes = make(map[uint64]struct{})
  30434. }
  30435. for i := range ids {
  30436. m.stage_nodes[ids[i]] = struct{}{}
  30437. }
  30438. }
  30439. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  30440. func (m *SopStageMutation) ClearStageNodes() {
  30441. m.clearedstage_nodes = true
  30442. }
  30443. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  30444. func (m *SopStageMutation) StageNodesCleared() bool {
  30445. return m.clearedstage_nodes
  30446. }
  30447. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  30448. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  30449. if m.removedstage_nodes == nil {
  30450. m.removedstage_nodes = make(map[uint64]struct{})
  30451. }
  30452. for i := range ids {
  30453. delete(m.stage_nodes, ids[i])
  30454. m.removedstage_nodes[ids[i]] = struct{}{}
  30455. }
  30456. }
  30457. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  30458. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  30459. for id := range m.removedstage_nodes {
  30460. ids = append(ids, id)
  30461. }
  30462. return
  30463. }
  30464. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  30465. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  30466. for id := range m.stage_nodes {
  30467. ids = append(ids, id)
  30468. }
  30469. return
  30470. }
  30471. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  30472. func (m *SopStageMutation) ResetStageNodes() {
  30473. m.stage_nodes = nil
  30474. m.clearedstage_nodes = false
  30475. m.removedstage_nodes = nil
  30476. }
  30477. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  30478. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  30479. if m.stage_messages == nil {
  30480. m.stage_messages = make(map[uint64]struct{})
  30481. }
  30482. for i := range ids {
  30483. m.stage_messages[ids[i]] = struct{}{}
  30484. }
  30485. }
  30486. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  30487. func (m *SopStageMutation) ClearStageMessages() {
  30488. m.clearedstage_messages = true
  30489. }
  30490. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  30491. func (m *SopStageMutation) StageMessagesCleared() bool {
  30492. return m.clearedstage_messages
  30493. }
  30494. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  30495. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  30496. if m.removedstage_messages == nil {
  30497. m.removedstage_messages = make(map[uint64]struct{})
  30498. }
  30499. for i := range ids {
  30500. delete(m.stage_messages, ids[i])
  30501. m.removedstage_messages[ids[i]] = struct{}{}
  30502. }
  30503. }
  30504. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  30505. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  30506. for id := range m.removedstage_messages {
  30507. ids = append(ids, id)
  30508. }
  30509. return
  30510. }
  30511. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  30512. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  30513. for id := range m.stage_messages {
  30514. ids = append(ids, id)
  30515. }
  30516. return
  30517. }
  30518. // ResetStageMessages resets all changes to the "stage_messages" edge.
  30519. func (m *SopStageMutation) ResetStageMessages() {
  30520. m.stage_messages = nil
  30521. m.clearedstage_messages = false
  30522. m.removedstage_messages = nil
  30523. }
  30524. // Where appends a list predicates to the SopStageMutation builder.
  30525. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  30526. m.predicates = append(m.predicates, ps...)
  30527. }
  30528. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  30529. // users can use type-assertion to append predicates that do not depend on any generated package.
  30530. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  30531. p := make([]predicate.SopStage, len(ps))
  30532. for i := range ps {
  30533. p[i] = ps[i]
  30534. }
  30535. m.Where(p...)
  30536. }
  30537. // Op returns the operation name.
  30538. func (m *SopStageMutation) Op() Op {
  30539. return m.op
  30540. }
  30541. // SetOp allows setting the mutation operation.
  30542. func (m *SopStageMutation) SetOp(op Op) {
  30543. m.op = op
  30544. }
  30545. // Type returns the node type of this mutation (SopStage).
  30546. func (m *SopStageMutation) Type() string {
  30547. return m.typ
  30548. }
  30549. // Fields returns all fields that were changed during this mutation. Note that in
  30550. // order to get all numeric fields that were incremented/decremented, call
  30551. // AddedFields().
  30552. func (m *SopStageMutation) Fields() []string {
  30553. fields := make([]string, 0, 14)
  30554. if m.created_at != nil {
  30555. fields = append(fields, sopstage.FieldCreatedAt)
  30556. }
  30557. if m.updated_at != nil {
  30558. fields = append(fields, sopstage.FieldUpdatedAt)
  30559. }
  30560. if m.status != nil {
  30561. fields = append(fields, sopstage.FieldStatus)
  30562. }
  30563. if m.deleted_at != nil {
  30564. fields = append(fields, sopstage.FieldDeletedAt)
  30565. }
  30566. if m.sop_task != nil {
  30567. fields = append(fields, sopstage.FieldTaskID)
  30568. }
  30569. if m.name != nil {
  30570. fields = append(fields, sopstage.FieldName)
  30571. }
  30572. if m.condition_type != nil {
  30573. fields = append(fields, sopstage.FieldConditionType)
  30574. }
  30575. if m.condition_operator != nil {
  30576. fields = append(fields, sopstage.FieldConditionOperator)
  30577. }
  30578. if m.condition_list != nil {
  30579. fields = append(fields, sopstage.FieldConditionList)
  30580. }
  30581. if m.action_message != nil {
  30582. fields = append(fields, sopstage.FieldActionMessage)
  30583. }
  30584. if m.action_label_add != nil {
  30585. fields = append(fields, sopstage.FieldActionLabelAdd)
  30586. }
  30587. if m.action_label_del != nil {
  30588. fields = append(fields, sopstage.FieldActionLabelDel)
  30589. }
  30590. if m.action_forward != nil {
  30591. fields = append(fields, sopstage.FieldActionForward)
  30592. }
  30593. if m.index_sort != nil {
  30594. fields = append(fields, sopstage.FieldIndexSort)
  30595. }
  30596. return fields
  30597. }
  30598. // Field returns the value of a field with the given name. The second boolean
  30599. // return value indicates that this field was not set, or was not defined in the
  30600. // schema.
  30601. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  30602. switch name {
  30603. case sopstage.FieldCreatedAt:
  30604. return m.CreatedAt()
  30605. case sopstage.FieldUpdatedAt:
  30606. return m.UpdatedAt()
  30607. case sopstage.FieldStatus:
  30608. return m.Status()
  30609. case sopstage.FieldDeletedAt:
  30610. return m.DeletedAt()
  30611. case sopstage.FieldTaskID:
  30612. return m.TaskID()
  30613. case sopstage.FieldName:
  30614. return m.Name()
  30615. case sopstage.FieldConditionType:
  30616. return m.ConditionType()
  30617. case sopstage.FieldConditionOperator:
  30618. return m.ConditionOperator()
  30619. case sopstage.FieldConditionList:
  30620. return m.ConditionList()
  30621. case sopstage.FieldActionMessage:
  30622. return m.ActionMessage()
  30623. case sopstage.FieldActionLabelAdd:
  30624. return m.ActionLabelAdd()
  30625. case sopstage.FieldActionLabelDel:
  30626. return m.ActionLabelDel()
  30627. case sopstage.FieldActionForward:
  30628. return m.ActionForward()
  30629. case sopstage.FieldIndexSort:
  30630. return m.IndexSort()
  30631. }
  30632. return nil, false
  30633. }
  30634. // OldField returns the old value of the field from the database. An error is
  30635. // returned if the mutation operation is not UpdateOne, or the query to the
  30636. // database failed.
  30637. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30638. switch name {
  30639. case sopstage.FieldCreatedAt:
  30640. return m.OldCreatedAt(ctx)
  30641. case sopstage.FieldUpdatedAt:
  30642. return m.OldUpdatedAt(ctx)
  30643. case sopstage.FieldStatus:
  30644. return m.OldStatus(ctx)
  30645. case sopstage.FieldDeletedAt:
  30646. return m.OldDeletedAt(ctx)
  30647. case sopstage.FieldTaskID:
  30648. return m.OldTaskID(ctx)
  30649. case sopstage.FieldName:
  30650. return m.OldName(ctx)
  30651. case sopstage.FieldConditionType:
  30652. return m.OldConditionType(ctx)
  30653. case sopstage.FieldConditionOperator:
  30654. return m.OldConditionOperator(ctx)
  30655. case sopstage.FieldConditionList:
  30656. return m.OldConditionList(ctx)
  30657. case sopstage.FieldActionMessage:
  30658. return m.OldActionMessage(ctx)
  30659. case sopstage.FieldActionLabelAdd:
  30660. return m.OldActionLabelAdd(ctx)
  30661. case sopstage.FieldActionLabelDel:
  30662. return m.OldActionLabelDel(ctx)
  30663. case sopstage.FieldActionForward:
  30664. return m.OldActionForward(ctx)
  30665. case sopstage.FieldIndexSort:
  30666. return m.OldIndexSort(ctx)
  30667. }
  30668. return nil, fmt.Errorf("unknown SopStage field %s", name)
  30669. }
  30670. // SetField sets the value of a field with the given name. It returns an error if
  30671. // the field is not defined in the schema, or if the type mismatched the field
  30672. // type.
  30673. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  30674. switch name {
  30675. case sopstage.FieldCreatedAt:
  30676. v, ok := value.(time.Time)
  30677. if !ok {
  30678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30679. }
  30680. m.SetCreatedAt(v)
  30681. return nil
  30682. case sopstage.FieldUpdatedAt:
  30683. v, ok := value.(time.Time)
  30684. if !ok {
  30685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30686. }
  30687. m.SetUpdatedAt(v)
  30688. return nil
  30689. case sopstage.FieldStatus:
  30690. v, ok := value.(uint8)
  30691. if !ok {
  30692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30693. }
  30694. m.SetStatus(v)
  30695. return nil
  30696. case sopstage.FieldDeletedAt:
  30697. v, ok := value.(time.Time)
  30698. if !ok {
  30699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30700. }
  30701. m.SetDeletedAt(v)
  30702. return nil
  30703. case sopstage.FieldTaskID:
  30704. v, ok := value.(uint64)
  30705. if !ok {
  30706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30707. }
  30708. m.SetTaskID(v)
  30709. return nil
  30710. case sopstage.FieldName:
  30711. v, ok := value.(string)
  30712. if !ok {
  30713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30714. }
  30715. m.SetName(v)
  30716. return nil
  30717. case sopstage.FieldConditionType:
  30718. v, ok := value.(int)
  30719. if !ok {
  30720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30721. }
  30722. m.SetConditionType(v)
  30723. return nil
  30724. case sopstage.FieldConditionOperator:
  30725. v, ok := value.(int)
  30726. if !ok {
  30727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30728. }
  30729. m.SetConditionOperator(v)
  30730. return nil
  30731. case sopstage.FieldConditionList:
  30732. v, ok := value.([]custom_types.Condition)
  30733. if !ok {
  30734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30735. }
  30736. m.SetConditionList(v)
  30737. return nil
  30738. case sopstage.FieldActionMessage:
  30739. v, ok := value.([]custom_types.Action)
  30740. if !ok {
  30741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30742. }
  30743. m.SetActionMessage(v)
  30744. return nil
  30745. case sopstage.FieldActionLabelAdd:
  30746. v, ok := value.([]uint64)
  30747. if !ok {
  30748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30749. }
  30750. m.SetActionLabelAdd(v)
  30751. return nil
  30752. case sopstage.FieldActionLabelDel:
  30753. v, ok := value.([]uint64)
  30754. if !ok {
  30755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30756. }
  30757. m.SetActionLabelDel(v)
  30758. return nil
  30759. case sopstage.FieldActionForward:
  30760. v, ok := value.(*custom_types.ActionForward)
  30761. if !ok {
  30762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30763. }
  30764. m.SetActionForward(v)
  30765. return nil
  30766. case sopstage.FieldIndexSort:
  30767. v, ok := value.(int)
  30768. if !ok {
  30769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30770. }
  30771. m.SetIndexSort(v)
  30772. return nil
  30773. }
  30774. return fmt.Errorf("unknown SopStage field %s", name)
  30775. }
  30776. // AddedFields returns all numeric fields that were incremented/decremented during
  30777. // this mutation.
  30778. func (m *SopStageMutation) AddedFields() []string {
  30779. var fields []string
  30780. if m.addstatus != nil {
  30781. fields = append(fields, sopstage.FieldStatus)
  30782. }
  30783. if m.addcondition_type != nil {
  30784. fields = append(fields, sopstage.FieldConditionType)
  30785. }
  30786. if m.addcondition_operator != nil {
  30787. fields = append(fields, sopstage.FieldConditionOperator)
  30788. }
  30789. if m.addindex_sort != nil {
  30790. fields = append(fields, sopstage.FieldIndexSort)
  30791. }
  30792. return fields
  30793. }
  30794. // AddedField returns the numeric value that was incremented/decremented on a field
  30795. // with the given name. The second boolean return value indicates that this field
  30796. // was not set, or was not defined in the schema.
  30797. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  30798. switch name {
  30799. case sopstage.FieldStatus:
  30800. return m.AddedStatus()
  30801. case sopstage.FieldConditionType:
  30802. return m.AddedConditionType()
  30803. case sopstage.FieldConditionOperator:
  30804. return m.AddedConditionOperator()
  30805. case sopstage.FieldIndexSort:
  30806. return m.AddedIndexSort()
  30807. }
  30808. return nil, false
  30809. }
  30810. // AddField adds the value to the field with the given name. It returns an error if
  30811. // the field is not defined in the schema, or if the type mismatched the field
  30812. // type.
  30813. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  30814. switch name {
  30815. case sopstage.FieldStatus:
  30816. v, ok := value.(int8)
  30817. if !ok {
  30818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30819. }
  30820. m.AddStatus(v)
  30821. return nil
  30822. case sopstage.FieldConditionType:
  30823. v, ok := value.(int)
  30824. if !ok {
  30825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30826. }
  30827. m.AddConditionType(v)
  30828. return nil
  30829. case sopstage.FieldConditionOperator:
  30830. v, ok := value.(int)
  30831. if !ok {
  30832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30833. }
  30834. m.AddConditionOperator(v)
  30835. return nil
  30836. case sopstage.FieldIndexSort:
  30837. v, ok := value.(int)
  30838. if !ok {
  30839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30840. }
  30841. m.AddIndexSort(v)
  30842. return nil
  30843. }
  30844. return fmt.Errorf("unknown SopStage numeric field %s", name)
  30845. }
  30846. // ClearedFields returns all nullable fields that were cleared during this
  30847. // mutation.
  30848. func (m *SopStageMutation) ClearedFields() []string {
  30849. var fields []string
  30850. if m.FieldCleared(sopstage.FieldStatus) {
  30851. fields = append(fields, sopstage.FieldStatus)
  30852. }
  30853. if m.FieldCleared(sopstage.FieldDeletedAt) {
  30854. fields = append(fields, sopstage.FieldDeletedAt)
  30855. }
  30856. if m.FieldCleared(sopstage.FieldActionMessage) {
  30857. fields = append(fields, sopstage.FieldActionMessage)
  30858. }
  30859. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  30860. fields = append(fields, sopstage.FieldActionLabelAdd)
  30861. }
  30862. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  30863. fields = append(fields, sopstage.FieldActionLabelDel)
  30864. }
  30865. if m.FieldCleared(sopstage.FieldActionForward) {
  30866. fields = append(fields, sopstage.FieldActionForward)
  30867. }
  30868. if m.FieldCleared(sopstage.FieldIndexSort) {
  30869. fields = append(fields, sopstage.FieldIndexSort)
  30870. }
  30871. return fields
  30872. }
  30873. // FieldCleared returns a boolean indicating if a field with the given name was
  30874. // cleared in this mutation.
  30875. func (m *SopStageMutation) FieldCleared(name string) bool {
  30876. _, ok := m.clearedFields[name]
  30877. return ok
  30878. }
  30879. // ClearField clears the value of the field with the given name. It returns an
  30880. // error if the field is not defined in the schema.
  30881. func (m *SopStageMutation) ClearField(name string) error {
  30882. switch name {
  30883. case sopstage.FieldStatus:
  30884. m.ClearStatus()
  30885. return nil
  30886. case sopstage.FieldDeletedAt:
  30887. m.ClearDeletedAt()
  30888. return nil
  30889. case sopstage.FieldActionMessage:
  30890. m.ClearActionMessage()
  30891. return nil
  30892. case sopstage.FieldActionLabelAdd:
  30893. m.ClearActionLabelAdd()
  30894. return nil
  30895. case sopstage.FieldActionLabelDel:
  30896. m.ClearActionLabelDel()
  30897. return nil
  30898. case sopstage.FieldActionForward:
  30899. m.ClearActionForward()
  30900. return nil
  30901. case sopstage.FieldIndexSort:
  30902. m.ClearIndexSort()
  30903. return nil
  30904. }
  30905. return fmt.Errorf("unknown SopStage nullable field %s", name)
  30906. }
  30907. // ResetField resets all changes in the mutation for the field with the given name.
  30908. // It returns an error if the field is not defined in the schema.
  30909. func (m *SopStageMutation) ResetField(name string) error {
  30910. switch name {
  30911. case sopstage.FieldCreatedAt:
  30912. m.ResetCreatedAt()
  30913. return nil
  30914. case sopstage.FieldUpdatedAt:
  30915. m.ResetUpdatedAt()
  30916. return nil
  30917. case sopstage.FieldStatus:
  30918. m.ResetStatus()
  30919. return nil
  30920. case sopstage.FieldDeletedAt:
  30921. m.ResetDeletedAt()
  30922. return nil
  30923. case sopstage.FieldTaskID:
  30924. m.ResetTaskID()
  30925. return nil
  30926. case sopstage.FieldName:
  30927. m.ResetName()
  30928. return nil
  30929. case sopstage.FieldConditionType:
  30930. m.ResetConditionType()
  30931. return nil
  30932. case sopstage.FieldConditionOperator:
  30933. m.ResetConditionOperator()
  30934. return nil
  30935. case sopstage.FieldConditionList:
  30936. m.ResetConditionList()
  30937. return nil
  30938. case sopstage.FieldActionMessage:
  30939. m.ResetActionMessage()
  30940. return nil
  30941. case sopstage.FieldActionLabelAdd:
  30942. m.ResetActionLabelAdd()
  30943. return nil
  30944. case sopstage.FieldActionLabelDel:
  30945. m.ResetActionLabelDel()
  30946. return nil
  30947. case sopstage.FieldActionForward:
  30948. m.ResetActionForward()
  30949. return nil
  30950. case sopstage.FieldIndexSort:
  30951. m.ResetIndexSort()
  30952. return nil
  30953. }
  30954. return fmt.Errorf("unknown SopStage field %s", name)
  30955. }
  30956. // AddedEdges returns all edge names that were set/added in this mutation.
  30957. func (m *SopStageMutation) AddedEdges() []string {
  30958. edges := make([]string, 0, 3)
  30959. if m.sop_task != nil {
  30960. edges = append(edges, sopstage.EdgeSopTask)
  30961. }
  30962. if m.stage_nodes != nil {
  30963. edges = append(edges, sopstage.EdgeStageNodes)
  30964. }
  30965. if m.stage_messages != nil {
  30966. edges = append(edges, sopstage.EdgeStageMessages)
  30967. }
  30968. return edges
  30969. }
  30970. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30971. // name in this mutation.
  30972. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  30973. switch name {
  30974. case sopstage.EdgeSopTask:
  30975. if id := m.sop_task; id != nil {
  30976. return []ent.Value{*id}
  30977. }
  30978. case sopstage.EdgeStageNodes:
  30979. ids := make([]ent.Value, 0, len(m.stage_nodes))
  30980. for id := range m.stage_nodes {
  30981. ids = append(ids, id)
  30982. }
  30983. return ids
  30984. case sopstage.EdgeStageMessages:
  30985. ids := make([]ent.Value, 0, len(m.stage_messages))
  30986. for id := range m.stage_messages {
  30987. ids = append(ids, id)
  30988. }
  30989. return ids
  30990. }
  30991. return nil
  30992. }
  30993. // RemovedEdges returns all edge names that were removed in this mutation.
  30994. func (m *SopStageMutation) RemovedEdges() []string {
  30995. edges := make([]string, 0, 3)
  30996. if m.removedstage_nodes != nil {
  30997. edges = append(edges, sopstage.EdgeStageNodes)
  30998. }
  30999. if m.removedstage_messages != nil {
  31000. edges = append(edges, sopstage.EdgeStageMessages)
  31001. }
  31002. return edges
  31003. }
  31004. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31005. // the given name in this mutation.
  31006. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  31007. switch name {
  31008. case sopstage.EdgeStageNodes:
  31009. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  31010. for id := range m.removedstage_nodes {
  31011. ids = append(ids, id)
  31012. }
  31013. return ids
  31014. case sopstage.EdgeStageMessages:
  31015. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  31016. for id := range m.removedstage_messages {
  31017. ids = append(ids, id)
  31018. }
  31019. return ids
  31020. }
  31021. return nil
  31022. }
  31023. // ClearedEdges returns all edge names that were cleared in this mutation.
  31024. func (m *SopStageMutation) ClearedEdges() []string {
  31025. edges := make([]string, 0, 3)
  31026. if m.clearedsop_task {
  31027. edges = append(edges, sopstage.EdgeSopTask)
  31028. }
  31029. if m.clearedstage_nodes {
  31030. edges = append(edges, sopstage.EdgeStageNodes)
  31031. }
  31032. if m.clearedstage_messages {
  31033. edges = append(edges, sopstage.EdgeStageMessages)
  31034. }
  31035. return edges
  31036. }
  31037. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31038. // was cleared in this mutation.
  31039. func (m *SopStageMutation) EdgeCleared(name string) bool {
  31040. switch name {
  31041. case sopstage.EdgeSopTask:
  31042. return m.clearedsop_task
  31043. case sopstage.EdgeStageNodes:
  31044. return m.clearedstage_nodes
  31045. case sopstage.EdgeStageMessages:
  31046. return m.clearedstage_messages
  31047. }
  31048. return false
  31049. }
  31050. // ClearEdge clears the value of the edge with the given name. It returns an error
  31051. // if that edge is not defined in the schema.
  31052. func (m *SopStageMutation) ClearEdge(name string) error {
  31053. switch name {
  31054. case sopstage.EdgeSopTask:
  31055. m.ClearSopTask()
  31056. return nil
  31057. }
  31058. return fmt.Errorf("unknown SopStage unique edge %s", name)
  31059. }
  31060. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31061. // It returns an error if the edge is not defined in the schema.
  31062. func (m *SopStageMutation) ResetEdge(name string) error {
  31063. switch name {
  31064. case sopstage.EdgeSopTask:
  31065. m.ResetSopTask()
  31066. return nil
  31067. case sopstage.EdgeStageNodes:
  31068. m.ResetStageNodes()
  31069. return nil
  31070. case sopstage.EdgeStageMessages:
  31071. m.ResetStageMessages()
  31072. return nil
  31073. }
  31074. return fmt.Errorf("unknown SopStage edge %s", name)
  31075. }
  31076. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  31077. type SopTaskMutation struct {
  31078. config
  31079. op Op
  31080. typ string
  31081. id *uint64
  31082. created_at *time.Time
  31083. updated_at *time.Time
  31084. status *uint8
  31085. addstatus *int8
  31086. deleted_at *time.Time
  31087. name *string
  31088. bot_wxid_list *[]string
  31089. appendbot_wxid_list []string
  31090. _type *int
  31091. add_type *int
  31092. plan_start_time *time.Time
  31093. plan_end_time *time.Time
  31094. creator_id *string
  31095. organization_id *uint64
  31096. addorganization_id *int64
  31097. token *[]string
  31098. appendtoken []string
  31099. clearedFields map[string]struct{}
  31100. task_stages map[uint64]struct{}
  31101. removedtask_stages map[uint64]struct{}
  31102. clearedtask_stages bool
  31103. done bool
  31104. oldValue func(context.Context) (*SopTask, error)
  31105. predicates []predicate.SopTask
  31106. }
  31107. var _ ent.Mutation = (*SopTaskMutation)(nil)
  31108. // soptaskOption allows management of the mutation configuration using functional options.
  31109. type soptaskOption func(*SopTaskMutation)
  31110. // newSopTaskMutation creates new mutation for the SopTask entity.
  31111. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  31112. m := &SopTaskMutation{
  31113. config: c,
  31114. op: op,
  31115. typ: TypeSopTask,
  31116. clearedFields: make(map[string]struct{}),
  31117. }
  31118. for _, opt := range opts {
  31119. opt(m)
  31120. }
  31121. return m
  31122. }
  31123. // withSopTaskID sets the ID field of the mutation.
  31124. func withSopTaskID(id uint64) soptaskOption {
  31125. return func(m *SopTaskMutation) {
  31126. var (
  31127. err error
  31128. once sync.Once
  31129. value *SopTask
  31130. )
  31131. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  31132. once.Do(func() {
  31133. if m.done {
  31134. err = errors.New("querying old values post mutation is not allowed")
  31135. } else {
  31136. value, err = m.Client().SopTask.Get(ctx, id)
  31137. }
  31138. })
  31139. return value, err
  31140. }
  31141. m.id = &id
  31142. }
  31143. }
  31144. // withSopTask sets the old SopTask of the mutation.
  31145. func withSopTask(node *SopTask) soptaskOption {
  31146. return func(m *SopTaskMutation) {
  31147. m.oldValue = func(context.Context) (*SopTask, error) {
  31148. return node, nil
  31149. }
  31150. m.id = &node.ID
  31151. }
  31152. }
  31153. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31154. // executed in a transaction (ent.Tx), a transactional client is returned.
  31155. func (m SopTaskMutation) Client() *Client {
  31156. client := &Client{config: m.config}
  31157. client.init()
  31158. return client
  31159. }
  31160. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31161. // it returns an error otherwise.
  31162. func (m SopTaskMutation) Tx() (*Tx, error) {
  31163. if _, ok := m.driver.(*txDriver); !ok {
  31164. return nil, errors.New("ent: mutation is not running in a transaction")
  31165. }
  31166. tx := &Tx{config: m.config}
  31167. tx.init()
  31168. return tx, nil
  31169. }
  31170. // SetID sets the value of the id field. Note that this
  31171. // operation is only accepted on creation of SopTask entities.
  31172. func (m *SopTaskMutation) SetID(id uint64) {
  31173. m.id = &id
  31174. }
  31175. // ID returns the ID value in the mutation. Note that the ID is only available
  31176. // if it was provided to the builder or after it was returned from the database.
  31177. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  31178. if m.id == nil {
  31179. return
  31180. }
  31181. return *m.id, true
  31182. }
  31183. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31184. // That means, if the mutation is applied within a transaction with an isolation level such
  31185. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31186. // or updated by the mutation.
  31187. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  31188. switch {
  31189. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31190. id, exists := m.ID()
  31191. if exists {
  31192. return []uint64{id}, nil
  31193. }
  31194. fallthrough
  31195. case m.op.Is(OpUpdate | OpDelete):
  31196. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  31197. default:
  31198. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31199. }
  31200. }
  31201. // SetCreatedAt sets the "created_at" field.
  31202. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  31203. m.created_at = &t
  31204. }
  31205. // CreatedAt returns the value of the "created_at" field in the mutation.
  31206. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  31207. v := m.created_at
  31208. if v == nil {
  31209. return
  31210. }
  31211. return *v, true
  31212. }
  31213. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  31214. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31216. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31217. if !m.op.Is(OpUpdateOne) {
  31218. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31219. }
  31220. if m.id == nil || m.oldValue == nil {
  31221. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31222. }
  31223. oldValue, err := m.oldValue(ctx)
  31224. if err != nil {
  31225. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31226. }
  31227. return oldValue.CreatedAt, nil
  31228. }
  31229. // ResetCreatedAt resets all changes to the "created_at" field.
  31230. func (m *SopTaskMutation) ResetCreatedAt() {
  31231. m.created_at = nil
  31232. }
  31233. // SetUpdatedAt sets the "updated_at" field.
  31234. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  31235. m.updated_at = &t
  31236. }
  31237. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31238. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  31239. v := m.updated_at
  31240. if v == nil {
  31241. return
  31242. }
  31243. return *v, true
  31244. }
  31245. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  31246. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31248. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31249. if !m.op.Is(OpUpdateOne) {
  31250. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31251. }
  31252. if m.id == nil || m.oldValue == nil {
  31253. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31254. }
  31255. oldValue, err := m.oldValue(ctx)
  31256. if err != nil {
  31257. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31258. }
  31259. return oldValue.UpdatedAt, nil
  31260. }
  31261. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31262. func (m *SopTaskMutation) ResetUpdatedAt() {
  31263. m.updated_at = nil
  31264. }
  31265. // SetStatus sets the "status" field.
  31266. func (m *SopTaskMutation) SetStatus(u uint8) {
  31267. m.status = &u
  31268. m.addstatus = nil
  31269. }
  31270. // Status returns the value of the "status" field in the mutation.
  31271. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  31272. v := m.status
  31273. if v == nil {
  31274. return
  31275. }
  31276. return *v, true
  31277. }
  31278. // OldStatus returns the old "status" field's value of the SopTask entity.
  31279. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31281. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31282. if !m.op.Is(OpUpdateOne) {
  31283. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31284. }
  31285. if m.id == nil || m.oldValue == nil {
  31286. return v, errors.New("OldStatus requires an ID field in the mutation")
  31287. }
  31288. oldValue, err := m.oldValue(ctx)
  31289. if err != nil {
  31290. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31291. }
  31292. return oldValue.Status, nil
  31293. }
  31294. // AddStatus adds u to the "status" field.
  31295. func (m *SopTaskMutation) AddStatus(u int8) {
  31296. if m.addstatus != nil {
  31297. *m.addstatus += u
  31298. } else {
  31299. m.addstatus = &u
  31300. }
  31301. }
  31302. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31303. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  31304. v := m.addstatus
  31305. if v == nil {
  31306. return
  31307. }
  31308. return *v, true
  31309. }
  31310. // ClearStatus clears the value of the "status" field.
  31311. func (m *SopTaskMutation) ClearStatus() {
  31312. m.status = nil
  31313. m.addstatus = nil
  31314. m.clearedFields[soptask.FieldStatus] = struct{}{}
  31315. }
  31316. // StatusCleared returns if the "status" field was cleared in this mutation.
  31317. func (m *SopTaskMutation) StatusCleared() bool {
  31318. _, ok := m.clearedFields[soptask.FieldStatus]
  31319. return ok
  31320. }
  31321. // ResetStatus resets all changes to the "status" field.
  31322. func (m *SopTaskMutation) ResetStatus() {
  31323. m.status = nil
  31324. m.addstatus = nil
  31325. delete(m.clearedFields, soptask.FieldStatus)
  31326. }
  31327. // SetDeletedAt sets the "deleted_at" field.
  31328. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  31329. m.deleted_at = &t
  31330. }
  31331. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31332. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  31333. v := m.deleted_at
  31334. if v == nil {
  31335. return
  31336. }
  31337. return *v, true
  31338. }
  31339. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  31340. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31342. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31343. if !m.op.Is(OpUpdateOne) {
  31344. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31345. }
  31346. if m.id == nil || m.oldValue == nil {
  31347. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31348. }
  31349. oldValue, err := m.oldValue(ctx)
  31350. if err != nil {
  31351. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31352. }
  31353. return oldValue.DeletedAt, nil
  31354. }
  31355. // ClearDeletedAt clears the value of the "deleted_at" field.
  31356. func (m *SopTaskMutation) ClearDeletedAt() {
  31357. m.deleted_at = nil
  31358. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  31359. }
  31360. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31361. func (m *SopTaskMutation) DeletedAtCleared() bool {
  31362. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  31363. return ok
  31364. }
  31365. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31366. func (m *SopTaskMutation) ResetDeletedAt() {
  31367. m.deleted_at = nil
  31368. delete(m.clearedFields, soptask.FieldDeletedAt)
  31369. }
  31370. // SetName sets the "name" field.
  31371. func (m *SopTaskMutation) SetName(s string) {
  31372. m.name = &s
  31373. }
  31374. // Name returns the value of the "name" field in the mutation.
  31375. func (m *SopTaskMutation) Name() (r string, exists bool) {
  31376. v := m.name
  31377. if v == nil {
  31378. return
  31379. }
  31380. return *v, true
  31381. }
  31382. // OldName returns the old "name" field's value of the SopTask entity.
  31383. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31385. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  31386. if !m.op.Is(OpUpdateOne) {
  31387. return v, errors.New("OldName is only allowed on UpdateOne operations")
  31388. }
  31389. if m.id == nil || m.oldValue == nil {
  31390. return v, errors.New("OldName requires an ID field in the mutation")
  31391. }
  31392. oldValue, err := m.oldValue(ctx)
  31393. if err != nil {
  31394. return v, fmt.Errorf("querying old value for OldName: %w", err)
  31395. }
  31396. return oldValue.Name, nil
  31397. }
  31398. // ResetName resets all changes to the "name" field.
  31399. func (m *SopTaskMutation) ResetName() {
  31400. m.name = nil
  31401. }
  31402. // SetBotWxidList sets the "bot_wxid_list" field.
  31403. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  31404. m.bot_wxid_list = &s
  31405. m.appendbot_wxid_list = nil
  31406. }
  31407. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  31408. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  31409. v := m.bot_wxid_list
  31410. if v == nil {
  31411. return
  31412. }
  31413. return *v, true
  31414. }
  31415. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  31416. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31418. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  31419. if !m.op.Is(OpUpdateOne) {
  31420. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  31421. }
  31422. if m.id == nil || m.oldValue == nil {
  31423. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  31424. }
  31425. oldValue, err := m.oldValue(ctx)
  31426. if err != nil {
  31427. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  31428. }
  31429. return oldValue.BotWxidList, nil
  31430. }
  31431. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  31432. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  31433. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  31434. }
  31435. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  31436. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  31437. if len(m.appendbot_wxid_list) == 0 {
  31438. return nil, false
  31439. }
  31440. return m.appendbot_wxid_list, true
  31441. }
  31442. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  31443. func (m *SopTaskMutation) ClearBotWxidList() {
  31444. m.bot_wxid_list = nil
  31445. m.appendbot_wxid_list = nil
  31446. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  31447. }
  31448. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  31449. func (m *SopTaskMutation) BotWxidListCleared() bool {
  31450. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  31451. return ok
  31452. }
  31453. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  31454. func (m *SopTaskMutation) ResetBotWxidList() {
  31455. m.bot_wxid_list = nil
  31456. m.appendbot_wxid_list = nil
  31457. delete(m.clearedFields, soptask.FieldBotWxidList)
  31458. }
  31459. // SetType sets the "type" field.
  31460. func (m *SopTaskMutation) SetType(i int) {
  31461. m._type = &i
  31462. m.add_type = nil
  31463. }
  31464. // GetType returns the value of the "type" field in the mutation.
  31465. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  31466. v := m._type
  31467. if v == nil {
  31468. return
  31469. }
  31470. return *v, true
  31471. }
  31472. // OldType returns the old "type" field's value of the SopTask entity.
  31473. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31475. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  31476. if !m.op.Is(OpUpdateOne) {
  31477. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31478. }
  31479. if m.id == nil || m.oldValue == nil {
  31480. return v, errors.New("OldType requires an ID field in the mutation")
  31481. }
  31482. oldValue, err := m.oldValue(ctx)
  31483. if err != nil {
  31484. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31485. }
  31486. return oldValue.Type, nil
  31487. }
  31488. // AddType adds i to the "type" field.
  31489. func (m *SopTaskMutation) AddType(i int) {
  31490. if m.add_type != nil {
  31491. *m.add_type += i
  31492. } else {
  31493. m.add_type = &i
  31494. }
  31495. }
  31496. // AddedType returns the value that was added to the "type" field in this mutation.
  31497. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  31498. v := m.add_type
  31499. if v == nil {
  31500. return
  31501. }
  31502. return *v, true
  31503. }
  31504. // ResetType resets all changes to the "type" field.
  31505. func (m *SopTaskMutation) ResetType() {
  31506. m._type = nil
  31507. m.add_type = nil
  31508. }
  31509. // SetPlanStartTime sets the "plan_start_time" field.
  31510. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  31511. m.plan_start_time = &t
  31512. }
  31513. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  31514. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  31515. v := m.plan_start_time
  31516. if v == nil {
  31517. return
  31518. }
  31519. return *v, true
  31520. }
  31521. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  31522. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31524. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  31525. if !m.op.Is(OpUpdateOne) {
  31526. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  31527. }
  31528. if m.id == nil || m.oldValue == nil {
  31529. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  31530. }
  31531. oldValue, err := m.oldValue(ctx)
  31532. if err != nil {
  31533. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  31534. }
  31535. return oldValue.PlanStartTime, nil
  31536. }
  31537. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  31538. func (m *SopTaskMutation) ClearPlanStartTime() {
  31539. m.plan_start_time = nil
  31540. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  31541. }
  31542. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  31543. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  31544. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  31545. return ok
  31546. }
  31547. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  31548. func (m *SopTaskMutation) ResetPlanStartTime() {
  31549. m.plan_start_time = nil
  31550. delete(m.clearedFields, soptask.FieldPlanStartTime)
  31551. }
  31552. // SetPlanEndTime sets the "plan_end_time" field.
  31553. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  31554. m.plan_end_time = &t
  31555. }
  31556. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  31557. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  31558. v := m.plan_end_time
  31559. if v == nil {
  31560. return
  31561. }
  31562. return *v, true
  31563. }
  31564. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  31565. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31567. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  31568. if !m.op.Is(OpUpdateOne) {
  31569. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  31570. }
  31571. if m.id == nil || m.oldValue == nil {
  31572. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  31573. }
  31574. oldValue, err := m.oldValue(ctx)
  31575. if err != nil {
  31576. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  31577. }
  31578. return oldValue.PlanEndTime, nil
  31579. }
  31580. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  31581. func (m *SopTaskMutation) ClearPlanEndTime() {
  31582. m.plan_end_time = nil
  31583. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  31584. }
  31585. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  31586. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  31587. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  31588. return ok
  31589. }
  31590. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  31591. func (m *SopTaskMutation) ResetPlanEndTime() {
  31592. m.plan_end_time = nil
  31593. delete(m.clearedFields, soptask.FieldPlanEndTime)
  31594. }
  31595. // SetCreatorID sets the "creator_id" field.
  31596. func (m *SopTaskMutation) SetCreatorID(s string) {
  31597. m.creator_id = &s
  31598. }
  31599. // CreatorID returns the value of the "creator_id" field in the mutation.
  31600. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  31601. v := m.creator_id
  31602. if v == nil {
  31603. return
  31604. }
  31605. return *v, true
  31606. }
  31607. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  31608. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31610. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  31611. if !m.op.Is(OpUpdateOne) {
  31612. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  31613. }
  31614. if m.id == nil || m.oldValue == nil {
  31615. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  31616. }
  31617. oldValue, err := m.oldValue(ctx)
  31618. if err != nil {
  31619. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  31620. }
  31621. return oldValue.CreatorID, nil
  31622. }
  31623. // ClearCreatorID clears the value of the "creator_id" field.
  31624. func (m *SopTaskMutation) ClearCreatorID() {
  31625. m.creator_id = nil
  31626. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  31627. }
  31628. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  31629. func (m *SopTaskMutation) CreatorIDCleared() bool {
  31630. _, ok := m.clearedFields[soptask.FieldCreatorID]
  31631. return ok
  31632. }
  31633. // ResetCreatorID resets all changes to the "creator_id" field.
  31634. func (m *SopTaskMutation) ResetCreatorID() {
  31635. m.creator_id = nil
  31636. delete(m.clearedFields, soptask.FieldCreatorID)
  31637. }
  31638. // SetOrganizationID sets the "organization_id" field.
  31639. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  31640. m.organization_id = &u
  31641. m.addorganization_id = nil
  31642. }
  31643. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31644. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  31645. v := m.organization_id
  31646. if v == nil {
  31647. return
  31648. }
  31649. return *v, true
  31650. }
  31651. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  31652. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31654. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31655. if !m.op.Is(OpUpdateOne) {
  31656. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31657. }
  31658. if m.id == nil || m.oldValue == nil {
  31659. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31660. }
  31661. oldValue, err := m.oldValue(ctx)
  31662. if err != nil {
  31663. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31664. }
  31665. return oldValue.OrganizationID, nil
  31666. }
  31667. // AddOrganizationID adds u to the "organization_id" field.
  31668. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  31669. if m.addorganization_id != nil {
  31670. *m.addorganization_id += u
  31671. } else {
  31672. m.addorganization_id = &u
  31673. }
  31674. }
  31675. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31676. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  31677. v := m.addorganization_id
  31678. if v == nil {
  31679. return
  31680. }
  31681. return *v, true
  31682. }
  31683. // ClearOrganizationID clears the value of the "organization_id" field.
  31684. func (m *SopTaskMutation) ClearOrganizationID() {
  31685. m.organization_id = nil
  31686. m.addorganization_id = nil
  31687. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  31688. }
  31689. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31690. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  31691. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  31692. return ok
  31693. }
  31694. // ResetOrganizationID resets all changes to the "organization_id" field.
  31695. func (m *SopTaskMutation) ResetOrganizationID() {
  31696. m.organization_id = nil
  31697. m.addorganization_id = nil
  31698. delete(m.clearedFields, soptask.FieldOrganizationID)
  31699. }
  31700. // SetToken sets the "token" field.
  31701. func (m *SopTaskMutation) SetToken(s []string) {
  31702. m.token = &s
  31703. m.appendtoken = nil
  31704. }
  31705. // Token returns the value of the "token" field in the mutation.
  31706. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  31707. v := m.token
  31708. if v == nil {
  31709. return
  31710. }
  31711. return *v, true
  31712. }
  31713. // OldToken returns the old "token" field's value of the SopTask entity.
  31714. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31716. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  31717. if !m.op.Is(OpUpdateOne) {
  31718. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31719. }
  31720. if m.id == nil || m.oldValue == nil {
  31721. return v, errors.New("OldToken requires an ID field in the mutation")
  31722. }
  31723. oldValue, err := m.oldValue(ctx)
  31724. if err != nil {
  31725. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31726. }
  31727. return oldValue.Token, nil
  31728. }
  31729. // AppendToken adds s to the "token" field.
  31730. func (m *SopTaskMutation) AppendToken(s []string) {
  31731. m.appendtoken = append(m.appendtoken, s...)
  31732. }
  31733. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  31734. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  31735. if len(m.appendtoken) == 0 {
  31736. return nil, false
  31737. }
  31738. return m.appendtoken, true
  31739. }
  31740. // ClearToken clears the value of the "token" field.
  31741. func (m *SopTaskMutation) ClearToken() {
  31742. m.token = nil
  31743. m.appendtoken = nil
  31744. m.clearedFields[soptask.FieldToken] = struct{}{}
  31745. }
  31746. // TokenCleared returns if the "token" field was cleared in this mutation.
  31747. func (m *SopTaskMutation) TokenCleared() bool {
  31748. _, ok := m.clearedFields[soptask.FieldToken]
  31749. return ok
  31750. }
  31751. // ResetToken resets all changes to the "token" field.
  31752. func (m *SopTaskMutation) ResetToken() {
  31753. m.token = nil
  31754. m.appendtoken = nil
  31755. delete(m.clearedFields, soptask.FieldToken)
  31756. }
  31757. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  31758. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  31759. if m.task_stages == nil {
  31760. m.task_stages = make(map[uint64]struct{})
  31761. }
  31762. for i := range ids {
  31763. m.task_stages[ids[i]] = struct{}{}
  31764. }
  31765. }
  31766. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  31767. func (m *SopTaskMutation) ClearTaskStages() {
  31768. m.clearedtask_stages = true
  31769. }
  31770. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  31771. func (m *SopTaskMutation) TaskStagesCleared() bool {
  31772. return m.clearedtask_stages
  31773. }
  31774. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  31775. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  31776. if m.removedtask_stages == nil {
  31777. m.removedtask_stages = make(map[uint64]struct{})
  31778. }
  31779. for i := range ids {
  31780. delete(m.task_stages, ids[i])
  31781. m.removedtask_stages[ids[i]] = struct{}{}
  31782. }
  31783. }
  31784. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  31785. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  31786. for id := range m.removedtask_stages {
  31787. ids = append(ids, id)
  31788. }
  31789. return
  31790. }
  31791. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  31792. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  31793. for id := range m.task_stages {
  31794. ids = append(ids, id)
  31795. }
  31796. return
  31797. }
  31798. // ResetTaskStages resets all changes to the "task_stages" edge.
  31799. func (m *SopTaskMutation) ResetTaskStages() {
  31800. m.task_stages = nil
  31801. m.clearedtask_stages = false
  31802. m.removedtask_stages = nil
  31803. }
  31804. // Where appends a list predicates to the SopTaskMutation builder.
  31805. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  31806. m.predicates = append(m.predicates, ps...)
  31807. }
  31808. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  31809. // users can use type-assertion to append predicates that do not depend on any generated package.
  31810. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  31811. p := make([]predicate.SopTask, len(ps))
  31812. for i := range ps {
  31813. p[i] = ps[i]
  31814. }
  31815. m.Where(p...)
  31816. }
  31817. // Op returns the operation name.
  31818. func (m *SopTaskMutation) Op() Op {
  31819. return m.op
  31820. }
  31821. // SetOp allows setting the mutation operation.
  31822. func (m *SopTaskMutation) SetOp(op Op) {
  31823. m.op = op
  31824. }
  31825. // Type returns the node type of this mutation (SopTask).
  31826. func (m *SopTaskMutation) Type() string {
  31827. return m.typ
  31828. }
  31829. // Fields returns all fields that were changed during this mutation. Note that in
  31830. // order to get all numeric fields that were incremented/decremented, call
  31831. // AddedFields().
  31832. func (m *SopTaskMutation) Fields() []string {
  31833. fields := make([]string, 0, 12)
  31834. if m.created_at != nil {
  31835. fields = append(fields, soptask.FieldCreatedAt)
  31836. }
  31837. if m.updated_at != nil {
  31838. fields = append(fields, soptask.FieldUpdatedAt)
  31839. }
  31840. if m.status != nil {
  31841. fields = append(fields, soptask.FieldStatus)
  31842. }
  31843. if m.deleted_at != nil {
  31844. fields = append(fields, soptask.FieldDeletedAt)
  31845. }
  31846. if m.name != nil {
  31847. fields = append(fields, soptask.FieldName)
  31848. }
  31849. if m.bot_wxid_list != nil {
  31850. fields = append(fields, soptask.FieldBotWxidList)
  31851. }
  31852. if m._type != nil {
  31853. fields = append(fields, soptask.FieldType)
  31854. }
  31855. if m.plan_start_time != nil {
  31856. fields = append(fields, soptask.FieldPlanStartTime)
  31857. }
  31858. if m.plan_end_time != nil {
  31859. fields = append(fields, soptask.FieldPlanEndTime)
  31860. }
  31861. if m.creator_id != nil {
  31862. fields = append(fields, soptask.FieldCreatorID)
  31863. }
  31864. if m.organization_id != nil {
  31865. fields = append(fields, soptask.FieldOrganizationID)
  31866. }
  31867. if m.token != nil {
  31868. fields = append(fields, soptask.FieldToken)
  31869. }
  31870. return fields
  31871. }
  31872. // Field returns the value of a field with the given name. The second boolean
  31873. // return value indicates that this field was not set, or was not defined in the
  31874. // schema.
  31875. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  31876. switch name {
  31877. case soptask.FieldCreatedAt:
  31878. return m.CreatedAt()
  31879. case soptask.FieldUpdatedAt:
  31880. return m.UpdatedAt()
  31881. case soptask.FieldStatus:
  31882. return m.Status()
  31883. case soptask.FieldDeletedAt:
  31884. return m.DeletedAt()
  31885. case soptask.FieldName:
  31886. return m.Name()
  31887. case soptask.FieldBotWxidList:
  31888. return m.BotWxidList()
  31889. case soptask.FieldType:
  31890. return m.GetType()
  31891. case soptask.FieldPlanStartTime:
  31892. return m.PlanStartTime()
  31893. case soptask.FieldPlanEndTime:
  31894. return m.PlanEndTime()
  31895. case soptask.FieldCreatorID:
  31896. return m.CreatorID()
  31897. case soptask.FieldOrganizationID:
  31898. return m.OrganizationID()
  31899. case soptask.FieldToken:
  31900. return m.Token()
  31901. }
  31902. return nil, false
  31903. }
  31904. // OldField returns the old value of the field from the database. An error is
  31905. // returned if the mutation operation is not UpdateOne, or the query to the
  31906. // database failed.
  31907. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31908. switch name {
  31909. case soptask.FieldCreatedAt:
  31910. return m.OldCreatedAt(ctx)
  31911. case soptask.FieldUpdatedAt:
  31912. return m.OldUpdatedAt(ctx)
  31913. case soptask.FieldStatus:
  31914. return m.OldStatus(ctx)
  31915. case soptask.FieldDeletedAt:
  31916. return m.OldDeletedAt(ctx)
  31917. case soptask.FieldName:
  31918. return m.OldName(ctx)
  31919. case soptask.FieldBotWxidList:
  31920. return m.OldBotWxidList(ctx)
  31921. case soptask.FieldType:
  31922. return m.OldType(ctx)
  31923. case soptask.FieldPlanStartTime:
  31924. return m.OldPlanStartTime(ctx)
  31925. case soptask.FieldPlanEndTime:
  31926. return m.OldPlanEndTime(ctx)
  31927. case soptask.FieldCreatorID:
  31928. return m.OldCreatorID(ctx)
  31929. case soptask.FieldOrganizationID:
  31930. return m.OldOrganizationID(ctx)
  31931. case soptask.FieldToken:
  31932. return m.OldToken(ctx)
  31933. }
  31934. return nil, fmt.Errorf("unknown SopTask field %s", name)
  31935. }
  31936. // SetField sets the value of a field with the given name. It returns an error if
  31937. // the field is not defined in the schema, or if the type mismatched the field
  31938. // type.
  31939. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  31940. switch name {
  31941. case soptask.FieldCreatedAt:
  31942. v, ok := value.(time.Time)
  31943. if !ok {
  31944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31945. }
  31946. m.SetCreatedAt(v)
  31947. return nil
  31948. case soptask.FieldUpdatedAt:
  31949. v, ok := value.(time.Time)
  31950. if !ok {
  31951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31952. }
  31953. m.SetUpdatedAt(v)
  31954. return nil
  31955. case soptask.FieldStatus:
  31956. v, ok := value.(uint8)
  31957. if !ok {
  31958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31959. }
  31960. m.SetStatus(v)
  31961. return nil
  31962. case soptask.FieldDeletedAt:
  31963. v, ok := value.(time.Time)
  31964. if !ok {
  31965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31966. }
  31967. m.SetDeletedAt(v)
  31968. return nil
  31969. case soptask.FieldName:
  31970. v, ok := value.(string)
  31971. if !ok {
  31972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31973. }
  31974. m.SetName(v)
  31975. return nil
  31976. case soptask.FieldBotWxidList:
  31977. v, ok := value.([]string)
  31978. if !ok {
  31979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31980. }
  31981. m.SetBotWxidList(v)
  31982. return nil
  31983. case soptask.FieldType:
  31984. v, ok := value.(int)
  31985. if !ok {
  31986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31987. }
  31988. m.SetType(v)
  31989. return nil
  31990. case soptask.FieldPlanStartTime:
  31991. v, ok := value.(time.Time)
  31992. if !ok {
  31993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31994. }
  31995. m.SetPlanStartTime(v)
  31996. return nil
  31997. case soptask.FieldPlanEndTime:
  31998. v, ok := value.(time.Time)
  31999. if !ok {
  32000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32001. }
  32002. m.SetPlanEndTime(v)
  32003. return nil
  32004. case soptask.FieldCreatorID:
  32005. v, ok := value.(string)
  32006. if !ok {
  32007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32008. }
  32009. m.SetCreatorID(v)
  32010. return nil
  32011. case soptask.FieldOrganizationID:
  32012. v, ok := value.(uint64)
  32013. if !ok {
  32014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32015. }
  32016. m.SetOrganizationID(v)
  32017. return nil
  32018. case soptask.FieldToken:
  32019. v, ok := value.([]string)
  32020. if !ok {
  32021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32022. }
  32023. m.SetToken(v)
  32024. return nil
  32025. }
  32026. return fmt.Errorf("unknown SopTask field %s", name)
  32027. }
  32028. // AddedFields returns all numeric fields that were incremented/decremented during
  32029. // this mutation.
  32030. func (m *SopTaskMutation) AddedFields() []string {
  32031. var fields []string
  32032. if m.addstatus != nil {
  32033. fields = append(fields, soptask.FieldStatus)
  32034. }
  32035. if m.add_type != nil {
  32036. fields = append(fields, soptask.FieldType)
  32037. }
  32038. if m.addorganization_id != nil {
  32039. fields = append(fields, soptask.FieldOrganizationID)
  32040. }
  32041. return fields
  32042. }
  32043. // AddedField returns the numeric value that was incremented/decremented on a field
  32044. // with the given name. The second boolean return value indicates that this field
  32045. // was not set, or was not defined in the schema.
  32046. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  32047. switch name {
  32048. case soptask.FieldStatus:
  32049. return m.AddedStatus()
  32050. case soptask.FieldType:
  32051. return m.AddedType()
  32052. case soptask.FieldOrganizationID:
  32053. return m.AddedOrganizationID()
  32054. }
  32055. return nil, false
  32056. }
  32057. // AddField adds the value to the field with the given name. It returns an error if
  32058. // the field is not defined in the schema, or if the type mismatched the field
  32059. // type.
  32060. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  32061. switch name {
  32062. case soptask.FieldStatus:
  32063. v, ok := value.(int8)
  32064. if !ok {
  32065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32066. }
  32067. m.AddStatus(v)
  32068. return nil
  32069. case soptask.FieldType:
  32070. v, ok := value.(int)
  32071. if !ok {
  32072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32073. }
  32074. m.AddType(v)
  32075. return nil
  32076. case soptask.FieldOrganizationID:
  32077. v, ok := value.(int64)
  32078. if !ok {
  32079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32080. }
  32081. m.AddOrganizationID(v)
  32082. return nil
  32083. }
  32084. return fmt.Errorf("unknown SopTask numeric field %s", name)
  32085. }
  32086. // ClearedFields returns all nullable fields that were cleared during this
  32087. // mutation.
  32088. func (m *SopTaskMutation) ClearedFields() []string {
  32089. var fields []string
  32090. if m.FieldCleared(soptask.FieldStatus) {
  32091. fields = append(fields, soptask.FieldStatus)
  32092. }
  32093. if m.FieldCleared(soptask.FieldDeletedAt) {
  32094. fields = append(fields, soptask.FieldDeletedAt)
  32095. }
  32096. if m.FieldCleared(soptask.FieldBotWxidList) {
  32097. fields = append(fields, soptask.FieldBotWxidList)
  32098. }
  32099. if m.FieldCleared(soptask.FieldPlanStartTime) {
  32100. fields = append(fields, soptask.FieldPlanStartTime)
  32101. }
  32102. if m.FieldCleared(soptask.FieldPlanEndTime) {
  32103. fields = append(fields, soptask.FieldPlanEndTime)
  32104. }
  32105. if m.FieldCleared(soptask.FieldCreatorID) {
  32106. fields = append(fields, soptask.FieldCreatorID)
  32107. }
  32108. if m.FieldCleared(soptask.FieldOrganizationID) {
  32109. fields = append(fields, soptask.FieldOrganizationID)
  32110. }
  32111. if m.FieldCleared(soptask.FieldToken) {
  32112. fields = append(fields, soptask.FieldToken)
  32113. }
  32114. return fields
  32115. }
  32116. // FieldCleared returns a boolean indicating if a field with the given name was
  32117. // cleared in this mutation.
  32118. func (m *SopTaskMutation) FieldCleared(name string) bool {
  32119. _, ok := m.clearedFields[name]
  32120. return ok
  32121. }
  32122. // ClearField clears the value of the field with the given name. It returns an
  32123. // error if the field is not defined in the schema.
  32124. func (m *SopTaskMutation) ClearField(name string) error {
  32125. switch name {
  32126. case soptask.FieldStatus:
  32127. m.ClearStatus()
  32128. return nil
  32129. case soptask.FieldDeletedAt:
  32130. m.ClearDeletedAt()
  32131. return nil
  32132. case soptask.FieldBotWxidList:
  32133. m.ClearBotWxidList()
  32134. return nil
  32135. case soptask.FieldPlanStartTime:
  32136. m.ClearPlanStartTime()
  32137. return nil
  32138. case soptask.FieldPlanEndTime:
  32139. m.ClearPlanEndTime()
  32140. return nil
  32141. case soptask.FieldCreatorID:
  32142. m.ClearCreatorID()
  32143. return nil
  32144. case soptask.FieldOrganizationID:
  32145. m.ClearOrganizationID()
  32146. return nil
  32147. case soptask.FieldToken:
  32148. m.ClearToken()
  32149. return nil
  32150. }
  32151. return fmt.Errorf("unknown SopTask nullable field %s", name)
  32152. }
  32153. // ResetField resets all changes in the mutation for the field with the given name.
  32154. // It returns an error if the field is not defined in the schema.
  32155. func (m *SopTaskMutation) ResetField(name string) error {
  32156. switch name {
  32157. case soptask.FieldCreatedAt:
  32158. m.ResetCreatedAt()
  32159. return nil
  32160. case soptask.FieldUpdatedAt:
  32161. m.ResetUpdatedAt()
  32162. return nil
  32163. case soptask.FieldStatus:
  32164. m.ResetStatus()
  32165. return nil
  32166. case soptask.FieldDeletedAt:
  32167. m.ResetDeletedAt()
  32168. return nil
  32169. case soptask.FieldName:
  32170. m.ResetName()
  32171. return nil
  32172. case soptask.FieldBotWxidList:
  32173. m.ResetBotWxidList()
  32174. return nil
  32175. case soptask.FieldType:
  32176. m.ResetType()
  32177. return nil
  32178. case soptask.FieldPlanStartTime:
  32179. m.ResetPlanStartTime()
  32180. return nil
  32181. case soptask.FieldPlanEndTime:
  32182. m.ResetPlanEndTime()
  32183. return nil
  32184. case soptask.FieldCreatorID:
  32185. m.ResetCreatorID()
  32186. return nil
  32187. case soptask.FieldOrganizationID:
  32188. m.ResetOrganizationID()
  32189. return nil
  32190. case soptask.FieldToken:
  32191. m.ResetToken()
  32192. return nil
  32193. }
  32194. return fmt.Errorf("unknown SopTask field %s", name)
  32195. }
  32196. // AddedEdges returns all edge names that were set/added in this mutation.
  32197. func (m *SopTaskMutation) AddedEdges() []string {
  32198. edges := make([]string, 0, 1)
  32199. if m.task_stages != nil {
  32200. edges = append(edges, soptask.EdgeTaskStages)
  32201. }
  32202. return edges
  32203. }
  32204. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32205. // name in this mutation.
  32206. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  32207. switch name {
  32208. case soptask.EdgeTaskStages:
  32209. ids := make([]ent.Value, 0, len(m.task_stages))
  32210. for id := range m.task_stages {
  32211. ids = append(ids, id)
  32212. }
  32213. return ids
  32214. }
  32215. return nil
  32216. }
  32217. // RemovedEdges returns all edge names that were removed in this mutation.
  32218. func (m *SopTaskMutation) RemovedEdges() []string {
  32219. edges := make([]string, 0, 1)
  32220. if m.removedtask_stages != nil {
  32221. edges = append(edges, soptask.EdgeTaskStages)
  32222. }
  32223. return edges
  32224. }
  32225. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32226. // the given name in this mutation.
  32227. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  32228. switch name {
  32229. case soptask.EdgeTaskStages:
  32230. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  32231. for id := range m.removedtask_stages {
  32232. ids = append(ids, id)
  32233. }
  32234. return ids
  32235. }
  32236. return nil
  32237. }
  32238. // ClearedEdges returns all edge names that were cleared in this mutation.
  32239. func (m *SopTaskMutation) ClearedEdges() []string {
  32240. edges := make([]string, 0, 1)
  32241. if m.clearedtask_stages {
  32242. edges = append(edges, soptask.EdgeTaskStages)
  32243. }
  32244. return edges
  32245. }
  32246. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32247. // was cleared in this mutation.
  32248. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  32249. switch name {
  32250. case soptask.EdgeTaskStages:
  32251. return m.clearedtask_stages
  32252. }
  32253. return false
  32254. }
  32255. // ClearEdge clears the value of the edge with the given name. It returns an error
  32256. // if that edge is not defined in the schema.
  32257. func (m *SopTaskMutation) ClearEdge(name string) error {
  32258. switch name {
  32259. }
  32260. return fmt.Errorf("unknown SopTask unique edge %s", name)
  32261. }
  32262. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32263. // It returns an error if the edge is not defined in the schema.
  32264. func (m *SopTaskMutation) ResetEdge(name string) error {
  32265. switch name {
  32266. case soptask.EdgeTaskStages:
  32267. m.ResetTaskStages()
  32268. return nil
  32269. }
  32270. return fmt.Errorf("unknown SopTask edge %s", name)
  32271. }
  32272. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  32273. type TokenMutation struct {
  32274. config
  32275. op Op
  32276. typ string
  32277. id *uint64
  32278. created_at *time.Time
  32279. updated_at *time.Time
  32280. deleted_at *time.Time
  32281. expire_at *time.Time
  32282. token *string
  32283. mac *string
  32284. organization_id *uint64
  32285. addorganization_id *int64
  32286. custom_agent_base *string
  32287. custom_agent_key *string
  32288. openai_base *string
  32289. openai_key *string
  32290. clearedFields map[string]struct{}
  32291. agent *uint64
  32292. clearedagent bool
  32293. done bool
  32294. oldValue func(context.Context) (*Token, error)
  32295. predicates []predicate.Token
  32296. }
  32297. var _ ent.Mutation = (*TokenMutation)(nil)
  32298. // tokenOption allows management of the mutation configuration using functional options.
  32299. type tokenOption func(*TokenMutation)
  32300. // newTokenMutation creates new mutation for the Token entity.
  32301. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  32302. m := &TokenMutation{
  32303. config: c,
  32304. op: op,
  32305. typ: TypeToken,
  32306. clearedFields: make(map[string]struct{}),
  32307. }
  32308. for _, opt := range opts {
  32309. opt(m)
  32310. }
  32311. return m
  32312. }
  32313. // withTokenID sets the ID field of the mutation.
  32314. func withTokenID(id uint64) tokenOption {
  32315. return func(m *TokenMutation) {
  32316. var (
  32317. err error
  32318. once sync.Once
  32319. value *Token
  32320. )
  32321. m.oldValue = func(ctx context.Context) (*Token, error) {
  32322. once.Do(func() {
  32323. if m.done {
  32324. err = errors.New("querying old values post mutation is not allowed")
  32325. } else {
  32326. value, err = m.Client().Token.Get(ctx, id)
  32327. }
  32328. })
  32329. return value, err
  32330. }
  32331. m.id = &id
  32332. }
  32333. }
  32334. // withToken sets the old Token of the mutation.
  32335. func withToken(node *Token) tokenOption {
  32336. return func(m *TokenMutation) {
  32337. m.oldValue = func(context.Context) (*Token, error) {
  32338. return node, nil
  32339. }
  32340. m.id = &node.ID
  32341. }
  32342. }
  32343. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32344. // executed in a transaction (ent.Tx), a transactional client is returned.
  32345. func (m TokenMutation) Client() *Client {
  32346. client := &Client{config: m.config}
  32347. client.init()
  32348. return client
  32349. }
  32350. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32351. // it returns an error otherwise.
  32352. func (m TokenMutation) Tx() (*Tx, error) {
  32353. if _, ok := m.driver.(*txDriver); !ok {
  32354. return nil, errors.New("ent: mutation is not running in a transaction")
  32355. }
  32356. tx := &Tx{config: m.config}
  32357. tx.init()
  32358. return tx, nil
  32359. }
  32360. // SetID sets the value of the id field. Note that this
  32361. // operation is only accepted on creation of Token entities.
  32362. func (m *TokenMutation) SetID(id uint64) {
  32363. m.id = &id
  32364. }
  32365. // ID returns the ID value in the mutation. Note that the ID is only available
  32366. // if it was provided to the builder or after it was returned from the database.
  32367. func (m *TokenMutation) ID() (id uint64, exists bool) {
  32368. if m.id == nil {
  32369. return
  32370. }
  32371. return *m.id, true
  32372. }
  32373. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32374. // That means, if the mutation is applied within a transaction with an isolation level such
  32375. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32376. // or updated by the mutation.
  32377. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  32378. switch {
  32379. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32380. id, exists := m.ID()
  32381. if exists {
  32382. return []uint64{id}, nil
  32383. }
  32384. fallthrough
  32385. case m.op.Is(OpUpdate | OpDelete):
  32386. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  32387. default:
  32388. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32389. }
  32390. }
  32391. // SetCreatedAt sets the "created_at" field.
  32392. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  32393. m.created_at = &t
  32394. }
  32395. // CreatedAt returns the value of the "created_at" field in the mutation.
  32396. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  32397. v := m.created_at
  32398. if v == nil {
  32399. return
  32400. }
  32401. return *v, true
  32402. }
  32403. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  32404. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32406. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32407. if !m.op.Is(OpUpdateOne) {
  32408. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32409. }
  32410. if m.id == nil || m.oldValue == nil {
  32411. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32412. }
  32413. oldValue, err := m.oldValue(ctx)
  32414. if err != nil {
  32415. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32416. }
  32417. return oldValue.CreatedAt, nil
  32418. }
  32419. // ResetCreatedAt resets all changes to the "created_at" field.
  32420. func (m *TokenMutation) ResetCreatedAt() {
  32421. m.created_at = nil
  32422. }
  32423. // SetUpdatedAt sets the "updated_at" field.
  32424. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  32425. m.updated_at = &t
  32426. }
  32427. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32428. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  32429. v := m.updated_at
  32430. if v == nil {
  32431. return
  32432. }
  32433. return *v, true
  32434. }
  32435. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  32436. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32438. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32439. if !m.op.Is(OpUpdateOne) {
  32440. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32441. }
  32442. if m.id == nil || m.oldValue == nil {
  32443. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32444. }
  32445. oldValue, err := m.oldValue(ctx)
  32446. if err != nil {
  32447. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32448. }
  32449. return oldValue.UpdatedAt, nil
  32450. }
  32451. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32452. func (m *TokenMutation) ResetUpdatedAt() {
  32453. m.updated_at = nil
  32454. }
  32455. // SetDeletedAt sets the "deleted_at" field.
  32456. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  32457. m.deleted_at = &t
  32458. }
  32459. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32460. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  32461. v := m.deleted_at
  32462. if v == nil {
  32463. return
  32464. }
  32465. return *v, true
  32466. }
  32467. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  32468. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32470. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32471. if !m.op.Is(OpUpdateOne) {
  32472. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32473. }
  32474. if m.id == nil || m.oldValue == nil {
  32475. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32476. }
  32477. oldValue, err := m.oldValue(ctx)
  32478. if err != nil {
  32479. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32480. }
  32481. return oldValue.DeletedAt, nil
  32482. }
  32483. // ClearDeletedAt clears the value of the "deleted_at" field.
  32484. func (m *TokenMutation) ClearDeletedAt() {
  32485. m.deleted_at = nil
  32486. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  32487. }
  32488. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32489. func (m *TokenMutation) DeletedAtCleared() bool {
  32490. _, ok := m.clearedFields[token.FieldDeletedAt]
  32491. return ok
  32492. }
  32493. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32494. func (m *TokenMutation) ResetDeletedAt() {
  32495. m.deleted_at = nil
  32496. delete(m.clearedFields, token.FieldDeletedAt)
  32497. }
  32498. // SetExpireAt sets the "expire_at" field.
  32499. func (m *TokenMutation) SetExpireAt(t time.Time) {
  32500. m.expire_at = &t
  32501. }
  32502. // ExpireAt returns the value of the "expire_at" field in the mutation.
  32503. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  32504. v := m.expire_at
  32505. if v == nil {
  32506. return
  32507. }
  32508. return *v, true
  32509. }
  32510. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  32511. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32513. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  32514. if !m.op.Is(OpUpdateOne) {
  32515. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  32516. }
  32517. if m.id == nil || m.oldValue == nil {
  32518. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  32519. }
  32520. oldValue, err := m.oldValue(ctx)
  32521. if err != nil {
  32522. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  32523. }
  32524. return oldValue.ExpireAt, nil
  32525. }
  32526. // ClearExpireAt clears the value of the "expire_at" field.
  32527. func (m *TokenMutation) ClearExpireAt() {
  32528. m.expire_at = nil
  32529. m.clearedFields[token.FieldExpireAt] = struct{}{}
  32530. }
  32531. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  32532. func (m *TokenMutation) ExpireAtCleared() bool {
  32533. _, ok := m.clearedFields[token.FieldExpireAt]
  32534. return ok
  32535. }
  32536. // ResetExpireAt resets all changes to the "expire_at" field.
  32537. func (m *TokenMutation) ResetExpireAt() {
  32538. m.expire_at = nil
  32539. delete(m.clearedFields, token.FieldExpireAt)
  32540. }
  32541. // SetToken sets the "token" field.
  32542. func (m *TokenMutation) SetToken(s string) {
  32543. m.token = &s
  32544. }
  32545. // Token returns the value of the "token" field in the mutation.
  32546. func (m *TokenMutation) Token() (r string, exists bool) {
  32547. v := m.token
  32548. if v == nil {
  32549. return
  32550. }
  32551. return *v, true
  32552. }
  32553. // OldToken returns the old "token" field's value of the Token entity.
  32554. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32556. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  32557. if !m.op.Is(OpUpdateOne) {
  32558. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  32559. }
  32560. if m.id == nil || m.oldValue == nil {
  32561. return v, errors.New("OldToken requires an ID field in the mutation")
  32562. }
  32563. oldValue, err := m.oldValue(ctx)
  32564. if err != nil {
  32565. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  32566. }
  32567. return oldValue.Token, nil
  32568. }
  32569. // ClearToken clears the value of the "token" field.
  32570. func (m *TokenMutation) ClearToken() {
  32571. m.token = nil
  32572. m.clearedFields[token.FieldToken] = struct{}{}
  32573. }
  32574. // TokenCleared returns if the "token" field was cleared in this mutation.
  32575. func (m *TokenMutation) TokenCleared() bool {
  32576. _, ok := m.clearedFields[token.FieldToken]
  32577. return ok
  32578. }
  32579. // ResetToken resets all changes to the "token" field.
  32580. func (m *TokenMutation) ResetToken() {
  32581. m.token = nil
  32582. delete(m.clearedFields, token.FieldToken)
  32583. }
  32584. // SetMAC sets the "mac" field.
  32585. func (m *TokenMutation) SetMAC(s string) {
  32586. m.mac = &s
  32587. }
  32588. // MAC returns the value of the "mac" field in the mutation.
  32589. func (m *TokenMutation) MAC() (r string, exists bool) {
  32590. v := m.mac
  32591. if v == nil {
  32592. return
  32593. }
  32594. return *v, true
  32595. }
  32596. // OldMAC returns the old "mac" field's value of the Token entity.
  32597. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32599. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  32600. if !m.op.Is(OpUpdateOne) {
  32601. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  32602. }
  32603. if m.id == nil || m.oldValue == nil {
  32604. return v, errors.New("OldMAC requires an ID field in the mutation")
  32605. }
  32606. oldValue, err := m.oldValue(ctx)
  32607. if err != nil {
  32608. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  32609. }
  32610. return oldValue.MAC, nil
  32611. }
  32612. // ClearMAC clears the value of the "mac" field.
  32613. func (m *TokenMutation) ClearMAC() {
  32614. m.mac = nil
  32615. m.clearedFields[token.FieldMAC] = struct{}{}
  32616. }
  32617. // MACCleared returns if the "mac" field was cleared in this mutation.
  32618. func (m *TokenMutation) MACCleared() bool {
  32619. _, ok := m.clearedFields[token.FieldMAC]
  32620. return ok
  32621. }
  32622. // ResetMAC resets all changes to the "mac" field.
  32623. func (m *TokenMutation) ResetMAC() {
  32624. m.mac = nil
  32625. delete(m.clearedFields, token.FieldMAC)
  32626. }
  32627. // SetOrganizationID sets the "organization_id" field.
  32628. func (m *TokenMutation) SetOrganizationID(u uint64) {
  32629. m.organization_id = &u
  32630. m.addorganization_id = nil
  32631. }
  32632. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32633. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  32634. v := m.organization_id
  32635. if v == nil {
  32636. return
  32637. }
  32638. return *v, true
  32639. }
  32640. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  32641. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32643. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32644. if !m.op.Is(OpUpdateOne) {
  32645. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32646. }
  32647. if m.id == nil || m.oldValue == nil {
  32648. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32649. }
  32650. oldValue, err := m.oldValue(ctx)
  32651. if err != nil {
  32652. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32653. }
  32654. return oldValue.OrganizationID, nil
  32655. }
  32656. // AddOrganizationID adds u to the "organization_id" field.
  32657. func (m *TokenMutation) AddOrganizationID(u int64) {
  32658. if m.addorganization_id != nil {
  32659. *m.addorganization_id += u
  32660. } else {
  32661. m.addorganization_id = &u
  32662. }
  32663. }
  32664. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32665. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  32666. v := m.addorganization_id
  32667. if v == nil {
  32668. return
  32669. }
  32670. return *v, true
  32671. }
  32672. // ResetOrganizationID resets all changes to the "organization_id" field.
  32673. func (m *TokenMutation) ResetOrganizationID() {
  32674. m.organization_id = nil
  32675. m.addorganization_id = nil
  32676. }
  32677. // SetAgentID sets the "agent_id" field.
  32678. func (m *TokenMutation) SetAgentID(u uint64) {
  32679. m.agent = &u
  32680. }
  32681. // AgentID returns the value of the "agent_id" field in the mutation.
  32682. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  32683. v := m.agent
  32684. if v == nil {
  32685. return
  32686. }
  32687. return *v, true
  32688. }
  32689. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  32690. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32692. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32693. if !m.op.Is(OpUpdateOne) {
  32694. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32695. }
  32696. if m.id == nil || m.oldValue == nil {
  32697. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32698. }
  32699. oldValue, err := m.oldValue(ctx)
  32700. if err != nil {
  32701. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32702. }
  32703. return oldValue.AgentID, nil
  32704. }
  32705. // ResetAgentID resets all changes to the "agent_id" field.
  32706. func (m *TokenMutation) ResetAgentID() {
  32707. m.agent = nil
  32708. }
  32709. // SetCustomAgentBase sets the "custom_agent_base" field.
  32710. func (m *TokenMutation) SetCustomAgentBase(s string) {
  32711. m.custom_agent_base = &s
  32712. }
  32713. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  32714. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  32715. v := m.custom_agent_base
  32716. if v == nil {
  32717. return
  32718. }
  32719. return *v, true
  32720. }
  32721. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  32722. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32724. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  32725. if !m.op.Is(OpUpdateOne) {
  32726. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  32727. }
  32728. if m.id == nil || m.oldValue == nil {
  32729. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  32730. }
  32731. oldValue, err := m.oldValue(ctx)
  32732. if err != nil {
  32733. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  32734. }
  32735. return oldValue.CustomAgentBase, nil
  32736. }
  32737. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  32738. func (m *TokenMutation) ClearCustomAgentBase() {
  32739. m.custom_agent_base = nil
  32740. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  32741. }
  32742. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  32743. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  32744. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  32745. return ok
  32746. }
  32747. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  32748. func (m *TokenMutation) ResetCustomAgentBase() {
  32749. m.custom_agent_base = nil
  32750. delete(m.clearedFields, token.FieldCustomAgentBase)
  32751. }
  32752. // SetCustomAgentKey sets the "custom_agent_key" field.
  32753. func (m *TokenMutation) SetCustomAgentKey(s string) {
  32754. m.custom_agent_key = &s
  32755. }
  32756. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  32757. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  32758. v := m.custom_agent_key
  32759. if v == nil {
  32760. return
  32761. }
  32762. return *v, true
  32763. }
  32764. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  32765. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32767. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  32768. if !m.op.Is(OpUpdateOne) {
  32769. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  32770. }
  32771. if m.id == nil || m.oldValue == nil {
  32772. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  32773. }
  32774. oldValue, err := m.oldValue(ctx)
  32775. if err != nil {
  32776. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  32777. }
  32778. return oldValue.CustomAgentKey, nil
  32779. }
  32780. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  32781. func (m *TokenMutation) ClearCustomAgentKey() {
  32782. m.custom_agent_key = nil
  32783. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  32784. }
  32785. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  32786. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  32787. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  32788. return ok
  32789. }
  32790. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  32791. func (m *TokenMutation) ResetCustomAgentKey() {
  32792. m.custom_agent_key = nil
  32793. delete(m.clearedFields, token.FieldCustomAgentKey)
  32794. }
  32795. // SetOpenaiBase sets the "openai_base" field.
  32796. func (m *TokenMutation) SetOpenaiBase(s string) {
  32797. m.openai_base = &s
  32798. }
  32799. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  32800. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  32801. v := m.openai_base
  32802. if v == nil {
  32803. return
  32804. }
  32805. return *v, true
  32806. }
  32807. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  32808. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32810. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  32811. if !m.op.Is(OpUpdateOne) {
  32812. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  32813. }
  32814. if m.id == nil || m.oldValue == nil {
  32815. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  32816. }
  32817. oldValue, err := m.oldValue(ctx)
  32818. if err != nil {
  32819. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  32820. }
  32821. return oldValue.OpenaiBase, nil
  32822. }
  32823. // ClearOpenaiBase clears the value of the "openai_base" field.
  32824. func (m *TokenMutation) ClearOpenaiBase() {
  32825. m.openai_base = nil
  32826. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  32827. }
  32828. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  32829. func (m *TokenMutation) OpenaiBaseCleared() bool {
  32830. _, ok := m.clearedFields[token.FieldOpenaiBase]
  32831. return ok
  32832. }
  32833. // ResetOpenaiBase resets all changes to the "openai_base" field.
  32834. func (m *TokenMutation) ResetOpenaiBase() {
  32835. m.openai_base = nil
  32836. delete(m.clearedFields, token.FieldOpenaiBase)
  32837. }
  32838. // SetOpenaiKey sets the "openai_key" field.
  32839. func (m *TokenMutation) SetOpenaiKey(s string) {
  32840. m.openai_key = &s
  32841. }
  32842. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  32843. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  32844. v := m.openai_key
  32845. if v == nil {
  32846. return
  32847. }
  32848. return *v, true
  32849. }
  32850. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  32851. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32853. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  32854. if !m.op.Is(OpUpdateOne) {
  32855. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  32856. }
  32857. if m.id == nil || m.oldValue == nil {
  32858. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  32859. }
  32860. oldValue, err := m.oldValue(ctx)
  32861. if err != nil {
  32862. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  32863. }
  32864. return oldValue.OpenaiKey, nil
  32865. }
  32866. // ClearOpenaiKey clears the value of the "openai_key" field.
  32867. func (m *TokenMutation) ClearOpenaiKey() {
  32868. m.openai_key = nil
  32869. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  32870. }
  32871. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  32872. func (m *TokenMutation) OpenaiKeyCleared() bool {
  32873. _, ok := m.clearedFields[token.FieldOpenaiKey]
  32874. return ok
  32875. }
  32876. // ResetOpenaiKey resets all changes to the "openai_key" field.
  32877. func (m *TokenMutation) ResetOpenaiKey() {
  32878. m.openai_key = nil
  32879. delete(m.clearedFields, token.FieldOpenaiKey)
  32880. }
  32881. // ClearAgent clears the "agent" edge to the Agent entity.
  32882. func (m *TokenMutation) ClearAgent() {
  32883. m.clearedagent = true
  32884. m.clearedFields[token.FieldAgentID] = struct{}{}
  32885. }
  32886. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  32887. func (m *TokenMutation) AgentCleared() bool {
  32888. return m.clearedagent
  32889. }
  32890. // AgentIDs returns the "agent" edge IDs in the mutation.
  32891. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32892. // AgentID instead. It exists only for internal usage by the builders.
  32893. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  32894. if id := m.agent; id != nil {
  32895. ids = append(ids, *id)
  32896. }
  32897. return
  32898. }
  32899. // ResetAgent resets all changes to the "agent" edge.
  32900. func (m *TokenMutation) ResetAgent() {
  32901. m.agent = nil
  32902. m.clearedagent = false
  32903. }
  32904. // Where appends a list predicates to the TokenMutation builder.
  32905. func (m *TokenMutation) Where(ps ...predicate.Token) {
  32906. m.predicates = append(m.predicates, ps...)
  32907. }
  32908. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  32909. // users can use type-assertion to append predicates that do not depend on any generated package.
  32910. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  32911. p := make([]predicate.Token, len(ps))
  32912. for i := range ps {
  32913. p[i] = ps[i]
  32914. }
  32915. m.Where(p...)
  32916. }
  32917. // Op returns the operation name.
  32918. func (m *TokenMutation) Op() Op {
  32919. return m.op
  32920. }
  32921. // SetOp allows setting the mutation operation.
  32922. func (m *TokenMutation) SetOp(op Op) {
  32923. m.op = op
  32924. }
  32925. // Type returns the node type of this mutation (Token).
  32926. func (m *TokenMutation) Type() string {
  32927. return m.typ
  32928. }
  32929. // Fields returns all fields that were changed during this mutation. Note that in
  32930. // order to get all numeric fields that were incremented/decremented, call
  32931. // AddedFields().
  32932. func (m *TokenMutation) Fields() []string {
  32933. fields := make([]string, 0, 12)
  32934. if m.created_at != nil {
  32935. fields = append(fields, token.FieldCreatedAt)
  32936. }
  32937. if m.updated_at != nil {
  32938. fields = append(fields, token.FieldUpdatedAt)
  32939. }
  32940. if m.deleted_at != nil {
  32941. fields = append(fields, token.FieldDeletedAt)
  32942. }
  32943. if m.expire_at != nil {
  32944. fields = append(fields, token.FieldExpireAt)
  32945. }
  32946. if m.token != nil {
  32947. fields = append(fields, token.FieldToken)
  32948. }
  32949. if m.mac != nil {
  32950. fields = append(fields, token.FieldMAC)
  32951. }
  32952. if m.organization_id != nil {
  32953. fields = append(fields, token.FieldOrganizationID)
  32954. }
  32955. if m.agent != nil {
  32956. fields = append(fields, token.FieldAgentID)
  32957. }
  32958. if m.custom_agent_base != nil {
  32959. fields = append(fields, token.FieldCustomAgentBase)
  32960. }
  32961. if m.custom_agent_key != nil {
  32962. fields = append(fields, token.FieldCustomAgentKey)
  32963. }
  32964. if m.openai_base != nil {
  32965. fields = append(fields, token.FieldOpenaiBase)
  32966. }
  32967. if m.openai_key != nil {
  32968. fields = append(fields, token.FieldOpenaiKey)
  32969. }
  32970. return fields
  32971. }
  32972. // Field returns the value of a field with the given name. The second boolean
  32973. // return value indicates that this field was not set, or was not defined in the
  32974. // schema.
  32975. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  32976. switch name {
  32977. case token.FieldCreatedAt:
  32978. return m.CreatedAt()
  32979. case token.FieldUpdatedAt:
  32980. return m.UpdatedAt()
  32981. case token.FieldDeletedAt:
  32982. return m.DeletedAt()
  32983. case token.FieldExpireAt:
  32984. return m.ExpireAt()
  32985. case token.FieldToken:
  32986. return m.Token()
  32987. case token.FieldMAC:
  32988. return m.MAC()
  32989. case token.FieldOrganizationID:
  32990. return m.OrganizationID()
  32991. case token.FieldAgentID:
  32992. return m.AgentID()
  32993. case token.FieldCustomAgentBase:
  32994. return m.CustomAgentBase()
  32995. case token.FieldCustomAgentKey:
  32996. return m.CustomAgentKey()
  32997. case token.FieldOpenaiBase:
  32998. return m.OpenaiBase()
  32999. case token.FieldOpenaiKey:
  33000. return m.OpenaiKey()
  33001. }
  33002. return nil, false
  33003. }
  33004. // OldField returns the old value of the field from the database. An error is
  33005. // returned if the mutation operation is not UpdateOne, or the query to the
  33006. // database failed.
  33007. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33008. switch name {
  33009. case token.FieldCreatedAt:
  33010. return m.OldCreatedAt(ctx)
  33011. case token.FieldUpdatedAt:
  33012. return m.OldUpdatedAt(ctx)
  33013. case token.FieldDeletedAt:
  33014. return m.OldDeletedAt(ctx)
  33015. case token.FieldExpireAt:
  33016. return m.OldExpireAt(ctx)
  33017. case token.FieldToken:
  33018. return m.OldToken(ctx)
  33019. case token.FieldMAC:
  33020. return m.OldMAC(ctx)
  33021. case token.FieldOrganizationID:
  33022. return m.OldOrganizationID(ctx)
  33023. case token.FieldAgentID:
  33024. return m.OldAgentID(ctx)
  33025. case token.FieldCustomAgentBase:
  33026. return m.OldCustomAgentBase(ctx)
  33027. case token.FieldCustomAgentKey:
  33028. return m.OldCustomAgentKey(ctx)
  33029. case token.FieldOpenaiBase:
  33030. return m.OldOpenaiBase(ctx)
  33031. case token.FieldOpenaiKey:
  33032. return m.OldOpenaiKey(ctx)
  33033. }
  33034. return nil, fmt.Errorf("unknown Token field %s", name)
  33035. }
  33036. // SetField sets the value of a field with the given name. It returns an error if
  33037. // the field is not defined in the schema, or if the type mismatched the field
  33038. // type.
  33039. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  33040. switch name {
  33041. case token.FieldCreatedAt:
  33042. v, ok := value.(time.Time)
  33043. if !ok {
  33044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33045. }
  33046. m.SetCreatedAt(v)
  33047. return nil
  33048. case token.FieldUpdatedAt:
  33049. v, ok := value.(time.Time)
  33050. if !ok {
  33051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33052. }
  33053. m.SetUpdatedAt(v)
  33054. return nil
  33055. case token.FieldDeletedAt:
  33056. v, ok := value.(time.Time)
  33057. if !ok {
  33058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33059. }
  33060. m.SetDeletedAt(v)
  33061. return nil
  33062. case token.FieldExpireAt:
  33063. v, ok := value.(time.Time)
  33064. if !ok {
  33065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33066. }
  33067. m.SetExpireAt(v)
  33068. return nil
  33069. case token.FieldToken:
  33070. v, ok := value.(string)
  33071. if !ok {
  33072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33073. }
  33074. m.SetToken(v)
  33075. return nil
  33076. case token.FieldMAC:
  33077. v, ok := value.(string)
  33078. if !ok {
  33079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33080. }
  33081. m.SetMAC(v)
  33082. return nil
  33083. case token.FieldOrganizationID:
  33084. v, ok := value.(uint64)
  33085. if !ok {
  33086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33087. }
  33088. m.SetOrganizationID(v)
  33089. return nil
  33090. case token.FieldAgentID:
  33091. v, ok := value.(uint64)
  33092. if !ok {
  33093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33094. }
  33095. m.SetAgentID(v)
  33096. return nil
  33097. case token.FieldCustomAgentBase:
  33098. v, ok := value.(string)
  33099. if !ok {
  33100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33101. }
  33102. m.SetCustomAgentBase(v)
  33103. return nil
  33104. case token.FieldCustomAgentKey:
  33105. v, ok := value.(string)
  33106. if !ok {
  33107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33108. }
  33109. m.SetCustomAgentKey(v)
  33110. return nil
  33111. case token.FieldOpenaiBase:
  33112. v, ok := value.(string)
  33113. if !ok {
  33114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33115. }
  33116. m.SetOpenaiBase(v)
  33117. return nil
  33118. case token.FieldOpenaiKey:
  33119. v, ok := value.(string)
  33120. if !ok {
  33121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33122. }
  33123. m.SetOpenaiKey(v)
  33124. return nil
  33125. }
  33126. return fmt.Errorf("unknown Token field %s", name)
  33127. }
  33128. // AddedFields returns all numeric fields that were incremented/decremented during
  33129. // this mutation.
  33130. func (m *TokenMutation) AddedFields() []string {
  33131. var fields []string
  33132. if m.addorganization_id != nil {
  33133. fields = append(fields, token.FieldOrganizationID)
  33134. }
  33135. return fields
  33136. }
  33137. // AddedField returns the numeric value that was incremented/decremented on a field
  33138. // with the given name. The second boolean return value indicates that this field
  33139. // was not set, or was not defined in the schema.
  33140. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  33141. switch name {
  33142. case token.FieldOrganizationID:
  33143. return m.AddedOrganizationID()
  33144. }
  33145. return nil, false
  33146. }
  33147. // AddField adds the value to the field with the given name. It returns an error if
  33148. // the field is not defined in the schema, or if the type mismatched the field
  33149. // type.
  33150. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  33151. switch name {
  33152. case token.FieldOrganizationID:
  33153. v, ok := value.(int64)
  33154. if !ok {
  33155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33156. }
  33157. m.AddOrganizationID(v)
  33158. return nil
  33159. }
  33160. return fmt.Errorf("unknown Token numeric field %s", name)
  33161. }
  33162. // ClearedFields returns all nullable fields that were cleared during this
  33163. // mutation.
  33164. func (m *TokenMutation) ClearedFields() []string {
  33165. var fields []string
  33166. if m.FieldCleared(token.FieldDeletedAt) {
  33167. fields = append(fields, token.FieldDeletedAt)
  33168. }
  33169. if m.FieldCleared(token.FieldExpireAt) {
  33170. fields = append(fields, token.FieldExpireAt)
  33171. }
  33172. if m.FieldCleared(token.FieldToken) {
  33173. fields = append(fields, token.FieldToken)
  33174. }
  33175. if m.FieldCleared(token.FieldMAC) {
  33176. fields = append(fields, token.FieldMAC)
  33177. }
  33178. if m.FieldCleared(token.FieldCustomAgentBase) {
  33179. fields = append(fields, token.FieldCustomAgentBase)
  33180. }
  33181. if m.FieldCleared(token.FieldCustomAgentKey) {
  33182. fields = append(fields, token.FieldCustomAgentKey)
  33183. }
  33184. if m.FieldCleared(token.FieldOpenaiBase) {
  33185. fields = append(fields, token.FieldOpenaiBase)
  33186. }
  33187. if m.FieldCleared(token.FieldOpenaiKey) {
  33188. fields = append(fields, token.FieldOpenaiKey)
  33189. }
  33190. return fields
  33191. }
  33192. // FieldCleared returns a boolean indicating if a field with the given name was
  33193. // cleared in this mutation.
  33194. func (m *TokenMutation) FieldCleared(name string) bool {
  33195. _, ok := m.clearedFields[name]
  33196. return ok
  33197. }
  33198. // ClearField clears the value of the field with the given name. It returns an
  33199. // error if the field is not defined in the schema.
  33200. func (m *TokenMutation) ClearField(name string) error {
  33201. switch name {
  33202. case token.FieldDeletedAt:
  33203. m.ClearDeletedAt()
  33204. return nil
  33205. case token.FieldExpireAt:
  33206. m.ClearExpireAt()
  33207. return nil
  33208. case token.FieldToken:
  33209. m.ClearToken()
  33210. return nil
  33211. case token.FieldMAC:
  33212. m.ClearMAC()
  33213. return nil
  33214. case token.FieldCustomAgentBase:
  33215. m.ClearCustomAgentBase()
  33216. return nil
  33217. case token.FieldCustomAgentKey:
  33218. m.ClearCustomAgentKey()
  33219. return nil
  33220. case token.FieldOpenaiBase:
  33221. m.ClearOpenaiBase()
  33222. return nil
  33223. case token.FieldOpenaiKey:
  33224. m.ClearOpenaiKey()
  33225. return nil
  33226. }
  33227. return fmt.Errorf("unknown Token nullable field %s", name)
  33228. }
  33229. // ResetField resets all changes in the mutation for the field with the given name.
  33230. // It returns an error if the field is not defined in the schema.
  33231. func (m *TokenMutation) ResetField(name string) error {
  33232. switch name {
  33233. case token.FieldCreatedAt:
  33234. m.ResetCreatedAt()
  33235. return nil
  33236. case token.FieldUpdatedAt:
  33237. m.ResetUpdatedAt()
  33238. return nil
  33239. case token.FieldDeletedAt:
  33240. m.ResetDeletedAt()
  33241. return nil
  33242. case token.FieldExpireAt:
  33243. m.ResetExpireAt()
  33244. return nil
  33245. case token.FieldToken:
  33246. m.ResetToken()
  33247. return nil
  33248. case token.FieldMAC:
  33249. m.ResetMAC()
  33250. return nil
  33251. case token.FieldOrganizationID:
  33252. m.ResetOrganizationID()
  33253. return nil
  33254. case token.FieldAgentID:
  33255. m.ResetAgentID()
  33256. return nil
  33257. case token.FieldCustomAgentBase:
  33258. m.ResetCustomAgentBase()
  33259. return nil
  33260. case token.FieldCustomAgentKey:
  33261. m.ResetCustomAgentKey()
  33262. return nil
  33263. case token.FieldOpenaiBase:
  33264. m.ResetOpenaiBase()
  33265. return nil
  33266. case token.FieldOpenaiKey:
  33267. m.ResetOpenaiKey()
  33268. return nil
  33269. }
  33270. return fmt.Errorf("unknown Token field %s", name)
  33271. }
  33272. // AddedEdges returns all edge names that were set/added in this mutation.
  33273. func (m *TokenMutation) AddedEdges() []string {
  33274. edges := make([]string, 0, 1)
  33275. if m.agent != nil {
  33276. edges = append(edges, token.EdgeAgent)
  33277. }
  33278. return edges
  33279. }
  33280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33281. // name in this mutation.
  33282. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  33283. switch name {
  33284. case token.EdgeAgent:
  33285. if id := m.agent; id != nil {
  33286. return []ent.Value{*id}
  33287. }
  33288. }
  33289. return nil
  33290. }
  33291. // RemovedEdges returns all edge names that were removed in this mutation.
  33292. func (m *TokenMutation) RemovedEdges() []string {
  33293. edges := make([]string, 0, 1)
  33294. return edges
  33295. }
  33296. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33297. // the given name in this mutation.
  33298. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  33299. return nil
  33300. }
  33301. // ClearedEdges returns all edge names that were cleared in this mutation.
  33302. func (m *TokenMutation) ClearedEdges() []string {
  33303. edges := make([]string, 0, 1)
  33304. if m.clearedagent {
  33305. edges = append(edges, token.EdgeAgent)
  33306. }
  33307. return edges
  33308. }
  33309. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33310. // was cleared in this mutation.
  33311. func (m *TokenMutation) EdgeCleared(name string) bool {
  33312. switch name {
  33313. case token.EdgeAgent:
  33314. return m.clearedagent
  33315. }
  33316. return false
  33317. }
  33318. // ClearEdge clears the value of the edge with the given name. It returns an error
  33319. // if that edge is not defined in the schema.
  33320. func (m *TokenMutation) ClearEdge(name string) error {
  33321. switch name {
  33322. case token.EdgeAgent:
  33323. m.ClearAgent()
  33324. return nil
  33325. }
  33326. return fmt.Errorf("unknown Token unique edge %s", name)
  33327. }
  33328. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33329. // It returns an error if the edge is not defined in the schema.
  33330. func (m *TokenMutation) ResetEdge(name string) error {
  33331. switch name {
  33332. case token.EdgeAgent:
  33333. m.ResetAgent()
  33334. return nil
  33335. }
  33336. return fmt.Errorf("unknown Token edge %s", name)
  33337. }
  33338. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  33339. type TutorialMutation struct {
  33340. config
  33341. op Op
  33342. typ string
  33343. id *uint64
  33344. created_at *time.Time
  33345. updated_at *time.Time
  33346. deleted_at *time.Time
  33347. index *int
  33348. addindex *int
  33349. title *string
  33350. content *string
  33351. organization_id *uint64
  33352. addorganization_id *int64
  33353. clearedFields map[string]struct{}
  33354. employee *uint64
  33355. clearedemployee bool
  33356. done bool
  33357. oldValue func(context.Context) (*Tutorial, error)
  33358. predicates []predicate.Tutorial
  33359. }
  33360. var _ ent.Mutation = (*TutorialMutation)(nil)
  33361. // tutorialOption allows management of the mutation configuration using functional options.
  33362. type tutorialOption func(*TutorialMutation)
  33363. // newTutorialMutation creates new mutation for the Tutorial entity.
  33364. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  33365. m := &TutorialMutation{
  33366. config: c,
  33367. op: op,
  33368. typ: TypeTutorial,
  33369. clearedFields: make(map[string]struct{}),
  33370. }
  33371. for _, opt := range opts {
  33372. opt(m)
  33373. }
  33374. return m
  33375. }
  33376. // withTutorialID sets the ID field of the mutation.
  33377. func withTutorialID(id uint64) tutorialOption {
  33378. return func(m *TutorialMutation) {
  33379. var (
  33380. err error
  33381. once sync.Once
  33382. value *Tutorial
  33383. )
  33384. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  33385. once.Do(func() {
  33386. if m.done {
  33387. err = errors.New("querying old values post mutation is not allowed")
  33388. } else {
  33389. value, err = m.Client().Tutorial.Get(ctx, id)
  33390. }
  33391. })
  33392. return value, err
  33393. }
  33394. m.id = &id
  33395. }
  33396. }
  33397. // withTutorial sets the old Tutorial of the mutation.
  33398. func withTutorial(node *Tutorial) tutorialOption {
  33399. return func(m *TutorialMutation) {
  33400. m.oldValue = func(context.Context) (*Tutorial, error) {
  33401. return node, nil
  33402. }
  33403. m.id = &node.ID
  33404. }
  33405. }
  33406. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33407. // executed in a transaction (ent.Tx), a transactional client is returned.
  33408. func (m TutorialMutation) Client() *Client {
  33409. client := &Client{config: m.config}
  33410. client.init()
  33411. return client
  33412. }
  33413. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33414. // it returns an error otherwise.
  33415. func (m TutorialMutation) Tx() (*Tx, error) {
  33416. if _, ok := m.driver.(*txDriver); !ok {
  33417. return nil, errors.New("ent: mutation is not running in a transaction")
  33418. }
  33419. tx := &Tx{config: m.config}
  33420. tx.init()
  33421. return tx, nil
  33422. }
  33423. // SetID sets the value of the id field. Note that this
  33424. // operation is only accepted on creation of Tutorial entities.
  33425. func (m *TutorialMutation) SetID(id uint64) {
  33426. m.id = &id
  33427. }
  33428. // ID returns the ID value in the mutation. Note that the ID is only available
  33429. // if it was provided to the builder or after it was returned from the database.
  33430. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  33431. if m.id == nil {
  33432. return
  33433. }
  33434. return *m.id, true
  33435. }
  33436. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33437. // That means, if the mutation is applied within a transaction with an isolation level such
  33438. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33439. // or updated by the mutation.
  33440. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  33441. switch {
  33442. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33443. id, exists := m.ID()
  33444. if exists {
  33445. return []uint64{id}, nil
  33446. }
  33447. fallthrough
  33448. case m.op.Is(OpUpdate | OpDelete):
  33449. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  33450. default:
  33451. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33452. }
  33453. }
  33454. // SetCreatedAt sets the "created_at" field.
  33455. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  33456. m.created_at = &t
  33457. }
  33458. // CreatedAt returns the value of the "created_at" field in the mutation.
  33459. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  33460. v := m.created_at
  33461. if v == nil {
  33462. return
  33463. }
  33464. return *v, true
  33465. }
  33466. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  33467. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33469. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33470. if !m.op.Is(OpUpdateOne) {
  33471. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33472. }
  33473. if m.id == nil || m.oldValue == nil {
  33474. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33475. }
  33476. oldValue, err := m.oldValue(ctx)
  33477. if err != nil {
  33478. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33479. }
  33480. return oldValue.CreatedAt, nil
  33481. }
  33482. // ResetCreatedAt resets all changes to the "created_at" field.
  33483. func (m *TutorialMutation) ResetCreatedAt() {
  33484. m.created_at = nil
  33485. }
  33486. // SetUpdatedAt sets the "updated_at" field.
  33487. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  33488. m.updated_at = &t
  33489. }
  33490. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33491. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  33492. v := m.updated_at
  33493. if v == nil {
  33494. return
  33495. }
  33496. return *v, true
  33497. }
  33498. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  33499. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33501. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33502. if !m.op.Is(OpUpdateOne) {
  33503. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33504. }
  33505. if m.id == nil || m.oldValue == nil {
  33506. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33507. }
  33508. oldValue, err := m.oldValue(ctx)
  33509. if err != nil {
  33510. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33511. }
  33512. return oldValue.UpdatedAt, nil
  33513. }
  33514. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33515. func (m *TutorialMutation) ResetUpdatedAt() {
  33516. m.updated_at = nil
  33517. }
  33518. // SetDeletedAt sets the "deleted_at" field.
  33519. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  33520. m.deleted_at = &t
  33521. }
  33522. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33523. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  33524. v := m.deleted_at
  33525. if v == nil {
  33526. return
  33527. }
  33528. return *v, true
  33529. }
  33530. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  33531. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33533. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33534. if !m.op.Is(OpUpdateOne) {
  33535. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33536. }
  33537. if m.id == nil || m.oldValue == nil {
  33538. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33539. }
  33540. oldValue, err := m.oldValue(ctx)
  33541. if err != nil {
  33542. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33543. }
  33544. return oldValue.DeletedAt, nil
  33545. }
  33546. // ClearDeletedAt clears the value of the "deleted_at" field.
  33547. func (m *TutorialMutation) ClearDeletedAt() {
  33548. m.deleted_at = nil
  33549. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  33550. }
  33551. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33552. func (m *TutorialMutation) DeletedAtCleared() bool {
  33553. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  33554. return ok
  33555. }
  33556. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33557. func (m *TutorialMutation) ResetDeletedAt() {
  33558. m.deleted_at = nil
  33559. delete(m.clearedFields, tutorial.FieldDeletedAt)
  33560. }
  33561. // SetEmployeeID sets the "employee_id" field.
  33562. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  33563. m.employee = &u
  33564. }
  33565. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33566. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  33567. v := m.employee
  33568. if v == nil {
  33569. return
  33570. }
  33571. return *v, true
  33572. }
  33573. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  33574. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33576. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33577. if !m.op.Is(OpUpdateOne) {
  33578. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33579. }
  33580. if m.id == nil || m.oldValue == nil {
  33581. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33582. }
  33583. oldValue, err := m.oldValue(ctx)
  33584. if err != nil {
  33585. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33586. }
  33587. return oldValue.EmployeeID, nil
  33588. }
  33589. // ResetEmployeeID resets all changes to the "employee_id" field.
  33590. func (m *TutorialMutation) ResetEmployeeID() {
  33591. m.employee = nil
  33592. }
  33593. // SetIndex sets the "index" field.
  33594. func (m *TutorialMutation) SetIndex(i int) {
  33595. m.index = &i
  33596. m.addindex = nil
  33597. }
  33598. // Index returns the value of the "index" field in the mutation.
  33599. func (m *TutorialMutation) Index() (r int, exists bool) {
  33600. v := m.index
  33601. if v == nil {
  33602. return
  33603. }
  33604. return *v, true
  33605. }
  33606. // OldIndex returns the old "index" field's value of the Tutorial entity.
  33607. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33609. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  33610. if !m.op.Is(OpUpdateOne) {
  33611. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  33612. }
  33613. if m.id == nil || m.oldValue == nil {
  33614. return v, errors.New("OldIndex requires an ID field in the mutation")
  33615. }
  33616. oldValue, err := m.oldValue(ctx)
  33617. if err != nil {
  33618. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  33619. }
  33620. return oldValue.Index, nil
  33621. }
  33622. // AddIndex adds i to the "index" field.
  33623. func (m *TutorialMutation) AddIndex(i int) {
  33624. if m.addindex != nil {
  33625. *m.addindex += i
  33626. } else {
  33627. m.addindex = &i
  33628. }
  33629. }
  33630. // AddedIndex returns the value that was added to the "index" field in this mutation.
  33631. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  33632. v := m.addindex
  33633. if v == nil {
  33634. return
  33635. }
  33636. return *v, true
  33637. }
  33638. // ResetIndex resets all changes to the "index" field.
  33639. func (m *TutorialMutation) ResetIndex() {
  33640. m.index = nil
  33641. m.addindex = nil
  33642. }
  33643. // SetTitle sets the "title" field.
  33644. func (m *TutorialMutation) SetTitle(s string) {
  33645. m.title = &s
  33646. }
  33647. // Title returns the value of the "title" field in the mutation.
  33648. func (m *TutorialMutation) Title() (r string, exists bool) {
  33649. v := m.title
  33650. if v == nil {
  33651. return
  33652. }
  33653. return *v, true
  33654. }
  33655. // OldTitle returns the old "title" field's value of the Tutorial entity.
  33656. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33658. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  33659. if !m.op.Is(OpUpdateOne) {
  33660. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  33661. }
  33662. if m.id == nil || m.oldValue == nil {
  33663. return v, errors.New("OldTitle requires an ID field in the mutation")
  33664. }
  33665. oldValue, err := m.oldValue(ctx)
  33666. if err != nil {
  33667. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  33668. }
  33669. return oldValue.Title, nil
  33670. }
  33671. // ResetTitle resets all changes to the "title" field.
  33672. func (m *TutorialMutation) ResetTitle() {
  33673. m.title = nil
  33674. }
  33675. // SetContent sets the "content" field.
  33676. func (m *TutorialMutation) SetContent(s string) {
  33677. m.content = &s
  33678. }
  33679. // Content returns the value of the "content" field in the mutation.
  33680. func (m *TutorialMutation) Content() (r string, exists bool) {
  33681. v := m.content
  33682. if v == nil {
  33683. return
  33684. }
  33685. return *v, true
  33686. }
  33687. // OldContent returns the old "content" field's value of the Tutorial entity.
  33688. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33690. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  33691. if !m.op.Is(OpUpdateOne) {
  33692. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  33693. }
  33694. if m.id == nil || m.oldValue == nil {
  33695. return v, errors.New("OldContent requires an ID field in the mutation")
  33696. }
  33697. oldValue, err := m.oldValue(ctx)
  33698. if err != nil {
  33699. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  33700. }
  33701. return oldValue.Content, nil
  33702. }
  33703. // ResetContent resets all changes to the "content" field.
  33704. func (m *TutorialMutation) ResetContent() {
  33705. m.content = nil
  33706. }
  33707. // SetOrganizationID sets the "organization_id" field.
  33708. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  33709. m.organization_id = &u
  33710. m.addorganization_id = nil
  33711. }
  33712. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33713. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  33714. v := m.organization_id
  33715. if v == nil {
  33716. return
  33717. }
  33718. return *v, true
  33719. }
  33720. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  33721. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33723. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33724. if !m.op.Is(OpUpdateOne) {
  33725. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33726. }
  33727. if m.id == nil || m.oldValue == nil {
  33728. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33729. }
  33730. oldValue, err := m.oldValue(ctx)
  33731. if err != nil {
  33732. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33733. }
  33734. return oldValue.OrganizationID, nil
  33735. }
  33736. // AddOrganizationID adds u to the "organization_id" field.
  33737. func (m *TutorialMutation) AddOrganizationID(u int64) {
  33738. if m.addorganization_id != nil {
  33739. *m.addorganization_id += u
  33740. } else {
  33741. m.addorganization_id = &u
  33742. }
  33743. }
  33744. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33745. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  33746. v := m.addorganization_id
  33747. if v == nil {
  33748. return
  33749. }
  33750. return *v, true
  33751. }
  33752. // ResetOrganizationID resets all changes to the "organization_id" field.
  33753. func (m *TutorialMutation) ResetOrganizationID() {
  33754. m.organization_id = nil
  33755. m.addorganization_id = nil
  33756. }
  33757. // ClearEmployee clears the "employee" edge to the Employee entity.
  33758. func (m *TutorialMutation) ClearEmployee() {
  33759. m.clearedemployee = true
  33760. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  33761. }
  33762. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  33763. func (m *TutorialMutation) EmployeeCleared() bool {
  33764. return m.clearedemployee
  33765. }
  33766. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  33767. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33768. // EmployeeID instead. It exists only for internal usage by the builders.
  33769. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  33770. if id := m.employee; id != nil {
  33771. ids = append(ids, *id)
  33772. }
  33773. return
  33774. }
  33775. // ResetEmployee resets all changes to the "employee" edge.
  33776. func (m *TutorialMutation) ResetEmployee() {
  33777. m.employee = nil
  33778. m.clearedemployee = false
  33779. }
  33780. // Where appends a list predicates to the TutorialMutation builder.
  33781. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  33782. m.predicates = append(m.predicates, ps...)
  33783. }
  33784. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  33785. // users can use type-assertion to append predicates that do not depend on any generated package.
  33786. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  33787. p := make([]predicate.Tutorial, len(ps))
  33788. for i := range ps {
  33789. p[i] = ps[i]
  33790. }
  33791. m.Where(p...)
  33792. }
  33793. // Op returns the operation name.
  33794. func (m *TutorialMutation) Op() Op {
  33795. return m.op
  33796. }
  33797. // SetOp allows setting the mutation operation.
  33798. func (m *TutorialMutation) SetOp(op Op) {
  33799. m.op = op
  33800. }
  33801. // Type returns the node type of this mutation (Tutorial).
  33802. func (m *TutorialMutation) Type() string {
  33803. return m.typ
  33804. }
  33805. // Fields returns all fields that were changed during this mutation. Note that in
  33806. // order to get all numeric fields that were incremented/decremented, call
  33807. // AddedFields().
  33808. func (m *TutorialMutation) Fields() []string {
  33809. fields := make([]string, 0, 8)
  33810. if m.created_at != nil {
  33811. fields = append(fields, tutorial.FieldCreatedAt)
  33812. }
  33813. if m.updated_at != nil {
  33814. fields = append(fields, tutorial.FieldUpdatedAt)
  33815. }
  33816. if m.deleted_at != nil {
  33817. fields = append(fields, tutorial.FieldDeletedAt)
  33818. }
  33819. if m.employee != nil {
  33820. fields = append(fields, tutorial.FieldEmployeeID)
  33821. }
  33822. if m.index != nil {
  33823. fields = append(fields, tutorial.FieldIndex)
  33824. }
  33825. if m.title != nil {
  33826. fields = append(fields, tutorial.FieldTitle)
  33827. }
  33828. if m.content != nil {
  33829. fields = append(fields, tutorial.FieldContent)
  33830. }
  33831. if m.organization_id != nil {
  33832. fields = append(fields, tutorial.FieldOrganizationID)
  33833. }
  33834. return fields
  33835. }
  33836. // Field returns the value of a field with the given name. The second boolean
  33837. // return value indicates that this field was not set, or was not defined in the
  33838. // schema.
  33839. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  33840. switch name {
  33841. case tutorial.FieldCreatedAt:
  33842. return m.CreatedAt()
  33843. case tutorial.FieldUpdatedAt:
  33844. return m.UpdatedAt()
  33845. case tutorial.FieldDeletedAt:
  33846. return m.DeletedAt()
  33847. case tutorial.FieldEmployeeID:
  33848. return m.EmployeeID()
  33849. case tutorial.FieldIndex:
  33850. return m.Index()
  33851. case tutorial.FieldTitle:
  33852. return m.Title()
  33853. case tutorial.FieldContent:
  33854. return m.Content()
  33855. case tutorial.FieldOrganizationID:
  33856. return m.OrganizationID()
  33857. }
  33858. return nil, false
  33859. }
  33860. // OldField returns the old value of the field from the database. An error is
  33861. // returned if the mutation operation is not UpdateOne, or the query to the
  33862. // database failed.
  33863. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33864. switch name {
  33865. case tutorial.FieldCreatedAt:
  33866. return m.OldCreatedAt(ctx)
  33867. case tutorial.FieldUpdatedAt:
  33868. return m.OldUpdatedAt(ctx)
  33869. case tutorial.FieldDeletedAt:
  33870. return m.OldDeletedAt(ctx)
  33871. case tutorial.FieldEmployeeID:
  33872. return m.OldEmployeeID(ctx)
  33873. case tutorial.FieldIndex:
  33874. return m.OldIndex(ctx)
  33875. case tutorial.FieldTitle:
  33876. return m.OldTitle(ctx)
  33877. case tutorial.FieldContent:
  33878. return m.OldContent(ctx)
  33879. case tutorial.FieldOrganizationID:
  33880. return m.OldOrganizationID(ctx)
  33881. }
  33882. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  33883. }
  33884. // SetField sets the value of a field with the given name. It returns an error if
  33885. // the field is not defined in the schema, or if the type mismatched the field
  33886. // type.
  33887. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  33888. switch name {
  33889. case tutorial.FieldCreatedAt:
  33890. v, ok := value.(time.Time)
  33891. if !ok {
  33892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33893. }
  33894. m.SetCreatedAt(v)
  33895. return nil
  33896. case tutorial.FieldUpdatedAt:
  33897. v, ok := value.(time.Time)
  33898. if !ok {
  33899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33900. }
  33901. m.SetUpdatedAt(v)
  33902. return nil
  33903. case tutorial.FieldDeletedAt:
  33904. v, ok := value.(time.Time)
  33905. if !ok {
  33906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33907. }
  33908. m.SetDeletedAt(v)
  33909. return nil
  33910. case tutorial.FieldEmployeeID:
  33911. v, ok := value.(uint64)
  33912. if !ok {
  33913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33914. }
  33915. m.SetEmployeeID(v)
  33916. return nil
  33917. case tutorial.FieldIndex:
  33918. v, ok := value.(int)
  33919. if !ok {
  33920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33921. }
  33922. m.SetIndex(v)
  33923. return nil
  33924. case tutorial.FieldTitle:
  33925. v, ok := value.(string)
  33926. if !ok {
  33927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33928. }
  33929. m.SetTitle(v)
  33930. return nil
  33931. case tutorial.FieldContent:
  33932. v, ok := value.(string)
  33933. if !ok {
  33934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33935. }
  33936. m.SetContent(v)
  33937. return nil
  33938. case tutorial.FieldOrganizationID:
  33939. v, ok := value.(uint64)
  33940. if !ok {
  33941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33942. }
  33943. m.SetOrganizationID(v)
  33944. return nil
  33945. }
  33946. return fmt.Errorf("unknown Tutorial field %s", name)
  33947. }
  33948. // AddedFields returns all numeric fields that were incremented/decremented during
  33949. // this mutation.
  33950. func (m *TutorialMutation) AddedFields() []string {
  33951. var fields []string
  33952. if m.addindex != nil {
  33953. fields = append(fields, tutorial.FieldIndex)
  33954. }
  33955. if m.addorganization_id != nil {
  33956. fields = append(fields, tutorial.FieldOrganizationID)
  33957. }
  33958. return fields
  33959. }
  33960. // AddedField returns the numeric value that was incremented/decremented on a field
  33961. // with the given name. The second boolean return value indicates that this field
  33962. // was not set, or was not defined in the schema.
  33963. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  33964. switch name {
  33965. case tutorial.FieldIndex:
  33966. return m.AddedIndex()
  33967. case tutorial.FieldOrganizationID:
  33968. return m.AddedOrganizationID()
  33969. }
  33970. return nil, false
  33971. }
  33972. // AddField adds the value to the field with the given name. It returns an error if
  33973. // the field is not defined in the schema, or if the type mismatched the field
  33974. // type.
  33975. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  33976. switch name {
  33977. case tutorial.FieldIndex:
  33978. v, ok := value.(int)
  33979. if !ok {
  33980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33981. }
  33982. m.AddIndex(v)
  33983. return nil
  33984. case tutorial.FieldOrganizationID:
  33985. v, ok := value.(int64)
  33986. if !ok {
  33987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33988. }
  33989. m.AddOrganizationID(v)
  33990. return nil
  33991. }
  33992. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  33993. }
  33994. // ClearedFields returns all nullable fields that were cleared during this
  33995. // mutation.
  33996. func (m *TutorialMutation) ClearedFields() []string {
  33997. var fields []string
  33998. if m.FieldCleared(tutorial.FieldDeletedAt) {
  33999. fields = append(fields, tutorial.FieldDeletedAt)
  34000. }
  34001. return fields
  34002. }
  34003. // FieldCleared returns a boolean indicating if a field with the given name was
  34004. // cleared in this mutation.
  34005. func (m *TutorialMutation) FieldCleared(name string) bool {
  34006. _, ok := m.clearedFields[name]
  34007. return ok
  34008. }
  34009. // ClearField clears the value of the field with the given name. It returns an
  34010. // error if the field is not defined in the schema.
  34011. func (m *TutorialMutation) ClearField(name string) error {
  34012. switch name {
  34013. case tutorial.FieldDeletedAt:
  34014. m.ClearDeletedAt()
  34015. return nil
  34016. }
  34017. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  34018. }
  34019. // ResetField resets all changes in the mutation for the field with the given name.
  34020. // It returns an error if the field is not defined in the schema.
  34021. func (m *TutorialMutation) ResetField(name string) error {
  34022. switch name {
  34023. case tutorial.FieldCreatedAt:
  34024. m.ResetCreatedAt()
  34025. return nil
  34026. case tutorial.FieldUpdatedAt:
  34027. m.ResetUpdatedAt()
  34028. return nil
  34029. case tutorial.FieldDeletedAt:
  34030. m.ResetDeletedAt()
  34031. return nil
  34032. case tutorial.FieldEmployeeID:
  34033. m.ResetEmployeeID()
  34034. return nil
  34035. case tutorial.FieldIndex:
  34036. m.ResetIndex()
  34037. return nil
  34038. case tutorial.FieldTitle:
  34039. m.ResetTitle()
  34040. return nil
  34041. case tutorial.FieldContent:
  34042. m.ResetContent()
  34043. return nil
  34044. case tutorial.FieldOrganizationID:
  34045. m.ResetOrganizationID()
  34046. return nil
  34047. }
  34048. return fmt.Errorf("unknown Tutorial field %s", name)
  34049. }
  34050. // AddedEdges returns all edge names that were set/added in this mutation.
  34051. func (m *TutorialMutation) AddedEdges() []string {
  34052. edges := make([]string, 0, 1)
  34053. if m.employee != nil {
  34054. edges = append(edges, tutorial.EdgeEmployee)
  34055. }
  34056. return edges
  34057. }
  34058. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34059. // name in this mutation.
  34060. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  34061. switch name {
  34062. case tutorial.EdgeEmployee:
  34063. if id := m.employee; id != nil {
  34064. return []ent.Value{*id}
  34065. }
  34066. }
  34067. return nil
  34068. }
  34069. // RemovedEdges returns all edge names that were removed in this mutation.
  34070. func (m *TutorialMutation) RemovedEdges() []string {
  34071. edges := make([]string, 0, 1)
  34072. return edges
  34073. }
  34074. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34075. // the given name in this mutation.
  34076. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  34077. return nil
  34078. }
  34079. // ClearedEdges returns all edge names that were cleared in this mutation.
  34080. func (m *TutorialMutation) ClearedEdges() []string {
  34081. edges := make([]string, 0, 1)
  34082. if m.clearedemployee {
  34083. edges = append(edges, tutorial.EdgeEmployee)
  34084. }
  34085. return edges
  34086. }
  34087. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34088. // was cleared in this mutation.
  34089. func (m *TutorialMutation) EdgeCleared(name string) bool {
  34090. switch name {
  34091. case tutorial.EdgeEmployee:
  34092. return m.clearedemployee
  34093. }
  34094. return false
  34095. }
  34096. // ClearEdge clears the value of the edge with the given name. It returns an error
  34097. // if that edge is not defined in the schema.
  34098. func (m *TutorialMutation) ClearEdge(name string) error {
  34099. switch name {
  34100. case tutorial.EdgeEmployee:
  34101. m.ClearEmployee()
  34102. return nil
  34103. }
  34104. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  34105. }
  34106. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34107. // It returns an error if the edge is not defined in the schema.
  34108. func (m *TutorialMutation) ResetEdge(name string) error {
  34109. switch name {
  34110. case tutorial.EdgeEmployee:
  34111. m.ResetEmployee()
  34112. return nil
  34113. }
  34114. return fmt.Errorf("unknown Tutorial edge %s", name)
  34115. }
  34116. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  34117. type UsageDetailMutation struct {
  34118. config
  34119. op Op
  34120. typ string
  34121. id *uint64
  34122. created_at *time.Time
  34123. updated_at *time.Time
  34124. status *uint8
  34125. addstatus *int8
  34126. _type *int
  34127. add_type *int
  34128. bot_id *string
  34129. receiver_id *string
  34130. app *int
  34131. addapp *int
  34132. session_id *uint64
  34133. addsession_id *int64
  34134. request *string
  34135. response *string
  34136. original_data *custom_types.OriginalData
  34137. total_tokens *uint64
  34138. addtotal_tokens *int64
  34139. prompt_tokens *uint64
  34140. addprompt_tokens *int64
  34141. completion_tokens *uint64
  34142. addcompletion_tokens *int64
  34143. organization_id *uint64
  34144. addorganization_id *int64
  34145. model *string
  34146. credits *float64
  34147. addcredits *float64
  34148. clearedFields map[string]struct{}
  34149. done bool
  34150. oldValue func(context.Context) (*UsageDetail, error)
  34151. predicates []predicate.UsageDetail
  34152. }
  34153. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  34154. // usagedetailOption allows management of the mutation configuration using functional options.
  34155. type usagedetailOption func(*UsageDetailMutation)
  34156. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  34157. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  34158. m := &UsageDetailMutation{
  34159. config: c,
  34160. op: op,
  34161. typ: TypeUsageDetail,
  34162. clearedFields: make(map[string]struct{}),
  34163. }
  34164. for _, opt := range opts {
  34165. opt(m)
  34166. }
  34167. return m
  34168. }
  34169. // withUsageDetailID sets the ID field of the mutation.
  34170. func withUsageDetailID(id uint64) usagedetailOption {
  34171. return func(m *UsageDetailMutation) {
  34172. var (
  34173. err error
  34174. once sync.Once
  34175. value *UsageDetail
  34176. )
  34177. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  34178. once.Do(func() {
  34179. if m.done {
  34180. err = errors.New("querying old values post mutation is not allowed")
  34181. } else {
  34182. value, err = m.Client().UsageDetail.Get(ctx, id)
  34183. }
  34184. })
  34185. return value, err
  34186. }
  34187. m.id = &id
  34188. }
  34189. }
  34190. // withUsageDetail sets the old UsageDetail of the mutation.
  34191. func withUsageDetail(node *UsageDetail) usagedetailOption {
  34192. return func(m *UsageDetailMutation) {
  34193. m.oldValue = func(context.Context) (*UsageDetail, error) {
  34194. return node, nil
  34195. }
  34196. m.id = &node.ID
  34197. }
  34198. }
  34199. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34200. // executed in a transaction (ent.Tx), a transactional client is returned.
  34201. func (m UsageDetailMutation) Client() *Client {
  34202. client := &Client{config: m.config}
  34203. client.init()
  34204. return client
  34205. }
  34206. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34207. // it returns an error otherwise.
  34208. func (m UsageDetailMutation) Tx() (*Tx, error) {
  34209. if _, ok := m.driver.(*txDriver); !ok {
  34210. return nil, errors.New("ent: mutation is not running in a transaction")
  34211. }
  34212. tx := &Tx{config: m.config}
  34213. tx.init()
  34214. return tx, nil
  34215. }
  34216. // SetID sets the value of the id field. Note that this
  34217. // operation is only accepted on creation of UsageDetail entities.
  34218. func (m *UsageDetailMutation) SetID(id uint64) {
  34219. m.id = &id
  34220. }
  34221. // ID returns the ID value in the mutation. Note that the ID is only available
  34222. // if it was provided to the builder or after it was returned from the database.
  34223. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  34224. if m.id == nil {
  34225. return
  34226. }
  34227. return *m.id, true
  34228. }
  34229. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34230. // That means, if the mutation is applied within a transaction with an isolation level such
  34231. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34232. // or updated by the mutation.
  34233. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  34234. switch {
  34235. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34236. id, exists := m.ID()
  34237. if exists {
  34238. return []uint64{id}, nil
  34239. }
  34240. fallthrough
  34241. case m.op.Is(OpUpdate | OpDelete):
  34242. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  34243. default:
  34244. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34245. }
  34246. }
  34247. // SetCreatedAt sets the "created_at" field.
  34248. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  34249. m.created_at = &t
  34250. }
  34251. // CreatedAt returns the value of the "created_at" field in the mutation.
  34252. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  34253. v := m.created_at
  34254. if v == nil {
  34255. return
  34256. }
  34257. return *v, true
  34258. }
  34259. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  34260. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34262. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34263. if !m.op.Is(OpUpdateOne) {
  34264. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34265. }
  34266. if m.id == nil || m.oldValue == nil {
  34267. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34268. }
  34269. oldValue, err := m.oldValue(ctx)
  34270. if err != nil {
  34271. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34272. }
  34273. return oldValue.CreatedAt, nil
  34274. }
  34275. // ResetCreatedAt resets all changes to the "created_at" field.
  34276. func (m *UsageDetailMutation) ResetCreatedAt() {
  34277. m.created_at = nil
  34278. }
  34279. // SetUpdatedAt sets the "updated_at" field.
  34280. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  34281. m.updated_at = &t
  34282. }
  34283. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34284. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  34285. v := m.updated_at
  34286. if v == nil {
  34287. return
  34288. }
  34289. return *v, true
  34290. }
  34291. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  34292. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34294. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34295. if !m.op.Is(OpUpdateOne) {
  34296. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34297. }
  34298. if m.id == nil || m.oldValue == nil {
  34299. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34300. }
  34301. oldValue, err := m.oldValue(ctx)
  34302. if err != nil {
  34303. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34304. }
  34305. return oldValue.UpdatedAt, nil
  34306. }
  34307. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34308. func (m *UsageDetailMutation) ResetUpdatedAt() {
  34309. m.updated_at = nil
  34310. }
  34311. // SetStatus sets the "status" field.
  34312. func (m *UsageDetailMutation) SetStatus(u uint8) {
  34313. m.status = &u
  34314. m.addstatus = nil
  34315. }
  34316. // Status returns the value of the "status" field in the mutation.
  34317. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  34318. v := m.status
  34319. if v == nil {
  34320. return
  34321. }
  34322. return *v, true
  34323. }
  34324. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  34325. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34327. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34328. if !m.op.Is(OpUpdateOne) {
  34329. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34330. }
  34331. if m.id == nil || m.oldValue == nil {
  34332. return v, errors.New("OldStatus requires an ID field in the mutation")
  34333. }
  34334. oldValue, err := m.oldValue(ctx)
  34335. if err != nil {
  34336. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34337. }
  34338. return oldValue.Status, nil
  34339. }
  34340. // AddStatus adds u to the "status" field.
  34341. func (m *UsageDetailMutation) AddStatus(u int8) {
  34342. if m.addstatus != nil {
  34343. *m.addstatus += u
  34344. } else {
  34345. m.addstatus = &u
  34346. }
  34347. }
  34348. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34349. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  34350. v := m.addstatus
  34351. if v == nil {
  34352. return
  34353. }
  34354. return *v, true
  34355. }
  34356. // ClearStatus clears the value of the "status" field.
  34357. func (m *UsageDetailMutation) ClearStatus() {
  34358. m.status = nil
  34359. m.addstatus = nil
  34360. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  34361. }
  34362. // StatusCleared returns if the "status" field was cleared in this mutation.
  34363. func (m *UsageDetailMutation) StatusCleared() bool {
  34364. _, ok := m.clearedFields[usagedetail.FieldStatus]
  34365. return ok
  34366. }
  34367. // ResetStatus resets all changes to the "status" field.
  34368. func (m *UsageDetailMutation) ResetStatus() {
  34369. m.status = nil
  34370. m.addstatus = nil
  34371. delete(m.clearedFields, usagedetail.FieldStatus)
  34372. }
  34373. // SetType sets the "type" field.
  34374. func (m *UsageDetailMutation) SetType(i int) {
  34375. m._type = &i
  34376. m.add_type = nil
  34377. }
  34378. // GetType returns the value of the "type" field in the mutation.
  34379. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  34380. v := m._type
  34381. if v == nil {
  34382. return
  34383. }
  34384. return *v, true
  34385. }
  34386. // OldType returns the old "type" field's value of the UsageDetail entity.
  34387. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34389. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  34390. if !m.op.Is(OpUpdateOne) {
  34391. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34392. }
  34393. if m.id == nil || m.oldValue == nil {
  34394. return v, errors.New("OldType requires an ID field in the mutation")
  34395. }
  34396. oldValue, err := m.oldValue(ctx)
  34397. if err != nil {
  34398. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34399. }
  34400. return oldValue.Type, nil
  34401. }
  34402. // AddType adds i to the "type" field.
  34403. func (m *UsageDetailMutation) AddType(i int) {
  34404. if m.add_type != nil {
  34405. *m.add_type += i
  34406. } else {
  34407. m.add_type = &i
  34408. }
  34409. }
  34410. // AddedType returns the value that was added to the "type" field in this mutation.
  34411. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  34412. v := m.add_type
  34413. if v == nil {
  34414. return
  34415. }
  34416. return *v, true
  34417. }
  34418. // ClearType clears the value of the "type" field.
  34419. func (m *UsageDetailMutation) ClearType() {
  34420. m._type = nil
  34421. m.add_type = nil
  34422. m.clearedFields[usagedetail.FieldType] = struct{}{}
  34423. }
  34424. // TypeCleared returns if the "type" field was cleared in this mutation.
  34425. func (m *UsageDetailMutation) TypeCleared() bool {
  34426. _, ok := m.clearedFields[usagedetail.FieldType]
  34427. return ok
  34428. }
  34429. // ResetType resets all changes to the "type" field.
  34430. func (m *UsageDetailMutation) ResetType() {
  34431. m._type = nil
  34432. m.add_type = nil
  34433. delete(m.clearedFields, usagedetail.FieldType)
  34434. }
  34435. // SetBotID sets the "bot_id" field.
  34436. func (m *UsageDetailMutation) SetBotID(s string) {
  34437. m.bot_id = &s
  34438. }
  34439. // BotID returns the value of the "bot_id" field in the mutation.
  34440. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  34441. v := m.bot_id
  34442. if v == nil {
  34443. return
  34444. }
  34445. return *v, true
  34446. }
  34447. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  34448. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34450. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  34451. if !m.op.Is(OpUpdateOne) {
  34452. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34453. }
  34454. if m.id == nil || m.oldValue == nil {
  34455. return v, errors.New("OldBotID requires an ID field in the mutation")
  34456. }
  34457. oldValue, err := m.oldValue(ctx)
  34458. if err != nil {
  34459. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34460. }
  34461. return oldValue.BotID, nil
  34462. }
  34463. // ResetBotID resets all changes to the "bot_id" field.
  34464. func (m *UsageDetailMutation) ResetBotID() {
  34465. m.bot_id = nil
  34466. }
  34467. // SetReceiverID sets the "receiver_id" field.
  34468. func (m *UsageDetailMutation) SetReceiverID(s string) {
  34469. m.receiver_id = &s
  34470. }
  34471. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  34472. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  34473. v := m.receiver_id
  34474. if v == nil {
  34475. return
  34476. }
  34477. return *v, true
  34478. }
  34479. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  34480. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34482. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  34483. if !m.op.Is(OpUpdateOne) {
  34484. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  34485. }
  34486. if m.id == nil || m.oldValue == nil {
  34487. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  34488. }
  34489. oldValue, err := m.oldValue(ctx)
  34490. if err != nil {
  34491. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  34492. }
  34493. return oldValue.ReceiverID, nil
  34494. }
  34495. // ResetReceiverID resets all changes to the "receiver_id" field.
  34496. func (m *UsageDetailMutation) ResetReceiverID() {
  34497. m.receiver_id = nil
  34498. }
  34499. // SetApp sets the "app" field.
  34500. func (m *UsageDetailMutation) SetApp(i int) {
  34501. m.app = &i
  34502. m.addapp = nil
  34503. }
  34504. // App returns the value of the "app" field in the mutation.
  34505. func (m *UsageDetailMutation) App() (r int, exists bool) {
  34506. v := m.app
  34507. if v == nil {
  34508. return
  34509. }
  34510. return *v, true
  34511. }
  34512. // OldApp returns the old "app" field's value of the UsageDetail entity.
  34513. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34515. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  34516. if !m.op.Is(OpUpdateOne) {
  34517. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  34518. }
  34519. if m.id == nil || m.oldValue == nil {
  34520. return v, errors.New("OldApp requires an ID field in the mutation")
  34521. }
  34522. oldValue, err := m.oldValue(ctx)
  34523. if err != nil {
  34524. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  34525. }
  34526. return oldValue.App, nil
  34527. }
  34528. // AddApp adds i to the "app" field.
  34529. func (m *UsageDetailMutation) AddApp(i int) {
  34530. if m.addapp != nil {
  34531. *m.addapp += i
  34532. } else {
  34533. m.addapp = &i
  34534. }
  34535. }
  34536. // AddedApp returns the value that was added to the "app" field in this mutation.
  34537. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  34538. v := m.addapp
  34539. if v == nil {
  34540. return
  34541. }
  34542. return *v, true
  34543. }
  34544. // ClearApp clears the value of the "app" field.
  34545. func (m *UsageDetailMutation) ClearApp() {
  34546. m.app = nil
  34547. m.addapp = nil
  34548. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  34549. }
  34550. // AppCleared returns if the "app" field was cleared in this mutation.
  34551. func (m *UsageDetailMutation) AppCleared() bool {
  34552. _, ok := m.clearedFields[usagedetail.FieldApp]
  34553. return ok
  34554. }
  34555. // ResetApp resets all changes to the "app" field.
  34556. func (m *UsageDetailMutation) ResetApp() {
  34557. m.app = nil
  34558. m.addapp = nil
  34559. delete(m.clearedFields, usagedetail.FieldApp)
  34560. }
  34561. // SetSessionID sets the "session_id" field.
  34562. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  34563. m.session_id = &u
  34564. m.addsession_id = nil
  34565. }
  34566. // SessionID returns the value of the "session_id" field in the mutation.
  34567. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  34568. v := m.session_id
  34569. if v == nil {
  34570. return
  34571. }
  34572. return *v, true
  34573. }
  34574. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  34575. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34577. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  34578. if !m.op.Is(OpUpdateOne) {
  34579. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  34580. }
  34581. if m.id == nil || m.oldValue == nil {
  34582. return v, errors.New("OldSessionID requires an ID field in the mutation")
  34583. }
  34584. oldValue, err := m.oldValue(ctx)
  34585. if err != nil {
  34586. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  34587. }
  34588. return oldValue.SessionID, nil
  34589. }
  34590. // AddSessionID adds u to the "session_id" field.
  34591. func (m *UsageDetailMutation) AddSessionID(u int64) {
  34592. if m.addsession_id != nil {
  34593. *m.addsession_id += u
  34594. } else {
  34595. m.addsession_id = &u
  34596. }
  34597. }
  34598. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  34599. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  34600. v := m.addsession_id
  34601. if v == nil {
  34602. return
  34603. }
  34604. return *v, true
  34605. }
  34606. // ClearSessionID clears the value of the "session_id" field.
  34607. func (m *UsageDetailMutation) ClearSessionID() {
  34608. m.session_id = nil
  34609. m.addsession_id = nil
  34610. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  34611. }
  34612. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  34613. func (m *UsageDetailMutation) SessionIDCleared() bool {
  34614. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  34615. return ok
  34616. }
  34617. // ResetSessionID resets all changes to the "session_id" field.
  34618. func (m *UsageDetailMutation) ResetSessionID() {
  34619. m.session_id = nil
  34620. m.addsession_id = nil
  34621. delete(m.clearedFields, usagedetail.FieldSessionID)
  34622. }
  34623. // SetRequest sets the "request" field.
  34624. func (m *UsageDetailMutation) SetRequest(s string) {
  34625. m.request = &s
  34626. }
  34627. // Request returns the value of the "request" field in the mutation.
  34628. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  34629. v := m.request
  34630. if v == nil {
  34631. return
  34632. }
  34633. return *v, true
  34634. }
  34635. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  34636. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34638. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  34639. if !m.op.Is(OpUpdateOne) {
  34640. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  34641. }
  34642. if m.id == nil || m.oldValue == nil {
  34643. return v, errors.New("OldRequest requires an ID field in the mutation")
  34644. }
  34645. oldValue, err := m.oldValue(ctx)
  34646. if err != nil {
  34647. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  34648. }
  34649. return oldValue.Request, nil
  34650. }
  34651. // ResetRequest resets all changes to the "request" field.
  34652. func (m *UsageDetailMutation) ResetRequest() {
  34653. m.request = nil
  34654. }
  34655. // SetResponse sets the "response" field.
  34656. func (m *UsageDetailMutation) SetResponse(s string) {
  34657. m.response = &s
  34658. }
  34659. // Response returns the value of the "response" field in the mutation.
  34660. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  34661. v := m.response
  34662. if v == nil {
  34663. return
  34664. }
  34665. return *v, true
  34666. }
  34667. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  34668. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34670. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  34671. if !m.op.Is(OpUpdateOne) {
  34672. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  34673. }
  34674. if m.id == nil || m.oldValue == nil {
  34675. return v, errors.New("OldResponse requires an ID field in the mutation")
  34676. }
  34677. oldValue, err := m.oldValue(ctx)
  34678. if err != nil {
  34679. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  34680. }
  34681. return oldValue.Response, nil
  34682. }
  34683. // ResetResponse resets all changes to the "response" field.
  34684. func (m *UsageDetailMutation) ResetResponse() {
  34685. m.response = nil
  34686. }
  34687. // SetOriginalData sets the "original_data" field.
  34688. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  34689. m.original_data = &ctd
  34690. }
  34691. // OriginalData returns the value of the "original_data" field in the mutation.
  34692. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  34693. v := m.original_data
  34694. if v == nil {
  34695. return
  34696. }
  34697. return *v, true
  34698. }
  34699. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  34700. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34702. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  34703. if !m.op.Is(OpUpdateOne) {
  34704. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  34705. }
  34706. if m.id == nil || m.oldValue == nil {
  34707. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  34708. }
  34709. oldValue, err := m.oldValue(ctx)
  34710. if err != nil {
  34711. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  34712. }
  34713. return oldValue.OriginalData, nil
  34714. }
  34715. // ResetOriginalData resets all changes to the "original_data" field.
  34716. func (m *UsageDetailMutation) ResetOriginalData() {
  34717. m.original_data = nil
  34718. }
  34719. // SetTotalTokens sets the "total_tokens" field.
  34720. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  34721. m.total_tokens = &u
  34722. m.addtotal_tokens = nil
  34723. }
  34724. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34725. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  34726. v := m.total_tokens
  34727. if v == nil {
  34728. return
  34729. }
  34730. return *v, true
  34731. }
  34732. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  34733. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34735. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34736. if !m.op.Is(OpUpdateOne) {
  34737. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34738. }
  34739. if m.id == nil || m.oldValue == nil {
  34740. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34741. }
  34742. oldValue, err := m.oldValue(ctx)
  34743. if err != nil {
  34744. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34745. }
  34746. return oldValue.TotalTokens, nil
  34747. }
  34748. // AddTotalTokens adds u to the "total_tokens" field.
  34749. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  34750. if m.addtotal_tokens != nil {
  34751. *m.addtotal_tokens += u
  34752. } else {
  34753. m.addtotal_tokens = &u
  34754. }
  34755. }
  34756. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34757. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  34758. v := m.addtotal_tokens
  34759. if v == nil {
  34760. return
  34761. }
  34762. return *v, true
  34763. }
  34764. // ClearTotalTokens clears the value of the "total_tokens" field.
  34765. func (m *UsageDetailMutation) ClearTotalTokens() {
  34766. m.total_tokens = nil
  34767. m.addtotal_tokens = nil
  34768. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  34769. }
  34770. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34771. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  34772. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  34773. return ok
  34774. }
  34775. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34776. func (m *UsageDetailMutation) ResetTotalTokens() {
  34777. m.total_tokens = nil
  34778. m.addtotal_tokens = nil
  34779. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  34780. }
  34781. // SetPromptTokens sets the "prompt_tokens" field.
  34782. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  34783. m.prompt_tokens = &u
  34784. m.addprompt_tokens = nil
  34785. }
  34786. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  34787. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  34788. v := m.prompt_tokens
  34789. if v == nil {
  34790. return
  34791. }
  34792. return *v, true
  34793. }
  34794. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  34795. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34797. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  34798. if !m.op.Is(OpUpdateOne) {
  34799. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  34800. }
  34801. if m.id == nil || m.oldValue == nil {
  34802. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  34803. }
  34804. oldValue, err := m.oldValue(ctx)
  34805. if err != nil {
  34806. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  34807. }
  34808. return oldValue.PromptTokens, nil
  34809. }
  34810. // AddPromptTokens adds u to the "prompt_tokens" field.
  34811. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  34812. if m.addprompt_tokens != nil {
  34813. *m.addprompt_tokens += u
  34814. } else {
  34815. m.addprompt_tokens = &u
  34816. }
  34817. }
  34818. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  34819. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  34820. v := m.addprompt_tokens
  34821. if v == nil {
  34822. return
  34823. }
  34824. return *v, true
  34825. }
  34826. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  34827. func (m *UsageDetailMutation) ClearPromptTokens() {
  34828. m.prompt_tokens = nil
  34829. m.addprompt_tokens = nil
  34830. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  34831. }
  34832. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  34833. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  34834. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  34835. return ok
  34836. }
  34837. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  34838. func (m *UsageDetailMutation) ResetPromptTokens() {
  34839. m.prompt_tokens = nil
  34840. m.addprompt_tokens = nil
  34841. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  34842. }
  34843. // SetCompletionTokens sets the "completion_tokens" field.
  34844. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  34845. m.completion_tokens = &u
  34846. m.addcompletion_tokens = nil
  34847. }
  34848. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  34849. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  34850. v := m.completion_tokens
  34851. if v == nil {
  34852. return
  34853. }
  34854. return *v, true
  34855. }
  34856. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  34857. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34859. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  34860. if !m.op.Is(OpUpdateOne) {
  34861. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  34862. }
  34863. if m.id == nil || m.oldValue == nil {
  34864. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  34865. }
  34866. oldValue, err := m.oldValue(ctx)
  34867. if err != nil {
  34868. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  34869. }
  34870. return oldValue.CompletionTokens, nil
  34871. }
  34872. // AddCompletionTokens adds u to the "completion_tokens" field.
  34873. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  34874. if m.addcompletion_tokens != nil {
  34875. *m.addcompletion_tokens += u
  34876. } else {
  34877. m.addcompletion_tokens = &u
  34878. }
  34879. }
  34880. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  34881. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  34882. v := m.addcompletion_tokens
  34883. if v == nil {
  34884. return
  34885. }
  34886. return *v, true
  34887. }
  34888. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  34889. func (m *UsageDetailMutation) ClearCompletionTokens() {
  34890. m.completion_tokens = nil
  34891. m.addcompletion_tokens = nil
  34892. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  34893. }
  34894. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  34895. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  34896. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  34897. return ok
  34898. }
  34899. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  34900. func (m *UsageDetailMutation) ResetCompletionTokens() {
  34901. m.completion_tokens = nil
  34902. m.addcompletion_tokens = nil
  34903. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  34904. }
  34905. // SetOrganizationID sets the "organization_id" field.
  34906. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  34907. m.organization_id = &u
  34908. m.addorganization_id = nil
  34909. }
  34910. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34911. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  34912. v := m.organization_id
  34913. if v == nil {
  34914. return
  34915. }
  34916. return *v, true
  34917. }
  34918. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  34919. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34921. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34922. if !m.op.Is(OpUpdateOne) {
  34923. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34924. }
  34925. if m.id == nil || m.oldValue == nil {
  34926. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34927. }
  34928. oldValue, err := m.oldValue(ctx)
  34929. if err != nil {
  34930. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34931. }
  34932. return oldValue.OrganizationID, nil
  34933. }
  34934. // AddOrganizationID adds u to the "organization_id" field.
  34935. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  34936. if m.addorganization_id != nil {
  34937. *m.addorganization_id += u
  34938. } else {
  34939. m.addorganization_id = &u
  34940. }
  34941. }
  34942. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34943. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  34944. v := m.addorganization_id
  34945. if v == nil {
  34946. return
  34947. }
  34948. return *v, true
  34949. }
  34950. // ClearOrganizationID clears the value of the "organization_id" field.
  34951. func (m *UsageDetailMutation) ClearOrganizationID() {
  34952. m.organization_id = nil
  34953. m.addorganization_id = nil
  34954. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  34955. }
  34956. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34957. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  34958. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  34959. return ok
  34960. }
  34961. // ResetOrganizationID resets all changes to the "organization_id" field.
  34962. func (m *UsageDetailMutation) ResetOrganizationID() {
  34963. m.organization_id = nil
  34964. m.addorganization_id = nil
  34965. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  34966. }
  34967. // SetModel sets the "model" field.
  34968. func (m *UsageDetailMutation) SetModel(s string) {
  34969. m.model = &s
  34970. }
  34971. // Model returns the value of the "model" field in the mutation.
  34972. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  34973. v := m.model
  34974. if v == nil {
  34975. return
  34976. }
  34977. return *v, true
  34978. }
  34979. // OldModel returns the old "model" field's value of the UsageDetail entity.
  34980. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34982. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  34983. if !m.op.Is(OpUpdateOne) {
  34984. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  34985. }
  34986. if m.id == nil || m.oldValue == nil {
  34987. return v, errors.New("OldModel requires an ID field in the mutation")
  34988. }
  34989. oldValue, err := m.oldValue(ctx)
  34990. if err != nil {
  34991. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  34992. }
  34993. return oldValue.Model, nil
  34994. }
  34995. // ClearModel clears the value of the "model" field.
  34996. func (m *UsageDetailMutation) ClearModel() {
  34997. m.model = nil
  34998. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  34999. }
  35000. // ModelCleared returns if the "model" field was cleared in this mutation.
  35001. func (m *UsageDetailMutation) ModelCleared() bool {
  35002. _, ok := m.clearedFields[usagedetail.FieldModel]
  35003. return ok
  35004. }
  35005. // ResetModel resets all changes to the "model" field.
  35006. func (m *UsageDetailMutation) ResetModel() {
  35007. m.model = nil
  35008. delete(m.clearedFields, usagedetail.FieldModel)
  35009. }
  35010. // SetCredits sets the "credits" field.
  35011. func (m *UsageDetailMutation) SetCredits(f float64) {
  35012. m.credits = &f
  35013. m.addcredits = nil
  35014. }
  35015. // Credits returns the value of the "credits" field in the mutation.
  35016. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  35017. v := m.credits
  35018. if v == nil {
  35019. return
  35020. }
  35021. return *v, true
  35022. }
  35023. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  35024. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35026. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  35027. if !m.op.Is(OpUpdateOne) {
  35028. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  35029. }
  35030. if m.id == nil || m.oldValue == nil {
  35031. return v, errors.New("OldCredits requires an ID field in the mutation")
  35032. }
  35033. oldValue, err := m.oldValue(ctx)
  35034. if err != nil {
  35035. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  35036. }
  35037. return oldValue.Credits, nil
  35038. }
  35039. // AddCredits adds f to the "credits" field.
  35040. func (m *UsageDetailMutation) AddCredits(f float64) {
  35041. if m.addcredits != nil {
  35042. *m.addcredits += f
  35043. } else {
  35044. m.addcredits = &f
  35045. }
  35046. }
  35047. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  35048. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  35049. v := m.addcredits
  35050. if v == nil {
  35051. return
  35052. }
  35053. return *v, true
  35054. }
  35055. // ClearCredits clears the value of the "credits" field.
  35056. func (m *UsageDetailMutation) ClearCredits() {
  35057. m.credits = nil
  35058. m.addcredits = nil
  35059. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  35060. }
  35061. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  35062. func (m *UsageDetailMutation) CreditsCleared() bool {
  35063. _, ok := m.clearedFields[usagedetail.FieldCredits]
  35064. return ok
  35065. }
  35066. // ResetCredits resets all changes to the "credits" field.
  35067. func (m *UsageDetailMutation) ResetCredits() {
  35068. m.credits = nil
  35069. m.addcredits = nil
  35070. delete(m.clearedFields, usagedetail.FieldCredits)
  35071. }
  35072. // Where appends a list predicates to the UsageDetailMutation builder.
  35073. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  35074. m.predicates = append(m.predicates, ps...)
  35075. }
  35076. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  35077. // users can use type-assertion to append predicates that do not depend on any generated package.
  35078. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  35079. p := make([]predicate.UsageDetail, len(ps))
  35080. for i := range ps {
  35081. p[i] = ps[i]
  35082. }
  35083. m.Where(p...)
  35084. }
  35085. // Op returns the operation name.
  35086. func (m *UsageDetailMutation) Op() Op {
  35087. return m.op
  35088. }
  35089. // SetOp allows setting the mutation operation.
  35090. func (m *UsageDetailMutation) SetOp(op Op) {
  35091. m.op = op
  35092. }
  35093. // Type returns the node type of this mutation (UsageDetail).
  35094. func (m *UsageDetailMutation) Type() string {
  35095. return m.typ
  35096. }
  35097. // Fields returns all fields that were changed during this mutation. Note that in
  35098. // order to get all numeric fields that were incremented/decremented, call
  35099. // AddedFields().
  35100. func (m *UsageDetailMutation) Fields() []string {
  35101. fields := make([]string, 0, 17)
  35102. if m.created_at != nil {
  35103. fields = append(fields, usagedetail.FieldCreatedAt)
  35104. }
  35105. if m.updated_at != nil {
  35106. fields = append(fields, usagedetail.FieldUpdatedAt)
  35107. }
  35108. if m.status != nil {
  35109. fields = append(fields, usagedetail.FieldStatus)
  35110. }
  35111. if m._type != nil {
  35112. fields = append(fields, usagedetail.FieldType)
  35113. }
  35114. if m.bot_id != nil {
  35115. fields = append(fields, usagedetail.FieldBotID)
  35116. }
  35117. if m.receiver_id != nil {
  35118. fields = append(fields, usagedetail.FieldReceiverID)
  35119. }
  35120. if m.app != nil {
  35121. fields = append(fields, usagedetail.FieldApp)
  35122. }
  35123. if m.session_id != nil {
  35124. fields = append(fields, usagedetail.FieldSessionID)
  35125. }
  35126. if m.request != nil {
  35127. fields = append(fields, usagedetail.FieldRequest)
  35128. }
  35129. if m.response != nil {
  35130. fields = append(fields, usagedetail.FieldResponse)
  35131. }
  35132. if m.original_data != nil {
  35133. fields = append(fields, usagedetail.FieldOriginalData)
  35134. }
  35135. if m.total_tokens != nil {
  35136. fields = append(fields, usagedetail.FieldTotalTokens)
  35137. }
  35138. if m.prompt_tokens != nil {
  35139. fields = append(fields, usagedetail.FieldPromptTokens)
  35140. }
  35141. if m.completion_tokens != nil {
  35142. fields = append(fields, usagedetail.FieldCompletionTokens)
  35143. }
  35144. if m.organization_id != nil {
  35145. fields = append(fields, usagedetail.FieldOrganizationID)
  35146. }
  35147. if m.model != nil {
  35148. fields = append(fields, usagedetail.FieldModel)
  35149. }
  35150. if m.credits != nil {
  35151. fields = append(fields, usagedetail.FieldCredits)
  35152. }
  35153. return fields
  35154. }
  35155. // Field returns the value of a field with the given name. The second boolean
  35156. // return value indicates that this field was not set, or was not defined in the
  35157. // schema.
  35158. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  35159. switch name {
  35160. case usagedetail.FieldCreatedAt:
  35161. return m.CreatedAt()
  35162. case usagedetail.FieldUpdatedAt:
  35163. return m.UpdatedAt()
  35164. case usagedetail.FieldStatus:
  35165. return m.Status()
  35166. case usagedetail.FieldType:
  35167. return m.GetType()
  35168. case usagedetail.FieldBotID:
  35169. return m.BotID()
  35170. case usagedetail.FieldReceiverID:
  35171. return m.ReceiverID()
  35172. case usagedetail.FieldApp:
  35173. return m.App()
  35174. case usagedetail.FieldSessionID:
  35175. return m.SessionID()
  35176. case usagedetail.FieldRequest:
  35177. return m.Request()
  35178. case usagedetail.FieldResponse:
  35179. return m.Response()
  35180. case usagedetail.FieldOriginalData:
  35181. return m.OriginalData()
  35182. case usagedetail.FieldTotalTokens:
  35183. return m.TotalTokens()
  35184. case usagedetail.FieldPromptTokens:
  35185. return m.PromptTokens()
  35186. case usagedetail.FieldCompletionTokens:
  35187. return m.CompletionTokens()
  35188. case usagedetail.FieldOrganizationID:
  35189. return m.OrganizationID()
  35190. case usagedetail.FieldModel:
  35191. return m.Model()
  35192. case usagedetail.FieldCredits:
  35193. return m.Credits()
  35194. }
  35195. return nil, false
  35196. }
  35197. // OldField returns the old value of the field from the database. An error is
  35198. // returned if the mutation operation is not UpdateOne, or the query to the
  35199. // database failed.
  35200. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35201. switch name {
  35202. case usagedetail.FieldCreatedAt:
  35203. return m.OldCreatedAt(ctx)
  35204. case usagedetail.FieldUpdatedAt:
  35205. return m.OldUpdatedAt(ctx)
  35206. case usagedetail.FieldStatus:
  35207. return m.OldStatus(ctx)
  35208. case usagedetail.FieldType:
  35209. return m.OldType(ctx)
  35210. case usagedetail.FieldBotID:
  35211. return m.OldBotID(ctx)
  35212. case usagedetail.FieldReceiverID:
  35213. return m.OldReceiverID(ctx)
  35214. case usagedetail.FieldApp:
  35215. return m.OldApp(ctx)
  35216. case usagedetail.FieldSessionID:
  35217. return m.OldSessionID(ctx)
  35218. case usagedetail.FieldRequest:
  35219. return m.OldRequest(ctx)
  35220. case usagedetail.FieldResponse:
  35221. return m.OldResponse(ctx)
  35222. case usagedetail.FieldOriginalData:
  35223. return m.OldOriginalData(ctx)
  35224. case usagedetail.FieldTotalTokens:
  35225. return m.OldTotalTokens(ctx)
  35226. case usagedetail.FieldPromptTokens:
  35227. return m.OldPromptTokens(ctx)
  35228. case usagedetail.FieldCompletionTokens:
  35229. return m.OldCompletionTokens(ctx)
  35230. case usagedetail.FieldOrganizationID:
  35231. return m.OldOrganizationID(ctx)
  35232. case usagedetail.FieldModel:
  35233. return m.OldModel(ctx)
  35234. case usagedetail.FieldCredits:
  35235. return m.OldCredits(ctx)
  35236. }
  35237. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  35238. }
  35239. // SetField sets the value of a field with the given name. It returns an error if
  35240. // the field is not defined in the schema, or if the type mismatched the field
  35241. // type.
  35242. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  35243. switch name {
  35244. case usagedetail.FieldCreatedAt:
  35245. v, ok := value.(time.Time)
  35246. if !ok {
  35247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35248. }
  35249. m.SetCreatedAt(v)
  35250. return nil
  35251. case usagedetail.FieldUpdatedAt:
  35252. v, ok := value.(time.Time)
  35253. if !ok {
  35254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35255. }
  35256. m.SetUpdatedAt(v)
  35257. return nil
  35258. case usagedetail.FieldStatus:
  35259. v, ok := value.(uint8)
  35260. if !ok {
  35261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35262. }
  35263. m.SetStatus(v)
  35264. return nil
  35265. case usagedetail.FieldType:
  35266. v, ok := value.(int)
  35267. if !ok {
  35268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35269. }
  35270. m.SetType(v)
  35271. return nil
  35272. case usagedetail.FieldBotID:
  35273. v, ok := value.(string)
  35274. if !ok {
  35275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35276. }
  35277. m.SetBotID(v)
  35278. return nil
  35279. case usagedetail.FieldReceiverID:
  35280. v, ok := value.(string)
  35281. if !ok {
  35282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35283. }
  35284. m.SetReceiverID(v)
  35285. return nil
  35286. case usagedetail.FieldApp:
  35287. v, ok := value.(int)
  35288. if !ok {
  35289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35290. }
  35291. m.SetApp(v)
  35292. return nil
  35293. case usagedetail.FieldSessionID:
  35294. v, ok := value.(uint64)
  35295. if !ok {
  35296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35297. }
  35298. m.SetSessionID(v)
  35299. return nil
  35300. case usagedetail.FieldRequest:
  35301. v, ok := value.(string)
  35302. if !ok {
  35303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35304. }
  35305. m.SetRequest(v)
  35306. return nil
  35307. case usagedetail.FieldResponse:
  35308. v, ok := value.(string)
  35309. if !ok {
  35310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35311. }
  35312. m.SetResponse(v)
  35313. return nil
  35314. case usagedetail.FieldOriginalData:
  35315. v, ok := value.(custom_types.OriginalData)
  35316. if !ok {
  35317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35318. }
  35319. m.SetOriginalData(v)
  35320. return nil
  35321. case usagedetail.FieldTotalTokens:
  35322. v, ok := value.(uint64)
  35323. if !ok {
  35324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35325. }
  35326. m.SetTotalTokens(v)
  35327. return nil
  35328. case usagedetail.FieldPromptTokens:
  35329. v, ok := value.(uint64)
  35330. if !ok {
  35331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35332. }
  35333. m.SetPromptTokens(v)
  35334. return nil
  35335. case usagedetail.FieldCompletionTokens:
  35336. v, ok := value.(uint64)
  35337. if !ok {
  35338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35339. }
  35340. m.SetCompletionTokens(v)
  35341. return nil
  35342. case usagedetail.FieldOrganizationID:
  35343. v, ok := value.(uint64)
  35344. if !ok {
  35345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35346. }
  35347. m.SetOrganizationID(v)
  35348. return nil
  35349. case usagedetail.FieldModel:
  35350. v, ok := value.(string)
  35351. if !ok {
  35352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35353. }
  35354. m.SetModel(v)
  35355. return nil
  35356. case usagedetail.FieldCredits:
  35357. v, ok := value.(float64)
  35358. if !ok {
  35359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35360. }
  35361. m.SetCredits(v)
  35362. return nil
  35363. }
  35364. return fmt.Errorf("unknown UsageDetail field %s", name)
  35365. }
  35366. // AddedFields returns all numeric fields that were incremented/decremented during
  35367. // this mutation.
  35368. func (m *UsageDetailMutation) AddedFields() []string {
  35369. var fields []string
  35370. if m.addstatus != nil {
  35371. fields = append(fields, usagedetail.FieldStatus)
  35372. }
  35373. if m.add_type != nil {
  35374. fields = append(fields, usagedetail.FieldType)
  35375. }
  35376. if m.addapp != nil {
  35377. fields = append(fields, usagedetail.FieldApp)
  35378. }
  35379. if m.addsession_id != nil {
  35380. fields = append(fields, usagedetail.FieldSessionID)
  35381. }
  35382. if m.addtotal_tokens != nil {
  35383. fields = append(fields, usagedetail.FieldTotalTokens)
  35384. }
  35385. if m.addprompt_tokens != nil {
  35386. fields = append(fields, usagedetail.FieldPromptTokens)
  35387. }
  35388. if m.addcompletion_tokens != nil {
  35389. fields = append(fields, usagedetail.FieldCompletionTokens)
  35390. }
  35391. if m.addorganization_id != nil {
  35392. fields = append(fields, usagedetail.FieldOrganizationID)
  35393. }
  35394. if m.addcredits != nil {
  35395. fields = append(fields, usagedetail.FieldCredits)
  35396. }
  35397. return fields
  35398. }
  35399. // AddedField returns the numeric value that was incremented/decremented on a field
  35400. // with the given name. The second boolean return value indicates that this field
  35401. // was not set, or was not defined in the schema.
  35402. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  35403. switch name {
  35404. case usagedetail.FieldStatus:
  35405. return m.AddedStatus()
  35406. case usagedetail.FieldType:
  35407. return m.AddedType()
  35408. case usagedetail.FieldApp:
  35409. return m.AddedApp()
  35410. case usagedetail.FieldSessionID:
  35411. return m.AddedSessionID()
  35412. case usagedetail.FieldTotalTokens:
  35413. return m.AddedTotalTokens()
  35414. case usagedetail.FieldPromptTokens:
  35415. return m.AddedPromptTokens()
  35416. case usagedetail.FieldCompletionTokens:
  35417. return m.AddedCompletionTokens()
  35418. case usagedetail.FieldOrganizationID:
  35419. return m.AddedOrganizationID()
  35420. case usagedetail.FieldCredits:
  35421. return m.AddedCredits()
  35422. }
  35423. return nil, false
  35424. }
  35425. // AddField adds the value to the field with the given name. It returns an error if
  35426. // the field is not defined in the schema, or if the type mismatched the field
  35427. // type.
  35428. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  35429. switch name {
  35430. case usagedetail.FieldStatus:
  35431. v, ok := value.(int8)
  35432. if !ok {
  35433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35434. }
  35435. m.AddStatus(v)
  35436. return nil
  35437. case usagedetail.FieldType:
  35438. v, ok := value.(int)
  35439. if !ok {
  35440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35441. }
  35442. m.AddType(v)
  35443. return nil
  35444. case usagedetail.FieldApp:
  35445. v, ok := value.(int)
  35446. if !ok {
  35447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35448. }
  35449. m.AddApp(v)
  35450. return nil
  35451. case usagedetail.FieldSessionID:
  35452. v, ok := value.(int64)
  35453. if !ok {
  35454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35455. }
  35456. m.AddSessionID(v)
  35457. return nil
  35458. case usagedetail.FieldTotalTokens:
  35459. v, ok := value.(int64)
  35460. if !ok {
  35461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35462. }
  35463. m.AddTotalTokens(v)
  35464. return nil
  35465. case usagedetail.FieldPromptTokens:
  35466. v, ok := value.(int64)
  35467. if !ok {
  35468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35469. }
  35470. m.AddPromptTokens(v)
  35471. return nil
  35472. case usagedetail.FieldCompletionTokens:
  35473. v, ok := value.(int64)
  35474. if !ok {
  35475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35476. }
  35477. m.AddCompletionTokens(v)
  35478. return nil
  35479. case usagedetail.FieldOrganizationID:
  35480. v, ok := value.(int64)
  35481. if !ok {
  35482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35483. }
  35484. m.AddOrganizationID(v)
  35485. return nil
  35486. case usagedetail.FieldCredits:
  35487. v, ok := value.(float64)
  35488. if !ok {
  35489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35490. }
  35491. m.AddCredits(v)
  35492. return nil
  35493. }
  35494. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  35495. }
  35496. // ClearedFields returns all nullable fields that were cleared during this
  35497. // mutation.
  35498. func (m *UsageDetailMutation) ClearedFields() []string {
  35499. var fields []string
  35500. if m.FieldCleared(usagedetail.FieldStatus) {
  35501. fields = append(fields, usagedetail.FieldStatus)
  35502. }
  35503. if m.FieldCleared(usagedetail.FieldType) {
  35504. fields = append(fields, usagedetail.FieldType)
  35505. }
  35506. if m.FieldCleared(usagedetail.FieldApp) {
  35507. fields = append(fields, usagedetail.FieldApp)
  35508. }
  35509. if m.FieldCleared(usagedetail.FieldSessionID) {
  35510. fields = append(fields, usagedetail.FieldSessionID)
  35511. }
  35512. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  35513. fields = append(fields, usagedetail.FieldTotalTokens)
  35514. }
  35515. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  35516. fields = append(fields, usagedetail.FieldPromptTokens)
  35517. }
  35518. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  35519. fields = append(fields, usagedetail.FieldCompletionTokens)
  35520. }
  35521. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  35522. fields = append(fields, usagedetail.FieldOrganizationID)
  35523. }
  35524. if m.FieldCleared(usagedetail.FieldModel) {
  35525. fields = append(fields, usagedetail.FieldModel)
  35526. }
  35527. if m.FieldCleared(usagedetail.FieldCredits) {
  35528. fields = append(fields, usagedetail.FieldCredits)
  35529. }
  35530. return fields
  35531. }
  35532. // FieldCleared returns a boolean indicating if a field with the given name was
  35533. // cleared in this mutation.
  35534. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  35535. _, ok := m.clearedFields[name]
  35536. return ok
  35537. }
  35538. // ClearField clears the value of the field with the given name. It returns an
  35539. // error if the field is not defined in the schema.
  35540. func (m *UsageDetailMutation) ClearField(name string) error {
  35541. switch name {
  35542. case usagedetail.FieldStatus:
  35543. m.ClearStatus()
  35544. return nil
  35545. case usagedetail.FieldType:
  35546. m.ClearType()
  35547. return nil
  35548. case usagedetail.FieldApp:
  35549. m.ClearApp()
  35550. return nil
  35551. case usagedetail.FieldSessionID:
  35552. m.ClearSessionID()
  35553. return nil
  35554. case usagedetail.FieldTotalTokens:
  35555. m.ClearTotalTokens()
  35556. return nil
  35557. case usagedetail.FieldPromptTokens:
  35558. m.ClearPromptTokens()
  35559. return nil
  35560. case usagedetail.FieldCompletionTokens:
  35561. m.ClearCompletionTokens()
  35562. return nil
  35563. case usagedetail.FieldOrganizationID:
  35564. m.ClearOrganizationID()
  35565. return nil
  35566. case usagedetail.FieldModel:
  35567. m.ClearModel()
  35568. return nil
  35569. case usagedetail.FieldCredits:
  35570. m.ClearCredits()
  35571. return nil
  35572. }
  35573. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  35574. }
  35575. // ResetField resets all changes in the mutation for the field with the given name.
  35576. // It returns an error if the field is not defined in the schema.
  35577. func (m *UsageDetailMutation) ResetField(name string) error {
  35578. switch name {
  35579. case usagedetail.FieldCreatedAt:
  35580. m.ResetCreatedAt()
  35581. return nil
  35582. case usagedetail.FieldUpdatedAt:
  35583. m.ResetUpdatedAt()
  35584. return nil
  35585. case usagedetail.FieldStatus:
  35586. m.ResetStatus()
  35587. return nil
  35588. case usagedetail.FieldType:
  35589. m.ResetType()
  35590. return nil
  35591. case usagedetail.FieldBotID:
  35592. m.ResetBotID()
  35593. return nil
  35594. case usagedetail.FieldReceiverID:
  35595. m.ResetReceiverID()
  35596. return nil
  35597. case usagedetail.FieldApp:
  35598. m.ResetApp()
  35599. return nil
  35600. case usagedetail.FieldSessionID:
  35601. m.ResetSessionID()
  35602. return nil
  35603. case usagedetail.FieldRequest:
  35604. m.ResetRequest()
  35605. return nil
  35606. case usagedetail.FieldResponse:
  35607. m.ResetResponse()
  35608. return nil
  35609. case usagedetail.FieldOriginalData:
  35610. m.ResetOriginalData()
  35611. return nil
  35612. case usagedetail.FieldTotalTokens:
  35613. m.ResetTotalTokens()
  35614. return nil
  35615. case usagedetail.FieldPromptTokens:
  35616. m.ResetPromptTokens()
  35617. return nil
  35618. case usagedetail.FieldCompletionTokens:
  35619. m.ResetCompletionTokens()
  35620. return nil
  35621. case usagedetail.FieldOrganizationID:
  35622. m.ResetOrganizationID()
  35623. return nil
  35624. case usagedetail.FieldModel:
  35625. m.ResetModel()
  35626. return nil
  35627. case usagedetail.FieldCredits:
  35628. m.ResetCredits()
  35629. return nil
  35630. }
  35631. return fmt.Errorf("unknown UsageDetail field %s", name)
  35632. }
  35633. // AddedEdges returns all edge names that were set/added in this mutation.
  35634. func (m *UsageDetailMutation) AddedEdges() []string {
  35635. edges := make([]string, 0, 0)
  35636. return edges
  35637. }
  35638. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35639. // name in this mutation.
  35640. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  35641. return nil
  35642. }
  35643. // RemovedEdges returns all edge names that were removed in this mutation.
  35644. func (m *UsageDetailMutation) RemovedEdges() []string {
  35645. edges := make([]string, 0, 0)
  35646. return edges
  35647. }
  35648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35649. // the given name in this mutation.
  35650. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  35651. return nil
  35652. }
  35653. // ClearedEdges returns all edge names that were cleared in this mutation.
  35654. func (m *UsageDetailMutation) ClearedEdges() []string {
  35655. edges := make([]string, 0, 0)
  35656. return edges
  35657. }
  35658. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35659. // was cleared in this mutation.
  35660. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  35661. return false
  35662. }
  35663. // ClearEdge clears the value of the edge with the given name. It returns an error
  35664. // if that edge is not defined in the schema.
  35665. func (m *UsageDetailMutation) ClearEdge(name string) error {
  35666. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  35667. }
  35668. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35669. // It returns an error if the edge is not defined in the schema.
  35670. func (m *UsageDetailMutation) ResetEdge(name string) error {
  35671. return fmt.Errorf("unknown UsageDetail edge %s", name)
  35672. }
  35673. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  35674. type UsageStatisticDayMutation struct {
  35675. config
  35676. op Op
  35677. typ string
  35678. id *uint64
  35679. created_at *time.Time
  35680. updated_at *time.Time
  35681. status *uint8
  35682. addstatus *int8
  35683. deleted_at *time.Time
  35684. addtime *uint64
  35685. addaddtime *int64
  35686. _type *int
  35687. add_type *int
  35688. bot_id *string
  35689. organization_id *uint64
  35690. addorganization_id *int64
  35691. ai_response *uint64
  35692. addai_response *int64
  35693. sop_run *uint64
  35694. addsop_run *int64
  35695. total_friend *uint64
  35696. addtotal_friend *int64
  35697. total_group *uint64
  35698. addtotal_group *int64
  35699. account_balance *uint64
  35700. addaccount_balance *int64
  35701. consume_token *uint64
  35702. addconsume_token *int64
  35703. active_user *uint64
  35704. addactive_user *int64
  35705. new_user *int64
  35706. addnew_user *int64
  35707. label_dist *[]custom_types.LabelDist
  35708. appendlabel_dist []custom_types.LabelDist
  35709. consume_coin *float64
  35710. addconsume_coin *float64
  35711. clearedFields map[string]struct{}
  35712. done bool
  35713. oldValue func(context.Context) (*UsageStatisticDay, error)
  35714. predicates []predicate.UsageStatisticDay
  35715. }
  35716. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  35717. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  35718. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  35719. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  35720. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  35721. m := &UsageStatisticDayMutation{
  35722. config: c,
  35723. op: op,
  35724. typ: TypeUsageStatisticDay,
  35725. clearedFields: make(map[string]struct{}),
  35726. }
  35727. for _, opt := range opts {
  35728. opt(m)
  35729. }
  35730. return m
  35731. }
  35732. // withUsageStatisticDayID sets the ID field of the mutation.
  35733. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  35734. return func(m *UsageStatisticDayMutation) {
  35735. var (
  35736. err error
  35737. once sync.Once
  35738. value *UsageStatisticDay
  35739. )
  35740. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  35741. once.Do(func() {
  35742. if m.done {
  35743. err = errors.New("querying old values post mutation is not allowed")
  35744. } else {
  35745. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  35746. }
  35747. })
  35748. return value, err
  35749. }
  35750. m.id = &id
  35751. }
  35752. }
  35753. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  35754. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  35755. return func(m *UsageStatisticDayMutation) {
  35756. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  35757. return node, nil
  35758. }
  35759. m.id = &node.ID
  35760. }
  35761. }
  35762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35763. // executed in a transaction (ent.Tx), a transactional client is returned.
  35764. func (m UsageStatisticDayMutation) Client() *Client {
  35765. client := &Client{config: m.config}
  35766. client.init()
  35767. return client
  35768. }
  35769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35770. // it returns an error otherwise.
  35771. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  35772. if _, ok := m.driver.(*txDriver); !ok {
  35773. return nil, errors.New("ent: mutation is not running in a transaction")
  35774. }
  35775. tx := &Tx{config: m.config}
  35776. tx.init()
  35777. return tx, nil
  35778. }
  35779. // SetID sets the value of the id field. Note that this
  35780. // operation is only accepted on creation of UsageStatisticDay entities.
  35781. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  35782. m.id = &id
  35783. }
  35784. // ID returns the ID value in the mutation. Note that the ID is only available
  35785. // if it was provided to the builder or after it was returned from the database.
  35786. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  35787. if m.id == nil {
  35788. return
  35789. }
  35790. return *m.id, true
  35791. }
  35792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35793. // That means, if the mutation is applied within a transaction with an isolation level such
  35794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35795. // or updated by the mutation.
  35796. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  35797. switch {
  35798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35799. id, exists := m.ID()
  35800. if exists {
  35801. return []uint64{id}, nil
  35802. }
  35803. fallthrough
  35804. case m.op.Is(OpUpdate | OpDelete):
  35805. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  35806. default:
  35807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35808. }
  35809. }
  35810. // SetCreatedAt sets the "created_at" field.
  35811. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  35812. m.created_at = &t
  35813. }
  35814. // CreatedAt returns the value of the "created_at" field in the mutation.
  35815. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  35816. v := m.created_at
  35817. if v == nil {
  35818. return
  35819. }
  35820. return *v, true
  35821. }
  35822. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  35823. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35825. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35826. if !m.op.Is(OpUpdateOne) {
  35827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35828. }
  35829. if m.id == nil || m.oldValue == nil {
  35830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35831. }
  35832. oldValue, err := m.oldValue(ctx)
  35833. if err != nil {
  35834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35835. }
  35836. return oldValue.CreatedAt, nil
  35837. }
  35838. // ResetCreatedAt resets all changes to the "created_at" field.
  35839. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  35840. m.created_at = nil
  35841. }
  35842. // SetUpdatedAt sets the "updated_at" field.
  35843. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  35844. m.updated_at = &t
  35845. }
  35846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35847. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  35848. v := m.updated_at
  35849. if v == nil {
  35850. return
  35851. }
  35852. return *v, true
  35853. }
  35854. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  35855. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35857. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35858. if !m.op.Is(OpUpdateOne) {
  35859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35860. }
  35861. if m.id == nil || m.oldValue == nil {
  35862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35863. }
  35864. oldValue, err := m.oldValue(ctx)
  35865. if err != nil {
  35866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35867. }
  35868. return oldValue.UpdatedAt, nil
  35869. }
  35870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35871. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  35872. m.updated_at = nil
  35873. }
  35874. // SetStatus sets the "status" field.
  35875. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  35876. m.status = &u
  35877. m.addstatus = nil
  35878. }
  35879. // Status returns the value of the "status" field in the mutation.
  35880. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  35881. v := m.status
  35882. if v == nil {
  35883. return
  35884. }
  35885. return *v, true
  35886. }
  35887. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  35888. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35890. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35891. if !m.op.Is(OpUpdateOne) {
  35892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35893. }
  35894. if m.id == nil || m.oldValue == nil {
  35895. return v, errors.New("OldStatus requires an ID field in the mutation")
  35896. }
  35897. oldValue, err := m.oldValue(ctx)
  35898. if err != nil {
  35899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35900. }
  35901. return oldValue.Status, nil
  35902. }
  35903. // AddStatus adds u to the "status" field.
  35904. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  35905. if m.addstatus != nil {
  35906. *m.addstatus += u
  35907. } else {
  35908. m.addstatus = &u
  35909. }
  35910. }
  35911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35912. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  35913. v := m.addstatus
  35914. if v == nil {
  35915. return
  35916. }
  35917. return *v, true
  35918. }
  35919. // ClearStatus clears the value of the "status" field.
  35920. func (m *UsageStatisticDayMutation) ClearStatus() {
  35921. m.status = nil
  35922. m.addstatus = nil
  35923. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  35924. }
  35925. // StatusCleared returns if the "status" field was cleared in this mutation.
  35926. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  35927. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  35928. return ok
  35929. }
  35930. // ResetStatus resets all changes to the "status" field.
  35931. func (m *UsageStatisticDayMutation) ResetStatus() {
  35932. m.status = nil
  35933. m.addstatus = nil
  35934. delete(m.clearedFields, usagestatisticday.FieldStatus)
  35935. }
  35936. // SetDeletedAt sets the "deleted_at" field.
  35937. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  35938. m.deleted_at = &t
  35939. }
  35940. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35941. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  35942. v := m.deleted_at
  35943. if v == nil {
  35944. return
  35945. }
  35946. return *v, true
  35947. }
  35948. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  35949. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35951. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35952. if !m.op.Is(OpUpdateOne) {
  35953. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35954. }
  35955. if m.id == nil || m.oldValue == nil {
  35956. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35957. }
  35958. oldValue, err := m.oldValue(ctx)
  35959. if err != nil {
  35960. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35961. }
  35962. return oldValue.DeletedAt, nil
  35963. }
  35964. // ClearDeletedAt clears the value of the "deleted_at" field.
  35965. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  35966. m.deleted_at = nil
  35967. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  35968. }
  35969. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35970. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  35971. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  35972. return ok
  35973. }
  35974. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35975. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  35976. m.deleted_at = nil
  35977. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  35978. }
  35979. // SetAddtime sets the "addtime" field.
  35980. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  35981. m.addtime = &u
  35982. m.addaddtime = nil
  35983. }
  35984. // Addtime returns the value of the "addtime" field in the mutation.
  35985. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  35986. v := m.addtime
  35987. if v == nil {
  35988. return
  35989. }
  35990. return *v, true
  35991. }
  35992. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  35993. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35995. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35996. if !m.op.Is(OpUpdateOne) {
  35997. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35998. }
  35999. if m.id == nil || m.oldValue == nil {
  36000. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36001. }
  36002. oldValue, err := m.oldValue(ctx)
  36003. if err != nil {
  36004. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36005. }
  36006. return oldValue.Addtime, nil
  36007. }
  36008. // AddAddtime adds u to the "addtime" field.
  36009. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  36010. if m.addaddtime != nil {
  36011. *m.addaddtime += u
  36012. } else {
  36013. m.addaddtime = &u
  36014. }
  36015. }
  36016. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36017. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  36018. v := m.addaddtime
  36019. if v == nil {
  36020. return
  36021. }
  36022. return *v, true
  36023. }
  36024. // ResetAddtime resets all changes to the "addtime" field.
  36025. func (m *UsageStatisticDayMutation) ResetAddtime() {
  36026. m.addtime = nil
  36027. m.addaddtime = nil
  36028. }
  36029. // SetType sets the "type" field.
  36030. func (m *UsageStatisticDayMutation) SetType(i int) {
  36031. m._type = &i
  36032. m.add_type = nil
  36033. }
  36034. // GetType returns the value of the "type" field in the mutation.
  36035. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  36036. v := m._type
  36037. if v == nil {
  36038. return
  36039. }
  36040. return *v, true
  36041. }
  36042. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  36043. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36045. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  36046. if !m.op.Is(OpUpdateOne) {
  36047. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36048. }
  36049. if m.id == nil || m.oldValue == nil {
  36050. return v, errors.New("OldType requires an ID field in the mutation")
  36051. }
  36052. oldValue, err := m.oldValue(ctx)
  36053. if err != nil {
  36054. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36055. }
  36056. return oldValue.Type, nil
  36057. }
  36058. // AddType adds i to the "type" field.
  36059. func (m *UsageStatisticDayMutation) AddType(i int) {
  36060. if m.add_type != nil {
  36061. *m.add_type += i
  36062. } else {
  36063. m.add_type = &i
  36064. }
  36065. }
  36066. // AddedType returns the value that was added to the "type" field in this mutation.
  36067. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  36068. v := m.add_type
  36069. if v == nil {
  36070. return
  36071. }
  36072. return *v, true
  36073. }
  36074. // ResetType resets all changes to the "type" field.
  36075. func (m *UsageStatisticDayMutation) ResetType() {
  36076. m._type = nil
  36077. m.add_type = nil
  36078. }
  36079. // SetBotID sets the "bot_id" field.
  36080. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  36081. m.bot_id = &s
  36082. }
  36083. // BotID returns the value of the "bot_id" field in the mutation.
  36084. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  36085. v := m.bot_id
  36086. if v == nil {
  36087. return
  36088. }
  36089. return *v, true
  36090. }
  36091. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  36092. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36094. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  36095. if !m.op.Is(OpUpdateOne) {
  36096. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36097. }
  36098. if m.id == nil || m.oldValue == nil {
  36099. return v, errors.New("OldBotID requires an ID field in the mutation")
  36100. }
  36101. oldValue, err := m.oldValue(ctx)
  36102. if err != nil {
  36103. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36104. }
  36105. return oldValue.BotID, nil
  36106. }
  36107. // ClearBotID clears the value of the "bot_id" field.
  36108. func (m *UsageStatisticDayMutation) ClearBotID() {
  36109. m.bot_id = nil
  36110. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  36111. }
  36112. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36113. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  36114. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  36115. return ok
  36116. }
  36117. // ResetBotID resets all changes to the "bot_id" field.
  36118. func (m *UsageStatisticDayMutation) ResetBotID() {
  36119. m.bot_id = nil
  36120. delete(m.clearedFields, usagestatisticday.FieldBotID)
  36121. }
  36122. // SetOrganizationID sets the "organization_id" field.
  36123. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  36124. m.organization_id = &u
  36125. m.addorganization_id = nil
  36126. }
  36127. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36128. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  36129. v := m.organization_id
  36130. if v == nil {
  36131. return
  36132. }
  36133. return *v, true
  36134. }
  36135. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  36136. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36138. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36139. if !m.op.Is(OpUpdateOne) {
  36140. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36141. }
  36142. if m.id == nil || m.oldValue == nil {
  36143. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36144. }
  36145. oldValue, err := m.oldValue(ctx)
  36146. if err != nil {
  36147. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36148. }
  36149. return oldValue.OrganizationID, nil
  36150. }
  36151. // AddOrganizationID adds u to the "organization_id" field.
  36152. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  36153. if m.addorganization_id != nil {
  36154. *m.addorganization_id += u
  36155. } else {
  36156. m.addorganization_id = &u
  36157. }
  36158. }
  36159. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36160. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  36161. v := m.addorganization_id
  36162. if v == nil {
  36163. return
  36164. }
  36165. return *v, true
  36166. }
  36167. // ClearOrganizationID clears the value of the "organization_id" field.
  36168. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  36169. m.organization_id = nil
  36170. m.addorganization_id = nil
  36171. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  36172. }
  36173. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36174. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  36175. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  36176. return ok
  36177. }
  36178. // ResetOrganizationID resets all changes to the "organization_id" field.
  36179. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  36180. m.organization_id = nil
  36181. m.addorganization_id = nil
  36182. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  36183. }
  36184. // SetAiResponse sets the "ai_response" field.
  36185. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  36186. m.ai_response = &u
  36187. m.addai_response = nil
  36188. }
  36189. // AiResponse returns the value of the "ai_response" field in the mutation.
  36190. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  36191. v := m.ai_response
  36192. if v == nil {
  36193. return
  36194. }
  36195. return *v, true
  36196. }
  36197. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  36198. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36200. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36201. if !m.op.Is(OpUpdateOne) {
  36202. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36203. }
  36204. if m.id == nil || m.oldValue == nil {
  36205. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36206. }
  36207. oldValue, err := m.oldValue(ctx)
  36208. if err != nil {
  36209. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36210. }
  36211. return oldValue.AiResponse, nil
  36212. }
  36213. // AddAiResponse adds u to the "ai_response" field.
  36214. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  36215. if m.addai_response != nil {
  36216. *m.addai_response += u
  36217. } else {
  36218. m.addai_response = &u
  36219. }
  36220. }
  36221. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36222. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  36223. v := m.addai_response
  36224. if v == nil {
  36225. return
  36226. }
  36227. return *v, true
  36228. }
  36229. // ResetAiResponse resets all changes to the "ai_response" field.
  36230. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  36231. m.ai_response = nil
  36232. m.addai_response = nil
  36233. }
  36234. // SetSopRun sets the "sop_run" field.
  36235. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  36236. m.sop_run = &u
  36237. m.addsop_run = nil
  36238. }
  36239. // SopRun returns the value of the "sop_run" field in the mutation.
  36240. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  36241. v := m.sop_run
  36242. if v == nil {
  36243. return
  36244. }
  36245. return *v, true
  36246. }
  36247. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  36248. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36250. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36251. if !m.op.Is(OpUpdateOne) {
  36252. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36253. }
  36254. if m.id == nil || m.oldValue == nil {
  36255. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36256. }
  36257. oldValue, err := m.oldValue(ctx)
  36258. if err != nil {
  36259. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36260. }
  36261. return oldValue.SopRun, nil
  36262. }
  36263. // AddSopRun adds u to the "sop_run" field.
  36264. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  36265. if m.addsop_run != nil {
  36266. *m.addsop_run += u
  36267. } else {
  36268. m.addsop_run = &u
  36269. }
  36270. }
  36271. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36272. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  36273. v := m.addsop_run
  36274. if v == nil {
  36275. return
  36276. }
  36277. return *v, true
  36278. }
  36279. // ResetSopRun resets all changes to the "sop_run" field.
  36280. func (m *UsageStatisticDayMutation) ResetSopRun() {
  36281. m.sop_run = nil
  36282. m.addsop_run = nil
  36283. }
  36284. // SetTotalFriend sets the "total_friend" field.
  36285. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  36286. m.total_friend = &u
  36287. m.addtotal_friend = nil
  36288. }
  36289. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36290. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  36291. v := m.total_friend
  36292. if v == nil {
  36293. return
  36294. }
  36295. return *v, true
  36296. }
  36297. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  36298. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36300. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36301. if !m.op.Is(OpUpdateOne) {
  36302. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36303. }
  36304. if m.id == nil || m.oldValue == nil {
  36305. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36306. }
  36307. oldValue, err := m.oldValue(ctx)
  36308. if err != nil {
  36309. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36310. }
  36311. return oldValue.TotalFriend, nil
  36312. }
  36313. // AddTotalFriend adds u to the "total_friend" field.
  36314. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  36315. if m.addtotal_friend != nil {
  36316. *m.addtotal_friend += u
  36317. } else {
  36318. m.addtotal_friend = &u
  36319. }
  36320. }
  36321. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36322. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  36323. v := m.addtotal_friend
  36324. if v == nil {
  36325. return
  36326. }
  36327. return *v, true
  36328. }
  36329. // ResetTotalFriend resets all changes to the "total_friend" field.
  36330. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  36331. m.total_friend = nil
  36332. m.addtotal_friend = nil
  36333. }
  36334. // SetTotalGroup sets the "total_group" field.
  36335. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  36336. m.total_group = &u
  36337. m.addtotal_group = nil
  36338. }
  36339. // TotalGroup returns the value of the "total_group" field in the mutation.
  36340. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  36341. v := m.total_group
  36342. if v == nil {
  36343. return
  36344. }
  36345. return *v, true
  36346. }
  36347. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  36348. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36350. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36351. if !m.op.Is(OpUpdateOne) {
  36352. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36353. }
  36354. if m.id == nil || m.oldValue == nil {
  36355. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36356. }
  36357. oldValue, err := m.oldValue(ctx)
  36358. if err != nil {
  36359. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36360. }
  36361. return oldValue.TotalGroup, nil
  36362. }
  36363. // AddTotalGroup adds u to the "total_group" field.
  36364. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  36365. if m.addtotal_group != nil {
  36366. *m.addtotal_group += u
  36367. } else {
  36368. m.addtotal_group = &u
  36369. }
  36370. }
  36371. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36372. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  36373. v := m.addtotal_group
  36374. if v == nil {
  36375. return
  36376. }
  36377. return *v, true
  36378. }
  36379. // ResetTotalGroup resets all changes to the "total_group" field.
  36380. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  36381. m.total_group = nil
  36382. m.addtotal_group = nil
  36383. }
  36384. // SetAccountBalance sets the "account_balance" field.
  36385. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  36386. m.account_balance = &u
  36387. m.addaccount_balance = nil
  36388. }
  36389. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36390. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  36391. v := m.account_balance
  36392. if v == nil {
  36393. return
  36394. }
  36395. return *v, true
  36396. }
  36397. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  36398. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36400. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36401. if !m.op.Is(OpUpdateOne) {
  36402. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36403. }
  36404. if m.id == nil || m.oldValue == nil {
  36405. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36406. }
  36407. oldValue, err := m.oldValue(ctx)
  36408. if err != nil {
  36409. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36410. }
  36411. return oldValue.AccountBalance, nil
  36412. }
  36413. // AddAccountBalance adds u to the "account_balance" field.
  36414. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  36415. if m.addaccount_balance != nil {
  36416. *m.addaccount_balance += u
  36417. } else {
  36418. m.addaccount_balance = &u
  36419. }
  36420. }
  36421. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36422. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  36423. v := m.addaccount_balance
  36424. if v == nil {
  36425. return
  36426. }
  36427. return *v, true
  36428. }
  36429. // ResetAccountBalance resets all changes to the "account_balance" field.
  36430. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  36431. m.account_balance = nil
  36432. m.addaccount_balance = nil
  36433. }
  36434. // SetConsumeToken sets the "consume_token" field.
  36435. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  36436. m.consume_token = &u
  36437. m.addconsume_token = nil
  36438. }
  36439. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36440. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  36441. v := m.consume_token
  36442. if v == nil {
  36443. return
  36444. }
  36445. return *v, true
  36446. }
  36447. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  36448. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36450. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36451. if !m.op.Is(OpUpdateOne) {
  36452. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36453. }
  36454. if m.id == nil || m.oldValue == nil {
  36455. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36456. }
  36457. oldValue, err := m.oldValue(ctx)
  36458. if err != nil {
  36459. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36460. }
  36461. return oldValue.ConsumeToken, nil
  36462. }
  36463. // AddConsumeToken adds u to the "consume_token" field.
  36464. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  36465. if m.addconsume_token != nil {
  36466. *m.addconsume_token += u
  36467. } else {
  36468. m.addconsume_token = &u
  36469. }
  36470. }
  36471. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36472. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  36473. v := m.addconsume_token
  36474. if v == nil {
  36475. return
  36476. }
  36477. return *v, true
  36478. }
  36479. // ResetConsumeToken resets all changes to the "consume_token" field.
  36480. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  36481. m.consume_token = nil
  36482. m.addconsume_token = nil
  36483. }
  36484. // SetActiveUser sets the "active_user" field.
  36485. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  36486. m.active_user = &u
  36487. m.addactive_user = nil
  36488. }
  36489. // ActiveUser returns the value of the "active_user" field in the mutation.
  36490. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  36491. v := m.active_user
  36492. if v == nil {
  36493. return
  36494. }
  36495. return *v, true
  36496. }
  36497. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  36498. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36500. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36501. if !m.op.Is(OpUpdateOne) {
  36502. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36503. }
  36504. if m.id == nil || m.oldValue == nil {
  36505. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36506. }
  36507. oldValue, err := m.oldValue(ctx)
  36508. if err != nil {
  36509. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36510. }
  36511. return oldValue.ActiveUser, nil
  36512. }
  36513. // AddActiveUser adds u to the "active_user" field.
  36514. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  36515. if m.addactive_user != nil {
  36516. *m.addactive_user += u
  36517. } else {
  36518. m.addactive_user = &u
  36519. }
  36520. }
  36521. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36522. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  36523. v := m.addactive_user
  36524. if v == nil {
  36525. return
  36526. }
  36527. return *v, true
  36528. }
  36529. // ResetActiveUser resets all changes to the "active_user" field.
  36530. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  36531. m.active_user = nil
  36532. m.addactive_user = nil
  36533. }
  36534. // SetNewUser sets the "new_user" field.
  36535. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  36536. m.new_user = &i
  36537. m.addnew_user = nil
  36538. }
  36539. // NewUser returns the value of the "new_user" field in the mutation.
  36540. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  36541. v := m.new_user
  36542. if v == nil {
  36543. return
  36544. }
  36545. return *v, true
  36546. }
  36547. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  36548. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36550. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36551. if !m.op.Is(OpUpdateOne) {
  36552. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36553. }
  36554. if m.id == nil || m.oldValue == nil {
  36555. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36556. }
  36557. oldValue, err := m.oldValue(ctx)
  36558. if err != nil {
  36559. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36560. }
  36561. return oldValue.NewUser, nil
  36562. }
  36563. // AddNewUser adds i to the "new_user" field.
  36564. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  36565. if m.addnew_user != nil {
  36566. *m.addnew_user += i
  36567. } else {
  36568. m.addnew_user = &i
  36569. }
  36570. }
  36571. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36572. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  36573. v := m.addnew_user
  36574. if v == nil {
  36575. return
  36576. }
  36577. return *v, true
  36578. }
  36579. // ResetNewUser resets all changes to the "new_user" field.
  36580. func (m *UsageStatisticDayMutation) ResetNewUser() {
  36581. m.new_user = nil
  36582. m.addnew_user = nil
  36583. }
  36584. // SetLabelDist sets the "label_dist" field.
  36585. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36586. m.label_dist = &ctd
  36587. m.appendlabel_dist = nil
  36588. }
  36589. // LabelDist returns the value of the "label_dist" field in the mutation.
  36590. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36591. v := m.label_dist
  36592. if v == nil {
  36593. return
  36594. }
  36595. return *v, true
  36596. }
  36597. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  36598. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36600. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36601. if !m.op.Is(OpUpdateOne) {
  36602. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36603. }
  36604. if m.id == nil || m.oldValue == nil {
  36605. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36606. }
  36607. oldValue, err := m.oldValue(ctx)
  36608. if err != nil {
  36609. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36610. }
  36611. return oldValue.LabelDist, nil
  36612. }
  36613. // AppendLabelDist adds ctd to the "label_dist" field.
  36614. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36615. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36616. }
  36617. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36618. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36619. if len(m.appendlabel_dist) == 0 {
  36620. return nil, false
  36621. }
  36622. return m.appendlabel_dist, true
  36623. }
  36624. // ResetLabelDist resets all changes to the "label_dist" field.
  36625. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  36626. m.label_dist = nil
  36627. m.appendlabel_dist = nil
  36628. }
  36629. // SetConsumeCoin sets the "consume_coin" field.
  36630. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  36631. m.consume_coin = &f
  36632. m.addconsume_coin = nil
  36633. }
  36634. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36635. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  36636. v := m.consume_coin
  36637. if v == nil {
  36638. return
  36639. }
  36640. return *v, true
  36641. }
  36642. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  36643. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36645. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  36646. if !m.op.Is(OpUpdateOne) {
  36647. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36648. }
  36649. if m.id == nil || m.oldValue == nil {
  36650. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36651. }
  36652. oldValue, err := m.oldValue(ctx)
  36653. if err != nil {
  36654. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36655. }
  36656. return oldValue.ConsumeCoin, nil
  36657. }
  36658. // AddConsumeCoin adds f to the "consume_coin" field.
  36659. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  36660. if m.addconsume_coin != nil {
  36661. *m.addconsume_coin += f
  36662. } else {
  36663. m.addconsume_coin = &f
  36664. }
  36665. }
  36666. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36667. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  36668. v := m.addconsume_coin
  36669. if v == nil {
  36670. return
  36671. }
  36672. return *v, true
  36673. }
  36674. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36675. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  36676. m.consume_coin = nil
  36677. m.addconsume_coin = nil
  36678. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  36679. }
  36680. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36681. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  36682. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  36683. return ok
  36684. }
  36685. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36686. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  36687. m.consume_coin = nil
  36688. m.addconsume_coin = nil
  36689. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  36690. }
  36691. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  36692. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  36693. m.predicates = append(m.predicates, ps...)
  36694. }
  36695. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  36696. // users can use type-assertion to append predicates that do not depend on any generated package.
  36697. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  36698. p := make([]predicate.UsageStatisticDay, len(ps))
  36699. for i := range ps {
  36700. p[i] = ps[i]
  36701. }
  36702. m.Where(p...)
  36703. }
  36704. // Op returns the operation name.
  36705. func (m *UsageStatisticDayMutation) Op() Op {
  36706. return m.op
  36707. }
  36708. // SetOp allows setting the mutation operation.
  36709. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  36710. m.op = op
  36711. }
  36712. // Type returns the node type of this mutation (UsageStatisticDay).
  36713. func (m *UsageStatisticDayMutation) Type() string {
  36714. return m.typ
  36715. }
  36716. // Fields returns all fields that were changed during this mutation. Note that in
  36717. // order to get all numeric fields that were incremented/decremented, call
  36718. // AddedFields().
  36719. func (m *UsageStatisticDayMutation) Fields() []string {
  36720. fields := make([]string, 0, 18)
  36721. if m.created_at != nil {
  36722. fields = append(fields, usagestatisticday.FieldCreatedAt)
  36723. }
  36724. if m.updated_at != nil {
  36725. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  36726. }
  36727. if m.status != nil {
  36728. fields = append(fields, usagestatisticday.FieldStatus)
  36729. }
  36730. if m.deleted_at != nil {
  36731. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36732. }
  36733. if m.addtime != nil {
  36734. fields = append(fields, usagestatisticday.FieldAddtime)
  36735. }
  36736. if m._type != nil {
  36737. fields = append(fields, usagestatisticday.FieldType)
  36738. }
  36739. if m.bot_id != nil {
  36740. fields = append(fields, usagestatisticday.FieldBotID)
  36741. }
  36742. if m.organization_id != nil {
  36743. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36744. }
  36745. if m.ai_response != nil {
  36746. fields = append(fields, usagestatisticday.FieldAiResponse)
  36747. }
  36748. if m.sop_run != nil {
  36749. fields = append(fields, usagestatisticday.FieldSopRun)
  36750. }
  36751. if m.total_friend != nil {
  36752. fields = append(fields, usagestatisticday.FieldTotalFriend)
  36753. }
  36754. if m.total_group != nil {
  36755. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36756. }
  36757. if m.account_balance != nil {
  36758. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36759. }
  36760. if m.consume_token != nil {
  36761. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36762. }
  36763. if m.active_user != nil {
  36764. fields = append(fields, usagestatisticday.FieldActiveUser)
  36765. }
  36766. if m.new_user != nil {
  36767. fields = append(fields, usagestatisticday.FieldNewUser)
  36768. }
  36769. if m.label_dist != nil {
  36770. fields = append(fields, usagestatisticday.FieldLabelDist)
  36771. }
  36772. if m.consume_coin != nil {
  36773. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36774. }
  36775. return fields
  36776. }
  36777. // Field returns the value of a field with the given name. The second boolean
  36778. // return value indicates that this field was not set, or was not defined in the
  36779. // schema.
  36780. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  36781. switch name {
  36782. case usagestatisticday.FieldCreatedAt:
  36783. return m.CreatedAt()
  36784. case usagestatisticday.FieldUpdatedAt:
  36785. return m.UpdatedAt()
  36786. case usagestatisticday.FieldStatus:
  36787. return m.Status()
  36788. case usagestatisticday.FieldDeletedAt:
  36789. return m.DeletedAt()
  36790. case usagestatisticday.FieldAddtime:
  36791. return m.Addtime()
  36792. case usagestatisticday.FieldType:
  36793. return m.GetType()
  36794. case usagestatisticday.FieldBotID:
  36795. return m.BotID()
  36796. case usagestatisticday.FieldOrganizationID:
  36797. return m.OrganizationID()
  36798. case usagestatisticday.FieldAiResponse:
  36799. return m.AiResponse()
  36800. case usagestatisticday.FieldSopRun:
  36801. return m.SopRun()
  36802. case usagestatisticday.FieldTotalFriend:
  36803. return m.TotalFriend()
  36804. case usagestatisticday.FieldTotalGroup:
  36805. return m.TotalGroup()
  36806. case usagestatisticday.FieldAccountBalance:
  36807. return m.AccountBalance()
  36808. case usagestatisticday.FieldConsumeToken:
  36809. return m.ConsumeToken()
  36810. case usagestatisticday.FieldActiveUser:
  36811. return m.ActiveUser()
  36812. case usagestatisticday.FieldNewUser:
  36813. return m.NewUser()
  36814. case usagestatisticday.FieldLabelDist:
  36815. return m.LabelDist()
  36816. case usagestatisticday.FieldConsumeCoin:
  36817. return m.ConsumeCoin()
  36818. }
  36819. return nil, false
  36820. }
  36821. // OldField returns the old value of the field from the database. An error is
  36822. // returned if the mutation operation is not UpdateOne, or the query to the
  36823. // database failed.
  36824. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36825. switch name {
  36826. case usagestatisticday.FieldCreatedAt:
  36827. return m.OldCreatedAt(ctx)
  36828. case usagestatisticday.FieldUpdatedAt:
  36829. return m.OldUpdatedAt(ctx)
  36830. case usagestatisticday.FieldStatus:
  36831. return m.OldStatus(ctx)
  36832. case usagestatisticday.FieldDeletedAt:
  36833. return m.OldDeletedAt(ctx)
  36834. case usagestatisticday.FieldAddtime:
  36835. return m.OldAddtime(ctx)
  36836. case usagestatisticday.FieldType:
  36837. return m.OldType(ctx)
  36838. case usagestatisticday.FieldBotID:
  36839. return m.OldBotID(ctx)
  36840. case usagestatisticday.FieldOrganizationID:
  36841. return m.OldOrganizationID(ctx)
  36842. case usagestatisticday.FieldAiResponse:
  36843. return m.OldAiResponse(ctx)
  36844. case usagestatisticday.FieldSopRun:
  36845. return m.OldSopRun(ctx)
  36846. case usagestatisticday.FieldTotalFriend:
  36847. return m.OldTotalFriend(ctx)
  36848. case usagestatisticday.FieldTotalGroup:
  36849. return m.OldTotalGroup(ctx)
  36850. case usagestatisticday.FieldAccountBalance:
  36851. return m.OldAccountBalance(ctx)
  36852. case usagestatisticday.FieldConsumeToken:
  36853. return m.OldConsumeToken(ctx)
  36854. case usagestatisticday.FieldActiveUser:
  36855. return m.OldActiveUser(ctx)
  36856. case usagestatisticday.FieldNewUser:
  36857. return m.OldNewUser(ctx)
  36858. case usagestatisticday.FieldLabelDist:
  36859. return m.OldLabelDist(ctx)
  36860. case usagestatisticday.FieldConsumeCoin:
  36861. return m.OldConsumeCoin(ctx)
  36862. }
  36863. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36864. }
  36865. // SetField sets the value of a field with the given name. It returns an error if
  36866. // the field is not defined in the schema, or if the type mismatched the field
  36867. // type.
  36868. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  36869. switch name {
  36870. case usagestatisticday.FieldCreatedAt:
  36871. v, ok := value.(time.Time)
  36872. if !ok {
  36873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36874. }
  36875. m.SetCreatedAt(v)
  36876. return nil
  36877. case usagestatisticday.FieldUpdatedAt:
  36878. v, ok := value.(time.Time)
  36879. if !ok {
  36880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36881. }
  36882. m.SetUpdatedAt(v)
  36883. return nil
  36884. case usagestatisticday.FieldStatus:
  36885. v, ok := value.(uint8)
  36886. if !ok {
  36887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36888. }
  36889. m.SetStatus(v)
  36890. return nil
  36891. case usagestatisticday.FieldDeletedAt:
  36892. v, ok := value.(time.Time)
  36893. if !ok {
  36894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36895. }
  36896. m.SetDeletedAt(v)
  36897. return nil
  36898. case usagestatisticday.FieldAddtime:
  36899. v, ok := value.(uint64)
  36900. if !ok {
  36901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36902. }
  36903. m.SetAddtime(v)
  36904. return nil
  36905. case usagestatisticday.FieldType:
  36906. v, ok := value.(int)
  36907. if !ok {
  36908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36909. }
  36910. m.SetType(v)
  36911. return nil
  36912. case usagestatisticday.FieldBotID:
  36913. v, ok := value.(string)
  36914. if !ok {
  36915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36916. }
  36917. m.SetBotID(v)
  36918. return nil
  36919. case usagestatisticday.FieldOrganizationID:
  36920. v, ok := value.(uint64)
  36921. if !ok {
  36922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36923. }
  36924. m.SetOrganizationID(v)
  36925. return nil
  36926. case usagestatisticday.FieldAiResponse:
  36927. v, ok := value.(uint64)
  36928. if !ok {
  36929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36930. }
  36931. m.SetAiResponse(v)
  36932. return nil
  36933. case usagestatisticday.FieldSopRun:
  36934. v, ok := value.(uint64)
  36935. if !ok {
  36936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36937. }
  36938. m.SetSopRun(v)
  36939. return nil
  36940. case usagestatisticday.FieldTotalFriend:
  36941. v, ok := value.(uint64)
  36942. if !ok {
  36943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36944. }
  36945. m.SetTotalFriend(v)
  36946. return nil
  36947. case usagestatisticday.FieldTotalGroup:
  36948. v, ok := value.(uint64)
  36949. if !ok {
  36950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36951. }
  36952. m.SetTotalGroup(v)
  36953. return nil
  36954. case usagestatisticday.FieldAccountBalance:
  36955. v, ok := value.(uint64)
  36956. if !ok {
  36957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36958. }
  36959. m.SetAccountBalance(v)
  36960. return nil
  36961. case usagestatisticday.FieldConsumeToken:
  36962. v, ok := value.(uint64)
  36963. if !ok {
  36964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36965. }
  36966. m.SetConsumeToken(v)
  36967. return nil
  36968. case usagestatisticday.FieldActiveUser:
  36969. v, ok := value.(uint64)
  36970. if !ok {
  36971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36972. }
  36973. m.SetActiveUser(v)
  36974. return nil
  36975. case usagestatisticday.FieldNewUser:
  36976. v, ok := value.(int64)
  36977. if !ok {
  36978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36979. }
  36980. m.SetNewUser(v)
  36981. return nil
  36982. case usagestatisticday.FieldLabelDist:
  36983. v, ok := value.([]custom_types.LabelDist)
  36984. if !ok {
  36985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36986. }
  36987. m.SetLabelDist(v)
  36988. return nil
  36989. case usagestatisticday.FieldConsumeCoin:
  36990. v, ok := value.(float64)
  36991. if !ok {
  36992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36993. }
  36994. m.SetConsumeCoin(v)
  36995. return nil
  36996. }
  36997. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36998. }
  36999. // AddedFields returns all numeric fields that were incremented/decremented during
  37000. // this mutation.
  37001. func (m *UsageStatisticDayMutation) AddedFields() []string {
  37002. var fields []string
  37003. if m.addstatus != nil {
  37004. fields = append(fields, usagestatisticday.FieldStatus)
  37005. }
  37006. if m.addaddtime != nil {
  37007. fields = append(fields, usagestatisticday.FieldAddtime)
  37008. }
  37009. if m.add_type != nil {
  37010. fields = append(fields, usagestatisticday.FieldType)
  37011. }
  37012. if m.addorganization_id != nil {
  37013. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37014. }
  37015. if m.addai_response != nil {
  37016. fields = append(fields, usagestatisticday.FieldAiResponse)
  37017. }
  37018. if m.addsop_run != nil {
  37019. fields = append(fields, usagestatisticday.FieldSopRun)
  37020. }
  37021. if m.addtotal_friend != nil {
  37022. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37023. }
  37024. if m.addtotal_group != nil {
  37025. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37026. }
  37027. if m.addaccount_balance != nil {
  37028. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37029. }
  37030. if m.addconsume_token != nil {
  37031. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37032. }
  37033. if m.addactive_user != nil {
  37034. fields = append(fields, usagestatisticday.FieldActiveUser)
  37035. }
  37036. if m.addnew_user != nil {
  37037. fields = append(fields, usagestatisticday.FieldNewUser)
  37038. }
  37039. if m.addconsume_coin != nil {
  37040. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37041. }
  37042. return fields
  37043. }
  37044. // AddedField returns the numeric value that was incremented/decremented on a field
  37045. // with the given name. The second boolean return value indicates that this field
  37046. // was not set, or was not defined in the schema.
  37047. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  37048. switch name {
  37049. case usagestatisticday.FieldStatus:
  37050. return m.AddedStatus()
  37051. case usagestatisticday.FieldAddtime:
  37052. return m.AddedAddtime()
  37053. case usagestatisticday.FieldType:
  37054. return m.AddedType()
  37055. case usagestatisticday.FieldOrganizationID:
  37056. return m.AddedOrganizationID()
  37057. case usagestatisticday.FieldAiResponse:
  37058. return m.AddedAiResponse()
  37059. case usagestatisticday.FieldSopRun:
  37060. return m.AddedSopRun()
  37061. case usagestatisticday.FieldTotalFriend:
  37062. return m.AddedTotalFriend()
  37063. case usagestatisticday.FieldTotalGroup:
  37064. return m.AddedTotalGroup()
  37065. case usagestatisticday.FieldAccountBalance:
  37066. return m.AddedAccountBalance()
  37067. case usagestatisticday.FieldConsumeToken:
  37068. return m.AddedConsumeToken()
  37069. case usagestatisticday.FieldActiveUser:
  37070. return m.AddedActiveUser()
  37071. case usagestatisticday.FieldNewUser:
  37072. return m.AddedNewUser()
  37073. case usagestatisticday.FieldConsumeCoin:
  37074. return m.AddedConsumeCoin()
  37075. }
  37076. return nil, false
  37077. }
  37078. // AddField adds the value to the field with the given name. It returns an error if
  37079. // the field is not defined in the schema, or if the type mismatched the field
  37080. // type.
  37081. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  37082. switch name {
  37083. case usagestatisticday.FieldStatus:
  37084. v, ok := value.(int8)
  37085. if !ok {
  37086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37087. }
  37088. m.AddStatus(v)
  37089. return nil
  37090. case usagestatisticday.FieldAddtime:
  37091. v, ok := value.(int64)
  37092. if !ok {
  37093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37094. }
  37095. m.AddAddtime(v)
  37096. return nil
  37097. case usagestatisticday.FieldType:
  37098. v, ok := value.(int)
  37099. if !ok {
  37100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37101. }
  37102. m.AddType(v)
  37103. return nil
  37104. case usagestatisticday.FieldOrganizationID:
  37105. v, ok := value.(int64)
  37106. if !ok {
  37107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37108. }
  37109. m.AddOrganizationID(v)
  37110. return nil
  37111. case usagestatisticday.FieldAiResponse:
  37112. v, ok := value.(int64)
  37113. if !ok {
  37114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37115. }
  37116. m.AddAiResponse(v)
  37117. return nil
  37118. case usagestatisticday.FieldSopRun:
  37119. v, ok := value.(int64)
  37120. if !ok {
  37121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37122. }
  37123. m.AddSopRun(v)
  37124. return nil
  37125. case usagestatisticday.FieldTotalFriend:
  37126. v, ok := value.(int64)
  37127. if !ok {
  37128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37129. }
  37130. m.AddTotalFriend(v)
  37131. return nil
  37132. case usagestatisticday.FieldTotalGroup:
  37133. v, ok := value.(int64)
  37134. if !ok {
  37135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37136. }
  37137. m.AddTotalGroup(v)
  37138. return nil
  37139. case usagestatisticday.FieldAccountBalance:
  37140. v, ok := value.(int64)
  37141. if !ok {
  37142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37143. }
  37144. m.AddAccountBalance(v)
  37145. return nil
  37146. case usagestatisticday.FieldConsumeToken:
  37147. v, ok := value.(int64)
  37148. if !ok {
  37149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37150. }
  37151. m.AddConsumeToken(v)
  37152. return nil
  37153. case usagestatisticday.FieldActiveUser:
  37154. v, ok := value.(int64)
  37155. if !ok {
  37156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37157. }
  37158. m.AddActiveUser(v)
  37159. return nil
  37160. case usagestatisticday.FieldNewUser:
  37161. v, ok := value.(int64)
  37162. if !ok {
  37163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37164. }
  37165. m.AddNewUser(v)
  37166. return nil
  37167. case usagestatisticday.FieldConsumeCoin:
  37168. v, ok := value.(float64)
  37169. if !ok {
  37170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37171. }
  37172. m.AddConsumeCoin(v)
  37173. return nil
  37174. }
  37175. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  37176. }
  37177. // ClearedFields returns all nullable fields that were cleared during this
  37178. // mutation.
  37179. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  37180. var fields []string
  37181. if m.FieldCleared(usagestatisticday.FieldStatus) {
  37182. fields = append(fields, usagestatisticday.FieldStatus)
  37183. }
  37184. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  37185. fields = append(fields, usagestatisticday.FieldDeletedAt)
  37186. }
  37187. if m.FieldCleared(usagestatisticday.FieldBotID) {
  37188. fields = append(fields, usagestatisticday.FieldBotID)
  37189. }
  37190. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  37191. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37192. }
  37193. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  37194. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37195. }
  37196. return fields
  37197. }
  37198. // FieldCleared returns a boolean indicating if a field with the given name was
  37199. // cleared in this mutation.
  37200. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  37201. _, ok := m.clearedFields[name]
  37202. return ok
  37203. }
  37204. // ClearField clears the value of the field with the given name. It returns an
  37205. // error if the field is not defined in the schema.
  37206. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  37207. switch name {
  37208. case usagestatisticday.FieldStatus:
  37209. m.ClearStatus()
  37210. return nil
  37211. case usagestatisticday.FieldDeletedAt:
  37212. m.ClearDeletedAt()
  37213. return nil
  37214. case usagestatisticday.FieldBotID:
  37215. m.ClearBotID()
  37216. return nil
  37217. case usagestatisticday.FieldOrganizationID:
  37218. m.ClearOrganizationID()
  37219. return nil
  37220. case usagestatisticday.FieldConsumeCoin:
  37221. m.ClearConsumeCoin()
  37222. return nil
  37223. }
  37224. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  37225. }
  37226. // ResetField resets all changes in the mutation for the field with the given name.
  37227. // It returns an error if the field is not defined in the schema.
  37228. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  37229. switch name {
  37230. case usagestatisticday.FieldCreatedAt:
  37231. m.ResetCreatedAt()
  37232. return nil
  37233. case usagestatisticday.FieldUpdatedAt:
  37234. m.ResetUpdatedAt()
  37235. return nil
  37236. case usagestatisticday.FieldStatus:
  37237. m.ResetStatus()
  37238. return nil
  37239. case usagestatisticday.FieldDeletedAt:
  37240. m.ResetDeletedAt()
  37241. return nil
  37242. case usagestatisticday.FieldAddtime:
  37243. m.ResetAddtime()
  37244. return nil
  37245. case usagestatisticday.FieldType:
  37246. m.ResetType()
  37247. return nil
  37248. case usagestatisticday.FieldBotID:
  37249. m.ResetBotID()
  37250. return nil
  37251. case usagestatisticday.FieldOrganizationID:
  37252. m.ResetOrganizationID()
  37253. return nil
  37254. case usagestatisticday.FieldAiResponse:
  37255. m.ResetAiResponse()
  37256. return nil
  37257. case usagestatisticday.FieldSopRun:
  37258. m.ResetSopRun()
  37259. return nil
  37260. case usagestatisticday.FieldTotalFriend:
  37261. m.ResetTotalFriend()
  37262. return nil
  37263. case usagestatisticday.FieldTotalGroup:
  37264. m.ResetTotalGroup()
  37265. return nil
  37266. case usagestatisticday.FieldAccountBalance:
  37267. m.ResetAccountBalance()
  37268. return nil
  37269. case usagestatisticday.FieldConsumeToken:
  37270. m.ResetConsumeToken()
  37271. return nil
  37272. case usagestatisticday.FieldActiveUser:
  37273. m.ResetActiveUser()
  37274. return nil
  37275. case usagestatisticday.FieldNewUser:
  37276. m.ResetNewUser()
  37277. return nil
  37278. case usagestatisticday.FieldLabelDist:
  37279. m.ResetLabelDist()
  37280. return nil
  37281. case usagestatisticday.FieldConsumeCoin:
  37282. m.ResetConsumeCoin()
  37283. return nil
  37284. }
  37285. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37286. }
  37287. // AddedEdges returns all edge names that were set/added in this mutation.
  37288. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  37289. edges := make([]string, 0, 0)
  37290. return edges
  37291. }
  37292. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37293. // name in this mutation.
  37294. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  37295. return nil
  37296. }
  37297. // RemovedEdges returns all edge names that were removed in this mutation.
  37298. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  37299. edges := make([]string, 0, 0)
  37300. return edges
  37301. }
  37302. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37303. // the given name in this mutation.
  37304. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  37305. return nil
  37306. }
  37307. // ClearedEdges returns all edge names that were cleared in this mutation.
  37308. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  37309. edges := make([]string, 0, 0)
  37310. return edges
  37311. }
  37312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37313. // was cleared in this mutation.
  37314. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  37315. return false
  37316. }
  37317. // ClearEdge clears the value of the edge with the given name. It returns an error
  37318. // if that edge is not defined in the schema.
  37319. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  37320. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  37321. }
  37322. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37323. // It returns an error if the edge is not defined in the schema.
  37324. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  37325. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  37326. }
  37327. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  37328. type UsageStatisticHourMutation struct {
  37329. config
  37330. op Op
  37331. typ string
  37332. id *uint64
  37333. created_at *time.Time
  37334. updated_at *time.Time
  37335. status *uint8
  37336. addstatus *int8
  37337. deleted_at *time.Time
  37338. addtime *uint64
  37339. addaddtime *int64
  37340. _type *int
  37341. add_type *int
  37342. bot_id *string
  37343. organization_id *uint64
  37344. addorganization_id *int64
  37345. ai_response *uint64
  37346. addai_response *int64
  37347. sop_run *uint64
  37348. addsop_run *int64
  37349. total_friend *uint64
  37350. addtotal_friend *int64
  37351. total_group *uint64
  37352. addtotal_group *int64
  37353. account_balance *uint64
  37354. addaccount_balance *int64
  37355. consume_token *uint64
  37356. addconsume_token *int64
  37357. active_user *uint64
  37358. addactive_user *int64
  37359. new_user *int64
  37360. addnew_user *int64
  37361. label_dist *[]custom_types.LabelDist
  37362. appendlabel_dist []custom_types.LabelDist
  37363. consume_coin *float64
  37364. addconsume_coin *float64
  37365. clearedFields map[string]struct{}
  37366. done bool
  37367. oldValue func(context.Context) (*UsageStatisticHour, error)
  37368. predicates []predicate.UsageStatisticHour
  37369. }
  37370. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  37371. // usagestatistichourOption allows management of the mutation configuration using functional options.
  37372. type usagestatistichourOption func(*UsageStatisticHourMutation)
  37373. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  37374. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  37375. m := &UsageStatisticHourMutation{
  37376. config: c,
  37377. op: op,
  37378. typ: TypeUsageStatisticHour,
  37379. clearedFields: make(map[string]struct{}),
  37380. }
  37381. for _, opt := range opts {
  37382. opt(m)
  37383. }
  37384. return m
  37385. }
  37386. // withUsageStatisticHourID sets the ID field of the mutation.
  37387. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  37388. return func(m *UsageStatisticHourMutation) {
  37389. var (
  37390. err error
  37391. once sync.Once
  37392. value *UsageStatisticHour
  37393. )
  37394. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  37395. once.Do(func() {
  37396. if m.done {
  37397. err = errors.New("querying old values post mutation is not allowed")
  37398. } else {
  37399. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  37400. }
  37401. })
  37402. return value, err
  37403. }
  37404. m.id = &id
  37405. }
  37406. }
  37407. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  37408. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  37409. return func(m *UsageStatisticHourMutation) {
  37410. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  37411. return node, nil
  37412. }
  37413. m.id = &node.ID
  37414. }
  37415. }
  37416. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37417. // executed in a transaction (ent.Tx), a transactional client is returned.
  37418. func (m UsageStatisticHourMutation) Client() *Client {
  37419. client := &Client{config: m.config}
  37420. client.init()
  37421. return client
  37422. }
  37423. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37424. // it returns an error otherwise.
  37425. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  37426. if _, ok := m.driver.(*txDriver); !ok {
  37427. return nil, errors.New("ent: mutation is not running in a transaction")
  37428. }
  37429. tx := &Tx{config: m.config}
  37430. tx.init()
  37431. return tx, nil
  37432. }
  37433. // SetID sets the value of the id field. Note that this
  37434. // operation is only accepted on creation of UsageStatisticHour entities.
  37435. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  37436. m.id = &id
  37437. }
  37438. // ID returns the ID value in the mutation. Note that the ID is only available
  37439. // if it was provided to the builder or after it was returned from the database.
  37440. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  37441. if m.id == nil {
  37442. return
  37443. }
  37444. return *m.id, true
  37445. }
  37446. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37447. // That means, if the mutation is applied within a transaction with an isolation level such
  37448. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37449. // or updated by the mutation.
  37450. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  37451. switch {
  37452. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37453. id, exists := m.ID()
  37454. if exists {
  37455. return []uint64{id}, nil
  37456. }
  37457. fallthrough
  37458. case m.op.Is(OpUpdate | OpDelete):
  37459. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  37460. default:
  37461. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37462. }
  37463. }
  37464. // SetCreatedAt sets the "created_at" field.
  37465. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  37466. m.created_at = &t
  37467. }
  37468. // CreatedAt returns the value of the "created_at" field in the mutation.
  37469. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  37470. v := m.created_at
  37471. if v == nil {
  37472. return
  37473. }
  37474. return *v, true
  37475. }
  37476. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  37477. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37479. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37480. if !m.op.Is(OpUpdateOne) {
  37481. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37482. }
  37483. if m.id == nil || m.oldValue == nil {
  37484. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37485. }
  37486. oldValue, err := m.oldValue(ctx)
  37487. if err != nil {
  37488. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37489. }
  37490. return oldValue.CreatedAt, nil
  37491. }
  37492. // ResetCreatedAt resets all changes to the "created_at" field.
  37493. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  37494. m.created_at = nil
  37495. }
  37496. // SetUpdatedAt sets the "updated_at" field.
  37497. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  37498. m.updated_at = &t
  37499. }
  37500. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37501. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  37502. v := m.updated_at
  37503. if v == nil {
  37504. return
  37505. }
  37506. return *v, true
  37507. }
  37508. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  37509. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37511. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37512. if !m.op.Is(OpUpdateOne) {
  37513. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37514. }
  37515. if m.id == nil || m.oldValue == nil {
  37516. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37517. }
  37518. oldValue, err := m.oldValue(ctx)
  37519. if err != nil {
  37520. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37521. }
  37522. return oldValue.UpdatedAt, nil
  37523. }
  37524. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37525. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  37526. m.updated_at = nil
  37527. }
  37528. // SetStatus sets the "status" field.
  37529. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  37530. m.status = &u
  37531. m.addstatus = nil
  37532. }
  37533. // Status returns the value of the "status" field in the mutation.
  37534. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  37535. v := m.status
  37536. if v == nil {
  37537. return
  37538. }
  37539. return *v, true
  37540. }
  37541. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  37542. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37544. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37545. if !m.op.Is(OpUpdateOne) {
  37546. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37547. }
  37548. if m.id == nil || m.oldValue == nil {
  37549. return v, errors.New("OldStatus requires an ID field in the mutation")
  37550. }
  37551. oldValue, err := m.oldValue(ctx)
  37552. if err != nil {
  37553. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37554. }
  37555. return oldValue.Status, nil
  37556. }
  37557. // AddStatus adds u to the "status" field.
  37558. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  37559. if m.addstatus != nil {
  37560. *m.addstatus += u
  37561. } else {
  37562. m.addstatus = &u
  37563. }
  37564. }
  37565. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37566. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  37567. v := m.addstatus
  37568. if v == nil {
  37569. return
  37570. }
  37571. return *v, true
  37572. }
  37573. // ClearStatus clears the value of the "status" field.
  37574. func (m *UsageStatisticHourMutation) ClearStatus() {
  37575. m.status = nil
  37576. m.addstatus = nil
  37577. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  37578. }
  37579. // StatusCleared returns if the "status" field was cleared in this mutation.
  37580. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  37581. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  37582. return ok
  37583. }
  37584. // ResetStatus resets all changes to the "status" field.
  37585. func (m *UsageStatisticHourMutation) ResetStatus() {
  37586. m.status = nil
  37587. m.addstatus = nil
  37588. delete(m.clearedFields, usagestatistichour.FieldStatus)
  37589. }
  37590. // SetDeletedAt sets the "deleted_at" field.
  37591. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  37592. m.deleted_at = &t
  37593. }
  37594. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37595. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  37596. v := m.deleted_at
  37597. if v == nil {
  37598. return
  37599. }
  37600. return *v, true
  37601. }
  37602. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  37603. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37605. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37606. if !m.op.Is(OpUpdateOne) {
  37607. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37608. }
  37609. if m.id == nil || m.oldValue == nil {
  37610. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37611. }
  37612. oldValue, err := m.oldValue(ctx)
  37613. if err != nil {
  37614. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37615. }
  37616. return oldValue.DeletedAt, nil
  37617. }
  37618. // ClearDeletedAt clears the value of the "deleted_at" field.
  37619. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  37620. m.deleted_at = nil
  37621. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  37622. }
  37623. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37624. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  37625. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  37626. return ok
  37627. }
  37628. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37629. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  37630. m.deleted_at = nil
  37631. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  37632. }
  37633. // SetAddtime sets the "addtime" field.
  37634. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  37635. m.addtime = &u
  37636. m.addaddtime = nil
  37637. }
  37638. // Addtime returns the value of the "addtime" field in the mutation.
  37639. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  37640. v := m.addtime
  37641. if v == nil {
  37642. return
  37643. }
  37644. return *v, true
  37645. }
  37646. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  37647. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37649. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37650. if !m.op.Is(OpUpdateOne) {
  37651. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37652. }
  37653. if m.id == nil || m.oldValue == nil {
  37654. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37655. }
  37656. oldValue, err := m.oldValue(ctx)
  37657. if err != nil {
  37658. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37659. }
  37660. return oldValue.Addtime, nil
  37661. }
  37662. // AddAddtime adds u to the "addtime" field.
  37663. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  37664. if m.addaddtime != nil {
  37665. *m.addaddtime += u
  37666. } else {
  37667. m.addaddtime = &u
  37668. }
  37669. }
  37670. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37671. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  37672. v := m.addaddtime
  37673. if v == nil {
  37674. return
  37675. }
  37676. return *v, true
  37677. }
  37678. // ResetAddtime resets all changes to the "addtime" field.
  37679. func (m *UsageStatisticHourMutation) ResetAddtime() {
  37680. m.addtime = nil
  37681. m.addaddtime = nil
  37682. }
  37683. // SetType sets the "type" field.
  37684. func (m *UsageStatisticHourMutation) SetType(i int) {
  37685. m._type = &i
  37686. m.add_type = nil
  37687. }
  37688. // GetType returns the value of the "type" field in the mutation.
  37689. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  37690. v := m._type
  37691. if v == nil {
  37692. return
  37693. }
  37694. return *v, true
  37695. }
  37696. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  37697. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37699. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  37700. if !m.op.Is(OpUpdateOne) {
  37701. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37702. }
  37703. if m.id == nil || m.oldValue == nil {
  37704. return v, errors.New("OldType requires an ID field in the mutation")
  37705. }
  37706. oldValue, err := m.oldValue(ctx)
  37707. if err != nil {
  37708. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37709. }
  37710. return oldValue.Type, nil
  37711. }
  37712. // AddType adds i to the "type" field.
  37713. func (m *UsageStatisticHourMutation) AddType(i int) {
  37714. if m.add_type != nil {
  37715. *m.add_type += i
  37716. } else {
  37717. m.add_type = &i
  37718. }
  37719. }
  37720. // AddedType returns the value that was added to the "type" field in this mutation.
  37721. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  37722. v := m.add_type
  37723. if v == nil {
  37724. return
  37725. }
  37726. return *v, true
  37727. }
  37728. // ResetType resets all changes to the "type" field.
  37729. func (m *UsageStatisticHourMutation) ResetType() {
  37730. m._type = nil
  37731. m.add_type = nil
  37732. }
  37733. // SetBotID sets the "bot_id" field.
  37734. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  37735. m.bot_id = &s
  37736. }
  37737. // BotID returns the value of the "bot_id" field in the mutation.
  37738. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  37739. v := m.bot_id
  37740. if v == nil {
  37741. return
  37742. }
  37743. return *v, true
  37744. }
  37745. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  37746. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37748. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  37749. if !m.op.Is(OpUpdateOne) {
  37750. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37751. }
  37752. if m.id == nil || m.oldValue == nil {
  37753. return v, errors.New("OldBotID requires an ID field in the mutation")
  37754. }
  37755. oldValue, err := m.oldValue(ctx)
  37756. if err != nil {
  37757. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37758. }
  37759. return oldValue.BotID, nil
  37760. }
  37761. // ClearBotID clears the value of the "bot_id" field.
  37762. func (m *UsageStatisticHourMutation) ClearBotID() {
  37763. m.bot_id = nil
  37764. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  37765. }
  37766. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37767. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  37768. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  37769. return ok
  37770. }
  37771. // ResetBotID resets all changes to the "bot_id" field.
  37772. func (m *UsageStatisticHourMutation) ResetBotID() {
  37773. m.bot_id = nil
  37774. delete(m.clearedFields, usagestatistichour.FieldBotID)
  37775. }
  37776. // SetOrganizationID sets the "organization_id" field.
  37777. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  37778. m.organization_id = &u
  37779. m.addorganization_id = nil
  37780. }
  37781. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37782. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  37783. v := m.organization_id
  37784. if v == nil {
  37785. return
  37786. }
  37787. return *v, true
  37788. }
  37789. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  37790. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37792. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37793. if !m.op.Is(OpUpdateOne) {
  37794. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37795. }
  37796. if m.id == nil || m.oldValue == nil {
  37797. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37798. }
  37799. oldValue, err := m.oldValue(ctx)
  37800. if err != nil {
  37801. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37802. }
  37803. return oldValue.OrganizationID, nil
  37804. }
  37805. // AddOrganizationID adds u to the "organization_id" field.
  37806. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  37807. if m.addorganization_id != nil {
  37808. *m.addorganization_id += u
  37809. } else {
  37810. m.addorganization_id = &u
  37811. }
  37812. }
  37813. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37814. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  37815. v := m.addorganization_id
  37816. if v == nil {
  37817. return
  37818. }
  37819. return *v, true
  37820. }
  37821. // ClearOrganizationID clears the value of the "organization_id" field.
  37822. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  37823. m.organization_id = nil
  37824. m.addorganization_id = nil
  37825. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  37826. }
  37827. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37828. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  37829. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  37830. return ok
  37831. }
  37832. // ResetOrganizationID resets all changes to the "organization_id" field.
  37833. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  37834. m.organization_id = nil
  37835. m.addorganization_id = nil
  37836. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  37837. }
  37838. // SetAiResponse sets the "ai_response" field.
  37839. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  37840. m.ai_response = &u
  37841. m.addai_response = nil
  37842. }
  37843. // AiResponse returns the value of the "ai_response" field in the mutation.
  37844. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  37845. v := m.ai_response
  37846. if v == nil {
  37847. return
  37848. }
  37849. return *v, true
  37850. }
  37851. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  37852. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37854. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37855. if !m.op.Is(OpUpdateOne) {
  37856. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37857. }
  37858. if m.id == nil || m.oldValue == nil {
  37859. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37860. }
  37861. oldValue, err := m.oldValue(ctx)
  37862. if err != nil {
  37863. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37864. }
  37865. return oldValue.AiResponse, nil
  37866. }
  37867. // AddAiResponse adds u to the "ai_response" field.
  37868. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  37869. if m.addai_response != nil {
  37870. *m.addai_response += u
  37871. } else {
  37872. m.addai_response = &u
  37873. }
  37874. }
  37875. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37876. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  37877. v := m.addai_response
  37878. if v == nil {
  37879. return
  37880. }
  37881. return *v, true
  37882. }
  37883. // ResetAiResponse resets all changes to the "ai_response" field.
  37884. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  37885. m.ai_response = nil
  37886. m.addai_response = nil
  37887. }
  37888. // SetSopRun sets the "sop_run" field.
  37889. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  37890. m.sop_run = &u
  37891. m.addsop_run = nil
  37892. }
  37893. // SopRun returns the value of the "sop_run" field in the mutation.
  37894. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  37895. v := m.sop_run
  37896. if v == nil {
  37897. return
  37898. }
  37899. return *v, true
  37900. }
  37901. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  37902. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37904. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37905. if !m.op.Is(OpUpdateOne) {
  37906. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37907. }
  37908. if m.id == nil || m.oldValue == nil {
  37909. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37910. }
  37911. oldValue, err := m.oldValue(ctx)
  37912. if err != nil {
  37913. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37914. }
  37915. return oldValue.SopRun, nil
  37916. }
  37917. // AddSopRun adds u to the "sop_run" field.
  37918. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  37919. if m.addsop_run != nil {
  37920. *m.addsop_run += u
  37921. } else {
  37922. m.addsop_run = &u
  37923. }
  37924. }
  37925. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37926. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  37927. v := m.addsop_run
  37928. if v == nil {
  37929. return
  37930. }
  37931. return *v, true
  37932. }
  37933. // ResetSopRun resets all changes to the "sop_run" field.
  37934. func (m *UsageStatisticHourMutation) ResetSopRun() {
  37935. m.sop_run = nil
  37936. m.addsop_run = nil
  37937. }
  37938. // SetTotalFriend sets the "total_friend" field.
  37939. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  37940. m.total_friend = &u
  37941. m.addtotal_friend = nil
  37942. }
  37943. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37944. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  37945. v := m.total_friend
  37946. if v == nil {
  37947. return
  37948. }
  37949. return *v, true
  37950. }
  37951. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  37952. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37954. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37955. if !m.op.Is(OpUpdateOne) {
  37956. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37957. }
  37958. if m.id == nil || m.oldValue == nil {
  37959. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  37960. }
  37961. oldValue, err := m.oldValue(ctx)
  37962. if err != nil {
  37963. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  37964. }
  37965. return oldValue.TotalFriend, nil
  37966. }
  37967. // AddTotalFriend adds u to the "total_friend" field.
  37968. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  37969. if m.addtotal_friend != nil {
  37970. *m.addtotal_friend += u
  37971. } else {
  37972. m.addtotal_friend = &u
  37973. }
  37974. }
  37975. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37976. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  37977. v := m.addtotal_friend
  37978. if v == nil {
  37979. return
  37980. }
  37981. return *v, true
  37982. }
  37983. // ResetTotalFriend resets all changes to the "total_friend" field.
  37984. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  37985. m.total_friend = nil
  37986. m.addtotal_friend = nil
  37987. }
  37988. // SetTotalGroup sets the "total_group" field.
  37989. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  37990. m.total_group = &u
  37991. m.addtotal_group = nil
  37992. }
  37993. // TotalGroup returns the value of the "total_group" field in the mutation.
  37994. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  37995. v := m.total_group
  37996. if v == nil {
  37997. return
  37998. }
  37999. return *v, true
  38000. }
  38001. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  38002. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38004. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38005. if !m.op.Is(OpUpdateOne) {
  38006. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38007. }
  38008. if m.id == nil || m.oldValue == nil {
  38009. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38010. }
  38011. oldValue, err := m.oldValue(ctx)
  38012. if err != nil {
  38013. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38014. }
  38015. return oldValue.TotalGroup, nil
  38016. }
  38017. // AddTotalGroup adds u to the "total_group" field.
  38018. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  38019. if m.addtotal_group != nil {
  38020. *m.addtotal_group += u
  38021. } else {
  38022. m.addtotal_group = &u
  38023. }
  38024. }
  38025. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38026. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  38027. v := m.addtotal_group
  38028. if v == nil {
  38029. return
  38030. }
  38031. return *v, true
  38032. }
  38033. // ResetTotalGroup resets all changes to the "total_group" field.
  38034. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  38035. m.total_group = nil
  38036. m.addtotal_group = nil
  38037. }
  38038. // SetAccountBalance sets the "account_balance" field.
  38039. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  38040. m.account_balance = &u
  38041. m.addaccount_balance = nil
  38042. }
  38043. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38044. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  38045. v := m.account_balance
  38046. if v == nil {
  38047. return
  38048. }
  38049. return *v, true
  38050. }
  38051. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  38052. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38054. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38055. if !m.op.Is(OpUpdateOne) {
  38056. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38057. }
  38058. if m.id == nil || m.oldValue == nil {
  38059. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38060. }
  38061. oldValue, err := m.oldValue(ctx)
  38062. if err != nil {
  38063. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38064. }
  38065. return oldValue.AccountBalance, nil
  38066. }
  38067. // AddAccountBalance adds u to the "account_balance" field.
  38068. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  38069. if m.addaccount_balance != nil {
  38070. *m.addaccount_balance += u
  38071. } else {
  38072. m.addaccount_balance = &u
  38073. }
  38074. }
  38075. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38076. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  38077. v := m.addaccount_balance
  38078. if v == nil {
  38079. return
  38080. }
  38081. return *v, true
  38082. }
  38083. // ResetAccountBalance resets all changes to the "account_balance" field.
  38084. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  38085. m.account_balance = nil
  38086. m.addaccount_balance = nil
  38087. }
  38088. // SetConsumeToken sets the "consume_token" field.
  38089. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  38090. m.consume_token = &u
  38091. m.addconsume_token = nil
  38092. }
  38093. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38094. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  38095. v := m.consume_token
  38096. if v == nil {
  38097. return
  38098. }
  38099. return *v, true
  38100. }
  38101. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  38102. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38104. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38105. if !m.op.Is(OpUpdateOne) {
  38106. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38107. }
  38108. if m.id == nil || m.oldValue == nil {
  38109. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38110. }
  38111. oldValue, err := m.oldValue(ctx)
  38112. if err != nil {
  38113. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38114. }
  38115. return oldValue.ConsumeToken, nil
  38116. }
  38117. // AddConsumeToken adds u to the "consume_token" field.
  38118. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  38119. if m.addconsume_token != nil {
  38120. *m.addconsume_token += u
  38121. } else {
  38122. m.addconsume_token = &u
  38123. }
  38124. }
  38125. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38126. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  38127. v := m.addconsume_token
  38128. if v == nil {
  38129. return
  38130. }
  38131. return *v, true
  38132. }
  38133. // ResetConsumeToken resets all changes to the "consume_token" field.
  38134. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  38135. m.consume_token = nil
  38136. m.addconsume_token = nil
  38137. }
  38138. // SetActiveUser sets the "active_user" field.
  38139. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  38140. m.active_user = &u
  38141. m.addactive_user = nil
  38142. }
  38143. // ActiveUser returns the value of the "active_user" field in the mutation.
  38144. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  38145. v := m.active_user
  38146. if v == nil {
  38147. return
  38148. }
  38149. return *v, true
  38150. }
  38151. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  38152. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38154. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38155. if !m.op.Is(OpUpdateOne) {
  38156. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38157. }
  38158. if m.id == nil || m.oldValue == nil {
  38159. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38160. }
  38161. oldValue, err := m.oldValue(ctx)
  38162. if err != nil {
  38163. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38164. }
  38165. return oldValue.ActiveUser, nil
  38166. }
  38167. // AddActiveUser adds u to the "active_user" field.
  38168. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  38169. if m.addactive_user != nil {
  38170. *m.addactive_user += u
  38171. } else {
  38172. m.addactive_user = &u
  38173. }
  38174. }
  38175. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38176. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  38177. v := m.addactive_user
  38178. if v == nil {
  38179. return
  38180. }
  38181. return *v, true
  38182. }
  38183. // ResetActiveUser resets all changes to the "active_user" field.
  38184. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  38185. m.active_user = nil
  38186. m.addactive_user = nil
  38187. }
  38188. // SetNewUser sets the "new_user" field.
  38189. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  38190. m.new_user = &i
  38191. m.addnew_user = nil
  38192. }
  38193. // NewUser returns the value of the "new_user" field in the mutation.
  38194. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  38195. v := m.new_user
  38196. if v == nil {
  38197. return
  38198. }
  38199. return *v, true
  38200. }
  38201. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  38202. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38204. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38205. if !m.op.Is(OpUpdateOne) {
  38206. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38207. }
  38208. if m.id == nil || m.oldValue == nil {
  38209. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38210. }
  38211. oldValue, err := m.oldValue(ctx)
  38212. if err != nil {
  38213. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38214. }
  38215. return oldValue.NewUser, nil
  38216. }
  38217. // AddNewUser adds i to the "new_user" field.
  38218. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  38219. if m.addnew_user != nil {
  38220. *m.addnew_user += i
  38221. } else {
  38222. m.addnew_user = &i
  38223. }
  38224. }
  38225. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38226. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  38227. v := m.addnew_user
  38228. if v == nil {
  38229. return
  38230. }
  38231. return *v, true
  38232. }
  38233. // ResetNewUser resets all changes to the "new_user" field.
  38234. func (m *UsageStatisticHourMutation) ResetNewUser() {
  38235. m.new_user = nil
  38236. m.addnew_user = nil
  38237. }
  38238. // SetLabelDist sets the "label_dist" field.
  38239. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38240. m.label_dist = &ctd
  38241. m.appendlabel_dist = nil
  38242. }
  38243. // LabelDist returns the value of the "label_dist" field in the mutation.
  38244. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38245. v := m.label_dist
  38246. if v == nil {
  38247. return
  38248. }
  38249. return *v, true
  38250. }
  38251. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  38252. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38254. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38255. if !m.op.Is(OpUpdateOne) {
  38256. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38257. }
  38258. if m.id == nil || m.oldValue == nil {
  38259. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38260. }
  38261. oldValue, err := m.oldValue(ctx)
  38262. if err != nil {
  38263. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38264. }
  38265. return oldValue.LabelDist, nil
  38266. }
  38267. // AppendLabelDist adds ctd to the "label_dist" field.
  38268. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38269. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38270. }
  38271. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38272. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38273. if len(m.appendlabel_dist) == 0 {
  38274. return nil, false
  38275. }
  38276. return m.appendlabel_dist, true
  38277. }
  38278. // ResetLabelDist resets all changes to the "label_dist" field.
  38279. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  38280. m.label_dist = nil
  38281. m.appendlabel_dist = nil
  38282. }
  38283. // SetConsumeCoin sets the "consume_coin" field.
  38284. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  38285. m.consume_coin = &f
  38286. m.addconsume_coin = nil
  38287. }
  38288. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38289. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  38290. v := m.consume_coin
  38291. if v == nil {
  38292. return
  38293. }
  38294. return *v, true
  38295. }
  38296. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  38297. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38299. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38300. if !m.op.Is(OpUpdateOne) {
  38301. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38302. }
  38303. if m.id == nil || m.oldValue == nil {
  38304. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38305. }
  38306. oldValue, err := m.oldValue(ctx)
  38307. if err != nil {
  38308. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38309. }
  38310. return oldValue.ConsumeCoin, nil
  38311. }
  38312. // AddConsumeCoin adds f to the "consume_coin" field.
  38313. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  38314. if m.addconsume_coin != nil {
  38315. *m.addconsume_coin += f
  38316. } else {
  38317. m.addconsume_coin = &f
  38318. }
  38319. }
  38320. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38321. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  38322. v := m.addconsume_coin
  38323. if v == nil {
  38324. return
  38325. }
  38326. return *v, true
  38327. }
  38328. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38329. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  38330. m.consume_coin = nil
  38331. m.addconsume_coin = nil
  38332. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  38333. }
  38334. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38335. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  38336. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  38337. return ok
  38338. }
  38339. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38340. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  38341. m.consume_coin = nil
  38342. m.addconsume_coin = nil
  38343. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  38344. }
  38345. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  38346. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  38347. m.predicates = append(m.predicates, ps...)
  38348. }
  38349. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  38350. // users can use type-assertion to append predicates that do not depend on any generated package.
  38351. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  38352. p := make([]predicate.UsageStatisticHour, len(ps))
  38353. for i := range ps {
  38354. p[i] = ps[i]
  38355. }
  38356. m.Where(p...)
  38357. }
  38358. // Op returns the operation name.
  38359. func (m *UsageStatisticHourMutation) Op() Op {
  38360. return m.op
  38361. }
  38362. // SetOp allows setting the mutation operation.
  38363. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  38364. m.op = op
  38365. }
  38366. // Type returns the node type of this mutation (UsageStatisticHour).
  38367. func (m *UsageStatisticHourMutation) Type() string {
  38368. return m.typ
  38369. }
  38370. // Fields returns all fields that were changed during this mutation. Note that in
  38371. // order to get all numeric fields that were incremented/decremented, call
  38372. // AddedFields().
  38373. func (m *UsageStatisticHourMutation) Fields() []string {
  38374. fields := make([]string, 0, 18)
  38375. if m.created_at != nil {
  38376. fields = append(fields, usagestatistichour.FieldCreatedAt)
  38377. }
  38378. if m.updated_at != nil {
  38379. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  38380. }
  38381. if m.status != nil {
  38382. fields = append(fields, usagestatistichour.FieldStatus)
  38383. }
  38384. if m.deleted_at != nil {
  38385. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38386. }
  38387. if m.addtime != nil {
  38388. fields = append(fields, usagestatistichour.FieldAddtime)
  38389. }
  38390. if m._type != nil {
  38391. fields = append(fields, usagestatistichour.FieldType)
  38392. }
  38393. if m.bot_id != nil {
  38394. fields = append(fields, usagestatistichour.FieldBotID)
  38395. }
  38396. if m.organization_id != nil {
  38397. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38398. }
  38399. if m.ai_response != nil {
  38400. fields = append(fields, usagestatistichour.FieldAiResponse)
  38401. }
  38402. if m.sop_run != nil {
  38403. fields = append(fields, usagestatistichour.FieldSopRun)
  38404. }
  38405. if m.total_friend != nil {
  38406. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38407. }
  38408. if m.total_group != nil {
  38409. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38410. }
  38411. if m.account_balance != nil {
  38412. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38413. }
  38414. if m.consume_token != nil {
  38415. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38416. }
  38417. if m.active_user != nil {
  38418. fields = append(fields, usagestatistichour.FieldActiveUser)
  38419. }
  38420. if m.new_user != nil {
  38421. fields = append(fields, usagestatistichour.FieldNewUser)
  38422. }
  38423. if m.label_dist != nil {
  38424. fields = append(fields, usagestatistichour.FieldLabelDist)
  38425. }
  38426. if m.consume_coin != nil {
  38427. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38428. }
  38429. return fields
  38430. }
  38431. // Field returns the value of a field with the given name. The second boolean
  38432. // return value indicates that this field was not set, or was not defined in the
  38433. // schema.
  38434. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  38435. switch name {
  38436. case usagestatistichour.FieldCreatedAt:
  38437. return m.CreatedAt()
  38438. case usagestatistichour.FieldUpdatedAt:
  38439. return m.UpdatedAt()
  38440. case usagestatistichour.FieldStatus:
  38441. return m.Status()
  38442. case usagestatistichour.FieldDeletedAt:
  38443. return m.DeletedAt()
  38444. case usagestatistichour.FieldAddtime:
  38445. return m.Addtime()
  38446. case usagestatistichour.FieldType:
  38447. return m.GetType()
  38448. case usagestatistichour.FieldBotID:
  38449. return m.BotID()
  38450. case usagestatistichour.FieldOrganizationID:
  38451. return m.OrganizationID()
  38452. case usagestatistichour.FieldAiResponse:
  38453. return m.AiResponse()
  38454. case usagestatistichour.FieldSopRun:
  38455. return m.SopRun()
  38456. case usagestatistichour.FieldTotalFriend:
  38457. return m.TotalFriend()
  38458. case usagestatistichour.FieldTotalGroup:
  38459. return m.TotalGroup()
  38460. case usagestatistichour.FieldAccountBalance:
  38461. return m.AccountBalance()
  38462. case usagestatistichour.FieldConsumeToken:
  38463. return m.ConsumeToken()
  38464. case usagestatistichour.FieldActiveUser:
  38465. return m.ActiveUser()
  38466. case usagestatistichour.FieldNewUser:
  38467. return m.NewUser()
  38468. case usagestatistichour.FieldLabelDist:
  38469. return m.LabelDist()
  38470. case usagestatistichour.FieldConsumeCoin:
  38471. return m.ConsumeCoin()
  38472. }
  38473. return nil, false
  38474. }
  38475. // OldField returns the old value of the field from the database. An error is
  38476. // returned if the mutation operation is not UpdateOne, or the query to the
  38477. // database failed.
  38478. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38479. switch name {
  38480. case usagestatistichour.FieldCreatedAt:
  38481. return m.OldCreatedAt(ctx)
  38482. case usagestatistichour.FieldUpdatedAt:
  38483. return m.OldUpdatedAt(ctx)
  38484. case usagestatistichour.FieldStatus:
  38485. return m.OldStatus(ctx)
  38486. case usagestatistichour.FieldDeletedAt:
  38487. return m.OldDeletedAt(ctx)
  38488. case usagestatistichour.FieldAddtime:
  38489. return m.OldAddtime(ctx)
  38490. case usagestatistichour.FieldType:
  38491. return m.OldType(ctx)
  38492. case usagestatistichour.FieldBotID:
  38493. return m.OldBotID(ctx)
  38494. case usagestatistichour.FieldOrganizationID:
  38495. return m.OldOrganizationID(ctx)
  38496. case usagestatistichour.FieldAiResponse:
  38497. return m.OldAiResponse(ctx)
  38498. case usagestatistichour.FieldSopRun:
  38499. return m.OldSopRun(ctx)
  38500. case usagestatistichour.FieldTotalFriend:
  38501. return m.OldTotalFriend(ctx)
  38502. case usagestatistichour.FieldTotalGroup:
  38503. return m.OldTotalGroup(ctx)
  38504. case usagestatistichour.FieldAccountBalance:
  38505. return m.OldAccountBalance(ctx)
  38506. case usagestatistichour.FieldConsumeToken:
  38507. return m.OldConsumeToken(ctx)
  38508. case usagestatistichour.FieldActiveUser:
  38509. return m.OldActiveUser(ctx)
  38510. case usagestatistichour.FieldNewUser:
  38511. return m.OldNewUser(ctx)
  38512. case usagestatistichour.FieldLabelDist:
  38513. return m.OldLabelDist(ctx)
  38514. case usagestatistichour.FieldConsumeCoin:
  38515. return m.OldConsumeCoin(ctx)
  38516. }
  38517. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38518. }
  38519. // SetField sets the value of a field with the given name. It returns an error if
  38520. // the field is not defined in the schema, or if the type mismatched the field
  38521. // type.
  38522. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  38523. switch name {
  38524. case usagestatistichour.FieldCreatedAt:
  38525. v, ok := value.(time.Time)
  38526. if !ok {
  38527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38528. }
  38529. m.SetCreatedAt(v)
  38530. return nil
  38531. case usagestatistichour.FieldUpdatedAt:
  38532. v, ok := value.(time.Time)
  38533. if !ok {
  38534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38535. }
  38536. m.SetUpdatedAt(v)
  38537. return nil
  38538. case usagestatistichour.FieldStatus:
  38539. v, ok := value.(uint8)
  38540. if !ok {
  38541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38542. }
  38543. m.SetStatus(v)
  38544. return nil
  38545. case usagestatistichour.FieldDeletedAt:
  38546. v, ok := value.(time.Time)
  38547. if !ok {
  38548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38549. }
  38550. m.SetDeletedAt(v)
  38551. return nil
  38552. case usagestatistichour.FieldAddtime:
  38553. v, ok := value.(uint64)
  38554. if !ok {
  38555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38556. }
  38557. m.SetAddtime(v)
  38558. return nil
  38559. case usagestatistichour.FieldType:
  38560. v, ok := value.(int)
  38561. if !ok {
  38562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38563. }
  38564. m.SetType(v)
  38565. return nil
  38566. case usagestatistichour.FieldBotID:
  38567. v, ok := value.(string)
  38568. if !ok {
  38569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38570. }
  38571. m.SetBotID(v)
  38572. return nil
  38573. case usagestatistichour.FieldOrganizationID:
  38574. v, ok := value.(uint64)
  38575. if !ok {
  38576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38577. }
  38578. m.SetOrganizationID(v)
  38579. return nil
  38580. case usagestatistichour.FieldAiResponse:
  38581. v, ok := value.(uint64)
  38582. if !ok {
  38583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38584. }
  38585. m.SetAiResponse(v)
  38586. return nil
  38587. case usagestatistichour.FieldSopRun:
  38588. v, ok := value.(uint64)
  38589. if !ok {
  38590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38591. }
  38592. m.SetSopRun(v)
  38593. return nil
  38594. case usagestatistichour.FieldTotalFriend:
  38595. v, ok := value.(uint64)
  38596. if !ok {
  38597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38598. }
  38599. m.SetTotalFriend(v)
  38600. return nil
  38601. case usagestatistichour.FieldTotalGroup:
  38602. v, ok := value.(uint64)
  38603. if !ok {
  38604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38605. }
  38606. m.SetTotalGroup(v)
  38607. return nil
  38608. case usagestatistichour.FieldAccountBalance:
  38609. v, ok := value.(uint64)
  38610. if !ok {
  38611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38612. }
  38613. m.SetAccountBalance(v)
  38614. return nil
  38615. case usagestatistichour.FieldConsumeToken:
  38616. v, ok := value.(uint64)
  38617. if !ok {
  38618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38619. }
  38620. m.SetConsumeToken(v)
  38621. return nil
  38622. case usagestatistichour.FieldActiveUser:
  38623. v, ok := value.(uint64)
  38624. if !ok {
  38625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38626. }
  38627. m.SetActiveUser(v)
  38628. return nil
  38629. case usagestatistichour.FieldNewUser:
  38630. v, ok := value.(int64)
  38631. if !ok {
  38632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38633. }
  38634. m.SetNewUser(v)
  38635. return nil
  38636. case usagestatistichour.FieldLabelDist:
  38637. v, ok := value.([]custom_types.LabelDist)
  38638. if !ok {
  38639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38640. }
  38641. m.SetLabelDist(v)
  38642. return nil
  38643. case usagestatistichour.FieldConsumeCoin:
  38644. v, ok := value.(float64)
  38645. if !ok {
  38646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38647. }
  38648. m.SetConsumeCoin(v)
  38649. return nil
  38650. }
  38651. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38652. }
  38653. // AddedFields returns all numeric fields that were incremented/decremented during
  38654. // this mutation.
  38655. func (m *UsageStatisticHourMutation) AddedFields() []string {
  38656. var fields []string
  38657. if m.addstatus != nil {
  38658. fields = append(fields, usagestatistichour.FieldStatus)
  38659. }
  38660. if m.addaddtime != nil {
  38661. fields = append(fields, usagestatistichour.FieldAddtime)
  38662. }
  38663. if m.add_type != nil {
  38664. fields = append(fields, usagestatistichour.FieldType)
  38665. }
  38666. if m.addorganization_id != nil {
  38667. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38668. }
  38669. if m.addai_response != nil {
  38670. fields = append(fields, usagestatistichour.FieldAiResponse)
  38671. }
  38672. if m.addsop_run != nil {
  38673. fields = append(fields, usagestatistichour.FieldSopRun)
  38674. }
  38675. if m.addtotal_friend != nil {
  38676. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38677. }
  38678. if m.addtotal_group != nil {
  38679. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38680. }
  38681. if m.addaccount_balance != nil {
  38682. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38683. }
  38684. if m.addconsume_token != nil {
  38685. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38686. }
  38687. if m.addactive_user != nil {
  38688. fields = append(fields, usagestatistichour.FieldActiveUser)
  38689. }
  38690. if m.addnew_user != nil {
  38691. fields = append(fields, usagestatistichour.FieldNewUser)
  38692. }
  38693. if m.addconsume_coin != nil {
  38694. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38695. }
  38696. return fields
  38697. }
  38698. // AddedField returns the numeric value that was incremented/decremented on a field
  38699. // with the given name. The second boolean return value indicates that this field
  38700. // was not set, or was not defined in the schema.
  38701. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  38702. switch name {
  38703. case usagestatistichour.FieldStatus:
  38704. return m.AddedStatus()
  38705. case usagestatistichour.FieldAddtime:
  38706. return m.AddedAddtime()
  38707. case usagestatistichour.FieldType:
  38708. return m.AddedType()
  38709. case usagestatistichour.FieldOrganizationID:
  38710. return m.AddedOrganizationID()
  38711. case usagestatistichour.FieldAiResponse:
  38712. return m.AddedAiResponse()
  38713. case usagestatistichour.FieldSopRun:
  38714. return m.AddedSopRun()
  38715. case usagestatistichour.FieldTotalFriend:
  38716. return m.AddedTotalFriend()
  38717. case usagestatistichour.FieldTotalGroup:
  38718. return m.AddedTotalGroup()
  38719. case usagestatistichour.FieldAccountBalance:
  38720. return m.AddedAccountBalance()
  38721. case usagestatistichour.FieldConsumeToken:
  38722. return m.AddedConsumeToken()
  38723. case usagestatistichour.FieldActiveUser:
  38724. return m.AddedActiveUser()
  38725. case usagestatistichour.FieldNewUser:
  38726. return m.AddedNewUser()
  38727. case usagestatistichour.FieldConsumeCoin:
  38728. return m.AddedConsumeCoin()
  38729. }
  38730. return nil, false
  38731. }
  38732. // AddField adds the value to the field with the given name. It returns an error if
  38733. // the field is not defined in the schema, or if the type mismatched the field
  38734. // type.
  38735. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  38736. switch name {
  38737. case usagestatistichour.FieldStatus:
  38738. v, ok := value.(int8)
  38739. if !ok {
  38740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38741. }
  38742. m.AddStatus(v)
  38743. return nil
  38744. case usagestatistichour.FieldAddtime:
  38745. v, ok := value.(int64)
  38746. if !ok {
  38747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38748. }
  38749. m.AddAddtime(v)
  38750. return nil
  38751. case usagestatistichour.FieldType:
  38752. v, ok := value.(int)
  38753. if !ok {
  38754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38755. }
  38756. m.AddType(v)
  38757. return nil
  38758. case usagestatistichour.FieldOrganizationID:
  38759. v, ok := value.(int64)
  38760. if !ok {
  38761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38762. }
  38763. m.AddOrganizationID(v)
  38764. return nil
  38765. case usagestatistichour.FieldAiResponse:
  38766. v, ok := value.(int64)
  38767. if !ok {
  38768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38769. }
  38770. m.AddAiResponse(v)
  38771. return nil
  38772. case usagestatistichour.FieldSopRun:
  38773. v, ok := value.(int64)
  38774. if !ok {
  38775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38776. }
  38777. m.AddSopRun(v)
  38778. return nil
  38779. case usagestatistichour.FieldTotalFriend:
  38780. v, ok := value.(int64)
  38781. if !ok {
  38782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38783. }
  38784. m.AddTotalFriend(v)
  38785. return nil
  38786. case usagestatistichour.FieldTotalGroup:
  38787. v, ok := value.(int64)
  38788. if !ok {
  38789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38790. }
  38791. m.AddTotalGroup(v)
  38792. return nil
  38793. case usagestatistichour.FieldAccountBalance:
  38794. v, ok := value.(int64)
  38795. if !ok {
  38796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38797. }
  38798. m.AddAccountBalance(v)
  38799. return nil
  38800. case usagestatistichour.FieldConsumeToken:
  38801. v, ok := value.(int64)
  38802. if !ok {
  38803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38804. }
  38805. m.AddConsumeToken(v)
  38806. return nil
  38807. case usagestatistichour.FieldActiveUser:
  38808. v, ok := value.(int64)
  38809. if !ok {
  38810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38811. }
  38812. m.AddActiveUser(v)
  38813. return nil
  38814. case usagestatistichour.FieldNewUser:
  38815. v, ok := value.(int64)
  38816. if !ok {
  38817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38818. }
  38819. m.AddNewUser(v)
  38820. return nil
  38821. case usagestatistichour.FieldConsumeCoin:
  38822. v, ok := value.(float64)
  38823. if !ok {
  38824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38825. }
  38826. m.AddConsumeCoin(v)
  38827. return nil
  38828. }
  38829. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  38830. }
  38831. // ClearedFields returns all nullable fields that were cleared during this
  38832. // mutation.
  38833. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  38834. var fields []string
  38835. if m.FieldCleared(usagestatistichour.FieldStatus) {
  38836. fields = append(fields, usagestatistichour.FieldStatus)
  38837. }
  38838. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  38839. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38840. }
  38841. if m.FieldCleared(usagestatistichour.FieldBotID) {
  38842. fields = append(fields, usagestatistichour.FieldBotID)
  38843. }
  38844. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  38845. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38846. }
  38847. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  38848. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38849. }
  38850. return fields
  38851. }
  38852. // FieldCleared returns a boolean indicating if a field with the given name was
  38853. // cleared in this mutation.
  38854. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  38855. _, ok := m.clearedFields[name]
  38856. return ok
  38857. }
  38858. // ClearField clears the value of the field with the given name. It returns an
  38859. // error if the field is not defined in the schema.
  38860. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  38861. switch name {
  38862. case usagestatistichour.FieldStatus:
  38863. m.ClearStatus()
  38864. return nil
  38865. case usagestatistichour.FieldDeletedAt:
  38866. m.ClearDeletedAt()
  38867. return nil
  38868. case usagestatistichour.FieldBotID:
  38869. m.ClearBotID()
  38870. return nil
  38871. case usagestatistichour.FieldOrganizationID:
  38872. m.ClearOrganizationID()
  38873. return nil
  38874. case usagestatistichour.FieldConsumeCoin:
  38875. m.ClearConsumeCoin()
  38876. return nil
  38877. }
  38878. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  38879. }
  38880. // ResetField resets all changes in the mutation for the field with the given name.
  38881. // It returns an error if the field is not defined in the schema.
  38882. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  38883. switch name {
  38884. case usagestatistichour.FieldCreatedAt:
  38885. m.ResetCreatedAt()
  38886. return nil
  38887. case usagestatistichour.FieldUpdatedAt:
  38888. m.ResetUpdatedAt()
  38889. return nil
  38890. case usagestatistichour.FieldStatus:
  38891. m.ResetStatus()
  38892. return nil
  38893. case usagestatistichour.FieldDeletedAt:
  38894. m.ResetDeletedAt()
  38895. return nil
  38896. case usagestatistichour.FieldAddtime:
  38897. m.ResetAddtime()
  38898. return nil
  38899. case usagestatistichour.FieldType:
  38900. m.ResetType()
  38901. return nil
  38902. case usagestatistichour.FieldBotID:
  38903. m.ResetBotID()
  38904. return nil
  38905. case usagestatistichour.FieldOrganizationID:
  38906. m.ResetOrganizationID()
  38907. return nil
  38908. case usagestatistichour.FieldAiResponse:
  38909. m.ResetAiResponse()
  38910. return nil
  38911. case usagestatistichour.FieldSopRun:
  38912. m.ResetSopRun()
  38913. return nil
  38914. case usagestatistichour.FieldTotalFriend:
  38915. m.ResetTotalFriend()
  38916. return nil
  38917. case usagestatistichour.FieldTotalGroup:
  38918. m.ResetTotalGroup()
  38919. return nil
  38920. case usagestatistichour.FieldAccountBalance:
  38921. m.ResetAccountBalance()
  38922. return nil
  38923. case usagestatistichour.FieldConsumeToken:
  38924. m.ResetConsumeToken()
  38925. return nil
  38926. case usagestatistichour.FieldActiveUser:
  38927. m.ResetActiveUser()
  38928. return nil
  38929. case usagestatistichour.FieldNewUser:
  38930. m.ResetNewUser()
  38931. return nil
  38932. case usagestatistichour.FieldLabelDist:
  38933. m.ResetLabelDist()
  38934. return nil
  38935. case usagestatistichour.FieldConsumeCoin:
  38936. m.ResetConsumeCoin()
  38937. return nil
  38938. }
  38939. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38940. }
  38941. // AddedEdges returns all edge names that were set/added in this mutation.
  38942. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  38943. edges := make([]string, 0, 0)
  38944. return edges
  38945. }
  38946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38947. // name in this mutation.
  38948. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  38949. return nil
  38950. }
  38951. // RemovedEdges returns all edge names that were removed in this mutation.
  38952. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  38953. edges := make([]string, 0, 0)
  38954. return edges
  38955. }
  38956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38957. // the given name in this mutation.
  38958. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  38959. return nil
  38960. }
  38961. // ClearedEdges returns all edge names that were cleared in this mutation.
  38962. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  38963. edges := make([]string, 0, 0)
  38964. return edges
  38965. }
  38966. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38967. // was cleared in this mutation.
  38968. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  38969. return false
  38970. }
  38971. // ClearEdge clears the value of the edge with the given name. It returns an error
  38972. // if that edge is not defined in the schema.
  38973. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  38974. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  38975. }
  38976. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38977. // It returns an error if the edge is not defined in the schema.
  38978. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  38979. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  38980. }
  38981. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  38982. type UsageStatisticMonthMutation struct {
  38983. config
  38984. op Op
  38985. typ string
  38986. id *uint64
  38987. created_at *time.Time
  38988. updated_at *time.Time
  38989. status *uint8
  38990. addstatus *int8
  38991. deleted_at *time.Time
  38992. addtime *uint64
  38993. addaddtime *int64
  38994. _type *int
  38995. add_type *int
  38996. bot_id *string
  38997. organization_id *uint64
  38998. addorganization_id *int64
  38999. ai_response *uint64
  39000. addai_response *int64
  39001. sop_run *uint64
  39002. addsop_run *int64
  39003. total_friend *uint64
  39004. addtotal_friend *int64
  39005. total_group *uint64
  39006. addtotal_group *int64
  39007. account_balance *uint64
  39008. addaccount_balance *int64
  39009. consume_token *uint64
  39010. addconsume_token *int64
  39011. active_user *uint64
  39012. addactive_user *int64
  39013. new_user *int64
  39014. addnew_user *int64
  39015. label_dist *[]custom_types.LabelDist
  39016. appendlabel_dist []custom_types.LabelDist
  39017. consume_coin *float64
  39018. addconsume_coin *float64
  39019. clearedFields map[string]struct{}
  39020. done bool
  39021. oldValue func(context.Context) (*UsageStatisticMonth, error)
  39022. predicates []predicate.UsageStatisticMonth
  39023. }
  39024. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  39025. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  39026. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  39027. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  39028. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  39029. m := &UsageStatisticMonthMutation{
  39030. config: c,
  39031. op: op,
  39032. typ: TypeUsageStatisticMonth,
  39033. clearedFields: make(map[string]struct{}),
  39034. }
  39035. for _, opt := range opts {
  39036. opt(m)
  39037. }
  39038. return m
  39039. }
  39040. // withUsageStatisticMonthID sets the ID field of the mutation.
  39041. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  39042. return func(m *UsageStatisticMonthMutation) {
  39043. var (
  39044. err error
  39045. once sync.Once
  39046. value *UsageStatisticMonth
  39047. )
  39048. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  39049. once.Do(func() {
  39050. if m.done {
  39051. err = errors.New("querying old values post mutation is not allowed")
  39052. } else {
  39053. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  39054. }
  39055. })
  39056. return value, err
  39057. }
  39058. m.id = &id
  39059. }
  39060. }
  39061. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  39062. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  39063. return func(m *UsageStatisticMonthMutation) {
  39064. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  39065. return node, nil
  39066. }
  39067. m.id = &node.ID
  39068. }
  39069. }
  39070. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39071. // executed in a transaction (ent.Tx), a transactional client is returned.
  39072. func (m UsageStatisticMonthMutation) Client() *Client {
  39073. client := &Client{config: m.config}
  39074. client.init()
  39075. return client
  39076. }
  39077. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39078. // it returns an error otherwise.
  39079. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  39080. if _, ok := m.driver.(*txDriver); !ok {
  39081. return nil, errors.New("ent: mutation is not running in a transaction")
  39082. }
  39083. tx := &Tx{config: m.config}
  39084. tx.init()
  39085. return tx, nil
  39086. }
  39087. // SetID sets the value of the id field. Note that this
  39088. // operation is only accepted on creation of UsageStatisticMonth entities.
  39089. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  39090. m.id = &id
  39091. }
  39092. // ID returns the ID value in the mutation. Note that the ID is only available
  39093. // if it was provided to the builder or after it was returned from the database.
  39094. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  39095. if m.id == nil {
  39096. return
  39097. }
  39098. return *m.id, true
  39099. }
  39100. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39101. // That means, if the mutation is applied within a transaction with an isolation level such
  39102. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39103. // or updated by the mutation.
  39104. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  39105. switch {
  39106. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39107. id, exists := m.ID()
  39108. if exists {
  39109. return []uint64{id}, nil
  39110. }
  39111. fallthrough
  39112. case m.op.Is(OpUpdate | OpDelete):
  39113. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  39114. default:
  39115. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39116. }
  39117. }
  39118. // SetCreatedAt sets the "created_at" field.
  39119. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  39120. m.created_at = &t
  39121. }
  39122. // CreatedAt returns the value of the "created_at" field in the mutation.
  39123. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  39124. v := m.created_at
  39125. if v == nil {
  39126. return
  39127. }
  39128. return *v, true
  39129. }
  39130. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  39131. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39133. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39134. if !m.op.Is(OpUpdateOne) {
  39135. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39136. }
  39137. if m.id == nil || m.oldValue == nil {
  39138. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39139. }
  39140. oldValue, err := m.oldValue(ctx)
  39141. if err != nil {
  39142. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39143. }
  39144. return oldValue.CreatedAt, nil
  39145. }
  39146. // ResetCreatedAt resets all changes to the "created_at" field.
  39147. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  39148. m.created_at = nil
  39149. }
  39150. // SetUpdatedAt sets the "updated_at" field.
  39151. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  39152. m.updated_at = &t
  39153. }
  39154. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39155. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  39156. v := m.updated_at
  39157. if v == nil {
  39158. return
  39159. }
  39160. return *v, true
  39161. }
  39162. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  39163. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39165. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39166. if !m.op.Is(OpUpdateOne) {
  39167. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39168. }
  39169. if m.id == nil || m.oldValue == nil {
  39170. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39171. }
  39172. oldValue, err := m.oldValue(ctx)
  39173. if err != nil {
  39174. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39175. }
  39176. return oldValue.UpdatedAt, nil
  39177. }
  39178. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39179. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  39180. m.updated_at = nil
  39181. }
  39182. // SetStatus sets the "status" field.
  39183. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  39184. m.status = &u
  39185. m.addstatus = nil
  39186. }
  39187. // Status returns the value of the "status" field in the mutation.
  39188. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  39189. v := m.status
  39190. if v == nil {
  39191. return
  39192. }
  39193. return *v, true
  39194. }
  39195. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  39196. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39198. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39199. if !m.op.Is(OpUpdateOne) {
  39200. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39201. }
  39202. if m.id == nil || m.oldValue == nil {
  39203. return v, errors.New("OldStatus requires an ID field in the mutation")
  39204. }
  39205. oldValue, err := m.oldValue(ctx)
  39206. if err != nil {
  39207. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39208. }
  39209. return oldValue.Status, nil
  39210. }
  39211. // AddStatus adds u to the "status" field.
  39212. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  39213. if m.addstatus != nil {
  39214. *m.addstatus += u
  39215. } else {
  39216. m.addstatus = &u
  39217. }
  39218. }
  39219. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39220. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  39221. v := m.addstatus
  39222. if v == nil {
  39223. return
  39224. }
  39225. return *v, true
  39226. }
  39227. // ClearStatus clears the value of the "status" field.
  39228. func (m *UsageStatisticMonthMutation) ClearStatus() {
  39229. m.status = nil
  39230. m.addstatus = nil
  39231. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  39232. }
  39233. // StatusCleared returns if the "status" field was cleared in this mutation.
  39234. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  39235. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  39236. return ok
  39237. }
  39238. // ResetStatus resets all changes to the "status" field.
  39239. func (m *UsageStatisticMonthMutation) ResetStatus() {
  39240. m.status = nil
  39241. m.addstatus = nil
  39242. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  39243. }
  39244. // SetDeletedAt sets the "deleted_at" field.
  39245. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  39246. m.deleted_at = &t
  39247. }
  39248. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39249. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  39250. v := m.deleted_at
  39251. if v == nil {
  39252. return
  39253. }
  39254. return *v, true
  39255. }
  39256. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  39257. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39259. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39260. if !m.op.Is(OpUpdateOne) {
  39261. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39262. }
  39263. if m.id == nil || m.oldValue == nil {
  39264. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39265. }
  39266. oldValue, err := m.oldValue(ctx)
  39267. if err != nil {
  39268. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39269. }
  39270. return oldValue.DeletedAt, nil
  39271. }
  39272. // ClearDeletedAt clears the value of the "deleted_at" field.
  39273. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  39274. m.deleted_at = nil
  39275. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  39276. }
  39277. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39278. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  39279. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  39280. return ok
  39281. }
  39282. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39283. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  39284. m.deleted_at = nil
  39285. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  39286. }
  39287. // SetAddtime sets the "addtime" field.
  39288. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  39289. m.addtime = &u
  39290. m.addaddtime = nil
  39291. }
  39292. // Addtime returns the value of the "addtime" field in the mutation.
  39293. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  39294. v := m.addtime
  39295. if v == nil {
  39296. return
  39297. }
  39298. return *v, true
  39299. }
  39300. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  39301. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39303. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  39304. if !m.op.Is(OpUpdateOne) {
  39305. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  39306. }
  39307. if m.id == nil || m.oldValue == nil {
  39308. return v, errors.New("OldAddtime requires an ID field in the mutation")
  39309. }
  39310. oldValue, err := m.oldValue(ctx)
  39311. if err != nil {
  39312. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  39313. }
  39314. return oldValue.Addtime, nil
  39315. }
  39316. // AddAddtime adds u to the "addtime" field.
  39317. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  39318. if m.addaddtime != nil {
  39319. *m.addaddtime += u
  39320. } else {
  39321. m.addaddtime = &u
  39322. }
  39323. }
  39324. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  39325. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  39326. v := m.addaddtime
  39327. if v == nil {
  39328. return
  39329. }
  39330. return *v, true
  39331. }
  39332. // ResetAddtime resets all changes to the "addtime" field.
  39333. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  39334. m.addtime = nil
  39335. m.addaddtime = nil
  39336. }
  39337. // SetType sets the "type" field.
  39338. func (m *UsageStatisticMonthMutation) SetType(i int) {
  39339. m._type = &i
  39340. m.add_type = nil
  39341. }
  39342. // GetType returns the value of the "type" field in the mutation.
  39343. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  39344. v := m._type
  39345. if v == nil {
  39346. return
  39347. }
  39348. return *v, true
  39349. }
  39350. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  39351. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39353. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  39354. if !m.op.Is(OpUpdateOne) {
  39355. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39356. }
  39357. if m.id == nil || m.oldValue == nil {
  39358. return v, errors.New("OldType requires an ID field in the mutation")
  39359. }
  39360. oldValue, err := m.oldValue(ctx)
  39361. if err != nil {
  39362. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39363. }
  39364. return oldValue.Type, nil
  39365. }
  39366. // AddType adds i to the "type" field.
  39367. func (m *UsageStatisticMonthMutation) AddType(i int) {
  39368. if m.add_type != nil {
  39369. *m.add_type += i
  39370. } else {
  39371. m.add_type = &i
  39372. }
  39373. }
  39374. // AddedType returns the value that was added to the "type" field in this mutation.
  39375. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  39376. v := m.add_type
  39377. if v == nil {
  39378. return
  39379. }
  39380. return *v, true
  39381. }
  39382. // ResetType resets all changes to the "type" field.
  39383. func (m *UsageStatisticMonthMutation) ResetType() {
  39384. m._type = nil
  39385. m.add_type = nil
  39386. }
  39387. // SetBotID sets the "bot_id" field.
  39388. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  39389. m.bot_id = &s
  39390. }
  39391. // BotID returns the value of the "bot_id" field in the mutation.
  39392. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  39393. v := m.bot_id
  39394. if v == nil {
  39395. return
  39396. }
  39397. return *v, true
  39398. }
  39399. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  39400. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39402. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  39403. if !m.op.Is(OpUpdateOne) {
  39404. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39405. }
  39406. if m.id == nil || m.oldValue == nil {
  39407. return v, errors.New("OldBotID requires an ID field in the mutation")
  39408. }
  39409. oldValue, err := m.oldValue(ctx)
  39410. if err != nil {
  39411. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39412. }
  39413. return oldValue.BotID, nil
  39414. }
  39415. // ClearBotID clears the value of the "bot_id" field.
  39416. func (m *UsageStatisticMonthMutation) ClearBotID() {
  39417. m.bot_id = nil
  39418. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  39419. }
  39420. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  39421. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  39422. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  39423. return ok
  39424. }
  39425. // ResetBotID resets all changes to the "bot_id" field.
  39426. func (m *UsageStatisticMonthMutation) ResetBotID() {
  39427. m.bot_id = nil
  39428. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  39429. }
  39430. // SetOrganizationID sets the "organization_id" field.
  39431. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  39432. m.organization_id = &u
  39433. m.addorganization_id = nil
  39434. }
  39435. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39436. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  39437. v := m.organization_id
  39438. if v == nil {
  39439. return
  39440. }
  39441. return *v, true
  39442. }
  39443. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  39444. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39446. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39447. if !m.op.Is(OpUpdateOne) {
  39448. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39449. }
  39450. if m.id == nil || m.oldValue == nil {
  39451. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39452. }
  39453. oldValue, err := m.oldValue(ctx)
  39454. if err != nil {
  39455. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39456. }
  39457. return oldValue.OrganizationID, nil
  39458. }
  39459. // AddOrganizationID adds u to the "organization_id" field.
  39460. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  39461. if m.addorganization_id != nil {
  39462. *m.addorganization_id += u
  39463. } else {
  39464. m.addorganization_id = &u
  39465. }
  39466. }
  39467. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39468. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  39469. v := m.addorganization_id
  39470. if v == nil {
  39471. return
  39472. }
  39473. return *v, true
  39474. }
  39475. // ClearOrganizationID clears the value of the "organization_id" field.
  39476. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  39477. m.organization_id = nil
  39478. m.addorganization_id = nil
  39479. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  39480. }
  39481. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39482. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  39483. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  39484. return ok
  39485. }
  39486. // ResetOrganizationID resets all changes to the "organization_id" field.
  39487. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  39488. m.organization_id = nil
  39489. m.addorganization_id = nil
  39490. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  39491. }
  39492. // SetAiResponse sets the "ai_response" field.
  39493. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  39494. m.ai_response = &u
  39495. m.addai_response = nil
  39496. }
  39497. // AiResponse returns the value of the "ai_response" field in the mutation.
  39498. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  39499. v := m.ai_response
  39500. if v == nil {
  39501. return
  39502. }
  39503. return *v, true
  39504. }
  39505. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  39506. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39508. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  39509. if !m.op.Is(OpUpdateOne) {
  39510. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  39511. }
  39512. if m.id == nil || m.oldValue == nil {
  39513. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  39514. }
  39515. oldValue, err := m.oldValue(ctx)
  39516. if err != nil {
  39517. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  39518. }
  39519. return oldValue.AiResponse, nil
  39520. }
  39521. // AddAiResponse adds u to the "ai_response" field.
  39522. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  39523. if m.addai_response != nil {
  39524. *m.addai_response += u
  39525. } else {
  39526. m.addai_response = &u
  39527. }
  39528. }
  39529. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  39530. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  39531. v := m.addai_response
  39532. if v == nil {
  39533. return
  39534. }
  39535. return *v, true
  39536. }
  39537. // ResetAiResponse resets all changes to the "ai_response" field.
  39538. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  39539. m.ai_response = nil
  39540. m.addai_response = nil
  39541. }
  39542. // SetSopRun sets the "sop_run" field.
  39543. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  39544. m.sop_run = &u
  39545. m.addsop_run = nil
  39546. }
  39547. // SopRun returns the value of the "sop_run" field in the mutation.
  39548. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  39549. v := m.sop_run
  39550. if v == nil {
  39551. return
  39552. }
  39553. return *v, true
  39554. }
  39555. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  39556. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39558. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  39559. if !m.op.Is(OpUpdateOne) {
  39560. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  39561. }
  39562. if m.id == nil || m.oldValue == nil {
  39563. return v, errors.New("OldSopRun requires an ID field in the mutation")
  39564. }
  39565. oldValue, err := m.oldValue(ctx)
  39566. if err != nil {
  39567. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  39568. }
  39569. return oldValue.SopRun, nil
  39570. }
  39571. // AddSopRun adds u to the "sop_run" field.
  39572. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  39573. if m.addsop_run != nil {
  39574. *m.addsop_run += u
  39575. } else {
  39576. m.addsop_run = &u
  39577. }
  39578. }
  39579. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  39580. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  39581. v := m.addsop_run
  39582. if v == nil {
  39583. return
  39584. }
  39585. return *v, true
  39586. }
  39587. // ResetSopRun resets all changes to the "sop_run" field.
  39588. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  39589. m.sop_run = nil
  39590. m.addsop_run = nil
  39591. }
  39592. // SetTotalFriend sets the "total_friend" field.
  39593. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  39594. m.total_friend = &u
  39595. m.addtotal_friend = nil
  39596. }
  39597. // TotalFriend returns the value of the "total_friend" field in the mutation.
  39598. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  39599. v := m.total_friend
  39600. if v == nil {
  39601. return
  39602. }
  39603. return *v, true
  39604. }
  39605. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  39606. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39608. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  39609. if !m.op.Is(OpUpdateOne) {
  39610. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  39611. }
  39612. if m.id == nil || m.oldValue == nil {
  39613. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  39614. }
  39615. oldValue, err := m.oldValue(ctx)
  39616. if err != nil {
  39617. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  39618. }
  39619. return oldValue.TotalFriend, nil
  39620. }
  39621. // AddTotalFriend adds u to the "total_friend" field.
  39622. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  39623. if m.addtotal_friend != nil {
  39624. *m.addtotal_friend += u
  39625. } else {
  39626. m.addtotal_friend = &u
  39627. }
  39628. }
  39629. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  39630. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  39631. v := m.addtotal_friend
  39632. if v == nil {
  39633. return
  39634. }
  39635. return *v, true
  39636. }
  39637. // ResetTotalFriend resets all changes to the "total_friend" field.
  39638. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  39639. m.total_friend = nil
  39640. m.addtotal_friend = nil
  39641. }
  39642. // SetTotalGroup sets the "total_group" field.
  39643. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  39644. m.total_group = &u
  39645. m.addtotal_group = nil
  39646. }
  39647. // TotalGroup returns the value of the "total_group" field in the mutation.
  39648. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  39649. v := m.total_group
  39650. if v == nil {
  39651. return
  39652. }
  39653. return *v, true
  39654. }
  39655. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  39656. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39658. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  39659. if !m.op.Is(OpUpdateOne) {
  39660. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  39661. }
  39662. if m.id == nil || m.oldValue == nil {
  39663. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  39664. }
  39665. oldValue, err := m.oldValue(ctx)
  39666. if err != nil {
  39667. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  39668. }
  39669. return oldValue.TotalGroup, nil
  39670. }
  39671. // AddTotalGroup adds u to the "total_group" field.
  39672. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  39673. if m.addtotal_group != nil {
  39674. *m.addtotal_group += u
  39675. } else {
  39676. m.addtotal_group = &u
  39677. }
  39678. }
  39679. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  39680. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  39681. v := m.addtotal_group
  39682. if v == nil {
  39683. return
  39684. }
  39685. return *v, true
  39686. }
  39687. // ResetTotalGroup resets all changes to the "total_group" field.
  39688. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  39689. m.total_group = nil
  39690. m.addtotal_group = nil
  39691. }
  39692. // SetAccountBalance sets the "account_balance" field.
  39693. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  39694. m.account_balance = &u
  39695. m.addaccount_balance = nil
  39696. }
  39697. // AccountBalance returns the value of the "account_balance" field in the mutation.
  39698. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  39699. v := m.account_balance
  39700. if v == nil {
  39701. return
  39702. }
  39703. return *v, true
  39704. }
  39705. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  39706. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39708. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  39709. if !m.op.Is(OpUpdateOne) {
  39710. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  39711. }
  39712. if m.id == nil || m.oldValue == nil {
  39713. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  39714. }
  39715. oldValue, err := m.oldValue(ctx)
  39716. if err != nil {
  39717. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  39718. }
  39719. return oldValue.AccountBalance, nil
  39720. }
  39721. // AddAccountBalance adds u to the "account_balance" field.
  39722. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  39723. if m.addaccount_balance != nil {
  39724. *m.addaccount_balance += u
  39725. } else {
  39726. m.addaccount_balance = &u
  39727. }
  39728. }
  39729. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  39730. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  39731. v := m.addaccount_balance
  39732. if v == nil {
  39733. return
  39734. }
  39735. return *v, true
  39736. }
  39737. // ResetAccountBalance resets all changes to the "account_balance" field.
  39738. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  39739. m.account_balance = nil
  39740. m.addaccount_balance = nil
  39741. }
  39742. // SetConsumeToken sets the "consume_token" field.
  39743. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  39744. m.consume_token = &u
  39745. m.addconsume_token = nil
  39746. }
  39747. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  39748. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  39749. v := m.consume_token
  39750. if v == nil {
  39751. return
  39752. }
  39753. return *v, true
  39754. }
  39755. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  39756. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39758. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  39759. if !m.op.Is(OpUpdateOne) {
  39760. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  39761. }
  39762. if m.id == nil || m.oldValue == nil {
  39763. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  39764. }
  39765. oldValue, err := m.oldValue(ctx)
  39766. if err != nil {
  39767. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  39768. }
  39769. return oldValue.ConsumeToken, nil
  39770. }
  39771. // AddConsumeToken adds u to the "consume_token" field.
  39772. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  39773. if m.addconsume_token != nil {
  39774. *m.addconsume_token += u
  39775. } else {
  39776. m.addconsume_token = &u
  39777. }
  39778. }
  39779. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  39780. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  39781. v := m.addconsume_token
  39782. if v == nil {
  39783. return
  39784. }
  39785. return *v, true
  39786. }
  39787. // ResetConsumeToken resets all changes to the "consume_token" field.
  39788. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  39789. m.consume_token = nil
  39790. m.addconsume_token = nil
  39791. }
  39792. // SetActiveUser sets the "active_user" field.
  39793. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  39794. m.active_user = &u
  39795. m.addactive_user = nil
  39796. }
  39797. // ActiveUser returns the value of the "active_user" field in the mutation.
  39798. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  39799. v := m.active_user
  39800. if v == nil {
  39801. return
  39802. }
  39803. return *v, true
  39804. }
  39805. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  39806. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39808. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  39809. if !m.op.Is(OpUpdateOne) {
  39810. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  39811. }
  39812. if m.id == nil || m.oldValue == nil {
  39813. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  39814. }
  39815. oldValue, err := m.oldValue(ctx)
  39816. if err != nil {
  39817. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  39818. }
  39819. return oldValue.ActiveUser, nil
  39820. }
  39821. // AddActiveUser adds u to the "active_user" field.
  39822. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  39823. if m.addactive_user != nil {
  39824. *m.addactive_user += u
  39825. } else {
  39826. m.addactive_user = &u
  39827. }
  39828. }
  39829. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  39830. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  39831. v := m.addactive_user
  39832. if v == nil {
  39833. return
  39834. }
  39835. return *v, true
  39836. }
  39837. // ResetActiveUser resets all changes to the "active_user" field.
  39838. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  39839. m.active_user = nil
  39840. m.addactive_user = nil
  39841. }
  39842. // SetNewUser sets the "new_user" field.
  39843. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  39844. m.new_user = &i
  39845. m.addnew_user = nil
  39846. }
  39847. // NewUser returns the value of the "new_user" field in the mutation.
  39848. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  39849. v := m.new_user
  39850. if v == nil {
  39851. return
  39852. }
  39853. return *v, true
  39854. }
  39855. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  39856. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39858. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  39859. if !m.op.Is(OpUpdateOne) {
  39860. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  39861. }
  39862. if m.id == nil || m.oldValue == nil {
  39863. return v, errors.New("OldNewUser requires an ID field in the mutation")
  39864. }
  39865. oldValue, err := m.oldValue(ctx)
  39866. if err != nil {
  39867. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  39868. }
  39869. return oldValue.NewUser, nil
  39870. }
  39871. // AddNewUser adds i to the "new_user" field.
  39872. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  39873. if m.addnew_user != nil {
  39874. *m.addnew_user += i
  39875. } else {
  39876. m.addnew_user = &i
  39877. }
  39878. }
  39879. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  39880. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  39881. v := m.addnew_user
  39882. if v == nil {
  39883. return
  39884. }
  39885. return *v, true
  39886. }
  39887. // ResetNewUser resets all changes to the "new_user" field.
  39888. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  39889. m.new_user = nil
  39890. m.addnew_user = nil
  39891. }
  39892. // SetLabelDist sets the "label_dist" field.
  39893. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  39894. m.label_dist = &ctd
  39895. m.appendlabel_dist = nil
  39896. }
  39897. // LabelDist returns the value of the "label_dist" field in the mutation.
  39898. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  39899. v := m.label_dist
  39900. if v == nil {
  39901. return
  39902. }
  39903. return *v, true
  39904. }
  39905. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  39906. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39908. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  39909. if !m.op.Is(OpUpdateOne) {
  39910. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  39911. }
  39912. if m.id == nil || m.oldValue == nil {
  39913. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  39914. }
  39915. oldValue, err := m.oldValue(ctx)
  39916. if err != nil {
  39917. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  39918. }
  39919. return oldValue.LabelDist, nil
  39920. }
  39921. // AppendLabelDist adds ctd to the "label_dist" field.
  39922. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  39923. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  39924. }
  39925. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  39926. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  39927. if len(m.appendlabel_dist) == 0 {
  39928. return nil, false
  39929. }
  39930. return m.appendlabel_dist, true
  39931. }
  39932. // ResetLabelDist resets all changes to the "label_dist" field.
  39933. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  39934. m.label_dist = nil
  39935. m.appendlabel_dist = nil
  39936. }
  39937. // SetConsumeCoin sets the "consume_coin" field.
  39938. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  39939. m.consume_coin = &f
  39940. m.addconsume_coin = nil
  39941. }
  39942. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  39943. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  39944. v := m.consume_coin
  39945. if v == nil {
  39946. return
  39947. }
  39948. return *v, true
  39949. }
  39950. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  39951. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39953. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  39954. if !m.op.Is(OpUpdateOne) {
  39955. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  39956. }
  39957. if m.id == nil || m.oldValue == nil {
  39958. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  39959. }
  39960. oldValue, err := m.oldValue(ctx)
  39961. if err != nil {
  39962. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  39963. }
  39964. return oldValue.ConsumeCoin, nil
  39965. }
  39966. // AddConsumeCoin adds f to the "consume_coin" field.
  39967. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  39968. if m.addconsume_coin != nil {
  39969. *m.addconsume_coin += f
  39970. } else {
  39971. m.addconsume_coin = &f
  39972. }
  39973. }
  39974. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  39975. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  39976. v := m.addconsume_coin
  39977. if v == nil {
  39978. return
  39979. }
  39980. return *v, true
  39981. }
  39982. // ClearConsumeCoin clears the value of the "consume_coin" field.
  39983. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  39984. m.consume_coin = nil
  39985. m.addconsume_coin = nil
  39986. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  39987. }
  39988. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  39989. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  39990. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  39991. return ok
  39992. }
  39993. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  39994. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  39995. m.consume_coin = nil
  39996. m.addconsume_coin = nil
  39997. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  39998. }
  39999. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  40000. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  40001. m.predicates = append(m.predicates, ps...)
  40002. }
  40003. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  40004. // users can use type-assertion to append predicates that do not depend on any generated package.
  40005. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  40006. p := make([]predicate.UsageStatisticMonth, len(ps))
  40007. for i := range ps {
  40008. p[i] = ps[i]
  40009. }
  40010. m.Where(p...)
  40011. }
  40012. // Op returns the operation name.
  40013. func (m *UsageStatisticMonthMutation) Op() Op {
  40014. return m.op
  40015. }
  40016. // SetOp allows setting the mutation operation.
  40017. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  40018. m.op = op
  40019. }
  40020. // Type returns the node type of this mutation (UsageStatisticMonth).
  40021. func (m *UsageStatisticMonthMutation) Type() string {
  40022. return m.typ
  40023. }
  40024. // Fields returns all fields that were changed during this mutation. Note that in
  40025. // order to get all numeric fields that were incremented/decremented, call
  40026. // AddedFields().
  40027. func (m *UsageStatisticMonthMutation) Fields() []string {
  40028. fields := make([]string, 0, 18)
  40029. if m.created_at != nil {
  40030. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  40031. }
  40032. if m.updated_at != nil {
  40033. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  40034. }
  40035. if m.status != nil {
  40036. fields = append(fields, usagestatisticmonth.FieldStatus)
  40037. }
  40038. if m.deleted_at != nil {
  40039. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40040. }
  40041. if m.addtime != nil {
  40042. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40043. }
  40044. if m._type != nil {
  40045. fields = append(fields, usagestatisticmonth.FieldType)
  40046. }
  40047. if m.bot_id != nil {
  40048. fields = append(fields, usagestatisticmonth.FieldBotID)
  40049. }
  40050. if m.organization_id != nil {
  40051. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40052. }
  40053. if m.ai_response != nil {
  40054. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40055. }
  40056. if m.sop_run != nil {
  40057. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40058. }
  40059. if m.total_friend != nil {
  40060. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40061. }
  40062. if m.total_group != nil {
  40063. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40064. }
  40065. if m.account_balance != nil {
  40066. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40067. }
  40068. if m.consume_token != nil {
  40069. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40070. }
  40071. if m.active_user != nil {
  40072. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40073. }
  40074. if m.new_user != nil {
  40075. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40076. }
  40077. if m.label_dist != nil {
  40078. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  40079. }
  40080. if m.consume_coin != nil {
  40081. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40082. }
  40083. return fields
  40084. }
  40085. // Field returns the value of a field with the given name. The second boolean
  40086. // return value indicates that this field was not set, or was not defined in the
  40087. // schema.
  40088. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  40089. switch name {
  40090. case usagestatisticmonth.FieldCreatedAt:
  40091. return m.CreatedAt()
  40092. case usagestatisticmonth.FieldUpdatedAt:
  40093. return m.UpdatedAt()
  40094. case usagestatisticmonth.FieldStatus:
  40095. return m.Status()
  40096. case usagestatisticmonth.FieldDeletedAt:
  40097. return m.DeletedAt()
  40098. case usagestatisticmonth.FieldAddtime:
  40099. return m.Addtime()
  40100. case usagestatisticmonth.FieldType:
  40101. return m.GetType()
  40102. case usagestatisticmonth.FieldBotID:
  40103. return m.BotID()
  40104. case usagestatisticmonth.FieldOrganizationID:
  40105. return m.OrganizationID()
  40106. case usagestatisticmonth.FieldAiResponse:
  40107. return m.AiResponse()
  40108. case usagestatisticmonth.FieldSopRun:
  40109. return m.SopRun()
  40110. case usagestatisticmonth.FieldTotalFriend:
  40111. return m.TotalFriend()
  40112. case usagestatisticmonth.FieldTotalGroup:
  40113. return m.TotalGroup()
  40114. case usagestatisticmonth.FieldAccountBalance:
  40115. return m.AccountBalance()
  40116. case usagestatisticmonth.FieldConsumeToken:
  40117. return m.ConsumeToken()
  40118. case usagestatisticmonth.FieldActiveUser:
  40119. return m.ActiveUser()
  40120. case usagestatisticmonth.FieldNewUser:
  40121. return m.NewUser()
  40122. case usagestatisticmonth.FieldLabelDist:
  40123. return m.LabelDist()
  40124. case usagestatisticmonth.FieldConsumeCoin:
  40125. return m.ConsumeCoin()
  40126. }
  40127. return nil, false
  40128. }
  40129. // OldField returns the old value of the field from the database. An error is
  40130. // returned if the mutation operation is not UpdateOne, or the query to the
  40131. // database failed.
  40132. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40133. switch name {
  40134. case usagestatisticmonth.FieldCreatedAt:
  40135. return m.OldCreatedAt(ctx)
  40136. case usagestatisticmonth.FieldUpdatedAt:
  40137. return m.OldUpdatedAt(ctx)
  40138. case usagestatisticmonth.FieldStatus:
  40139. return m.OldStatus(ctx)
  40140. case usagestatisticmonth.FieldDeletedAt:
  40141. return m.OldDeletedAt(ctx)
  40142. case usagestatisticmonth.FieldAddtime:
  40143. return m.OldAddtime(ctx)
  40144. case usagestatisticmonth.FieldType:
  40145. return m.OldType(ctx)
  40146. case usagestatisticmonth.FieldBotID:
  40147. return m.OldBotID(ctx)
  40148. case usagestatisticmonth.FieldOrganizationID:
  40149. return m.OldOrganizationID(ctx)
  40150. case usagestatisticmonth.FieldAiResponse:
  40151. return m.OldAiResponse(ctx)
  40152. case usagestatisticmonth.FieldSopRun:
  40153. return m.OldSopRun(ctx)
  40154. case usagestatisticmonth.FieldTotalFriend:
  40155. return m.OldTotalFriend(ctx)
  40156. case usagestatisticmonth.FieldTotalGroup:
  40157. return m.OldTotalGroup(ctx)
  40158. case usagestatisticmonth.FieldAccountBalance:
  40159. return m.OldAccountBalance(ctx)
  40160. case usagestatisticmonth.FieldConsumeToken:
  40161. return m.OldConsumeToken(ctx)
  40162. case usagestatisticmonth.FieldActiveUser:
  40163. return m.OldActiveUser(ctx)
  40164. case usagestatisticmonth.FieldNewUser:
  40165. return m.OldNewUser(ctx)
  40166. case usagestatisticmonth.FieldLabelDist:
  40167. return m.OldLabelDist(ctx)
  40168. case usagestatisticmonth.FieldConsumeCoin:
  40169. return m.OldConsumeCoin(ctx)
  40170. }
  40171. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40172. }
  40173. // SetField sets the value of a field with the given name. It returns an error if
  40174. // the field is not defined in the schema, or if the type mismatched the field
  40175. // type.
  40176. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  40177. switch name {
  40178. case usagestatisticmonth.FieldCreatedAt:
  40179. v, ok := value.(time.Time)
  40180. if !ok {
  40181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40182. }
  40183. m.SetCreatedAt(v)
  40184. return nil
  40185. case usagestatisticmonth.FieldUpdatedAt:
  40186. v, ok := value.(time.Time)
  40187. if !ok {
  40188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40189. }
  40190. m.SetUpdatedAt(v)
  40191. return nil
  40192. case usagestatisticmonth.FieldStatus:
  40193. v, ok := value.(uint8)
  40194. if !ok {
  40195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40196. }
  40197. m.SetStatus(v)
  40198. return nil
  40199. case usagestatisticmonth.FieldDeletedAt:
  40200. v, ok := value.(time.Time)
  40201. if !ok {
  40202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40203. }
  40204. m.SetDeletedAt(v)
  40205. return nil
  40206. case usagestatisticmonth.FieldAddtime:
  40207. v, ok := value.(uint64)
  40208. if !ok {
  40209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40210. }
  40211. m.SetAddtime(v)
  40212. return nil
  40213. case usagestatisticmonth.FieldType:
  40214. v, ok := value.(int)
  40215. if !ok {
  40216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40217. }
  40218. m.SetType(v)
  40219. return nil
  40220. case usagestatisticmonth.FieldBotID:
  40221. v, ok := value.(string)
  40222. if !ok {
  40223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40224. }
  40225. m.SetBotID(v)
  40226. return nil
  40227. case usagestatisticmonth.FieldOrganizationID:
  40228. v, ok := value.(uint64)
  40229. if !ok {
  40230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40231. }
  40232. m.SetOrganizationID(v)
  40233. return nil
  40234. case usagestatisticmonth.FieldAiResponse:
  40235. v, ok := value.(uint64)
  40236. if !ok {
  40237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40238. }
  40239. m.SetAiResponse(v)
  40240. return nil
  40241. case usagestatisticmonth.FieldSopRun:
  40242. v, ok := value.(uint64)
  40243. if !ok {
  40244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40245. }
  40246. m.SetSopRun(v)
  40247. return nil
  40248. case usagestatisticmonth.FieldTotalFriend:
  40249. v, ok := value.(uint64)
  40250. if !ok {
  40251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40252. }
  40253. m.SetTotalFriend(v)
  40254. return nil
  40255. case usagestatisticmonth.FieldTotalGroup:
  40256. v, ok := value.(uint64)
  40257. if !ok {
  40258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40259. }
  40260. m.SetTotalGroup(v)
  40261. return nil
  40262. case usagestatisticmonth.FieldAccountBalance:
  40263. v, ok := value.(uint64)
  40264. if !ok {
  40265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40266. }
  40267. m.SetAccountBalance(v)
  40268. return nil
  40269. case usagestatisticmonth.FieldConsumeToken:
  40270. v, ok := value.(uint64)
  40271. if !ok {
  40272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40273. }
  40274. m.SetConsumeToken(v)
  40275. return nil
  40276. case usagestatisticmonth.FieldActiveUser:
  40277. v, ok := value.(uint64)
  40278. if !ok {
  40279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40280. }
  40281. m.SetActiveUser(v)
  40282. return nil
  40283. case usagestatisticmonth.FieldNewUser:
  40284. v, ok := value.(int64)
  40285. if !ok {
  40286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40287. }
  40288. m.SetNewUser(v)
  40289. return nil
  40290. case usagestatisticmonth.FieldLabelDist:
  40291. v, ok := value.([]custom_types.LabelDist)
  40292. if !ok {
  40293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40294. }
  40295. m.SetLabelDist(v)
  40296. return nil
  40297. case usagestatisticmonth.FieldConsumeCoin:
  40298. v, ok := value.(float64)
  40299. if !ok {
  40300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40301. }
  40302. m.SetConsumeCoin(v)
  40303. return nil
  40304. }
  40305. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40306. }
  40307. // AddedFields returns all numeric fields that were incremented/decremented during
  40308. // this mutation.
  40309. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  40310. var fields []string
  40311. if m.addstatus != nil {
  40312. fields = append(fields, usagestatisticmonth.FieldStatus)
  40313. }
  40314. if m.addaddtime != nil {
  40315. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40316. }
  40317. if m.add_type != nil {
  40318. fields = append(fields, usagestatisticmonth.FieldType)
  40319. }
  40320. if m.addorganization_id != nil {
  40321. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40322. }
  40323. if m.addai_response != nil {
  40324. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40325. }
  40326. if m.addsop_run != nil {
  40327. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40328. }
  40329. if m.addtotal_friend != nil {
  40330. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40331. }
  40332. if m.addtotal_group != nil {
  40333. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40334. }
  40335. if m.addaccount_balance != nil {
  40336. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40337. }
  40338. if m.addconsume_token != nil {
  40339. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40340. }
  40341. if m.addactive_user != nil {
  40342. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40343. }
  40344. if m.addnew_user != nil {
  40345. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40346. }
  40347. if m.addconsume_coin != nil {
  40348. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40349. }
  40350. return fields
  40351. }
  40352. // AddedField returns the numeric value that was incremented/decremented on a field
  40353. // with the given name. The second boolean return value indicates that this field
  40354. // was not set, or was not defined in the schema.
  40355. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  40356. switch name {
  40357. case usagestatisticmonth.FieldStatus:
  40358. return m.AddedStatus()
  40359. case usagestatisticmonth.FieldAddtime:
  40360. return m.AddedAddtime()
  40361. case usagestatisticmonth.FieldType:
  40362. return m.AddedType()
  40363. case usagestatisticmonth.FieldOrganizationID:
  40364. return m.AddedOrganizationID()
  40365. case usagestatisticmonth.FieldAiResponse:
  40366. return m.AddedAiResponse()
  40367. case usagestatisticmonth.FieldSopRun:
  40368. return m.AddedSopRun()
  40369. case usagestatisticmonth.FieldTotalFriend:
  40370. return m.AddedTotalFriend()
  40371. case usagestatisticmonth.FieldTotalGroup:
  40372. return m.AddedTotalGroup()
  40373. case usagestatisticmonth.FieldAccountBalance:
  40374. return m.AddedAccountBalance()
  40375. case usagestatisticmonth.FieldConsumeToken:
  40376. return m.AddedConsumeToken()
  40377. case usagestatisticmonth.FieldActiveUser:
  40378. return m.AddedActiveUser()
  40379. case usagestatisticmonth.FieldNewUser:
  40380. return m.AddedNewUser()
  40381. case usagestatisticmonth.FieldConsumeCoin:
  40382. return m.AddedConsumeCoin()
  40383. }
  40384. return nil, false
  40385. }
  40386. // AddField adds the value to the field with the given name. It returns an error if
  40387. // the field is not defined in the schema, or if the type mismatched the field
  40388. // type.
  40389. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  40390. switch name {
  40391. case usagestatisticmonth.FieldStatus:
  40392. v, ok := value.(int8)
  40393. if !ok {
  40394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40395. }
  40396. m.AddStatus(v)
  40397. return nil
  40398. case usagestatisticmonth.FieldAddtime:
  40399. v, ok := value.(int64)
  40400. if !ok {
  40401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40402. }
  40403. m.AddAddtime(v)
  40404. return nil
  40405. case usagestatisticmonth.FieldType:
  40406. v, ok := value.(int)
  40407. if !ok {
  40408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40409. }
  40410. m.AddType(v)
  40411. return nil
  40412. case usagestatisticmonth.FieldOrganizationID:
  40413. v, ok := value.(int64)
  40414. if !ok {
  40415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40416. }
  40417. m.AddOrganizationID(v)
  40418. return nil
  40419. case usagestatisticmonth.FieldAiResponse:
  40420. v, ok := value.(int64)
  40421. if !ok {
  40422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40423. }
  40424. m.AddAiResponse(v)
  40425. return nil
  40426. case usagestatisticmonth.FieldSopRun:
  40427. v, ok := value.(int64)
  40428. if !ok {
  40429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40430. }
  40431. m.AddSopRun(v)
  40432. return nil
  40433. case usagestatisticmonth.FieldTotalFriend:
  40434. v, ok := value.(int64)
  40435. if !ok {
  40436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40437. }
  40438. m.AddTotalFriend(v)
  40439. return nil
  40440. case usagestatisticmonth.FieldTotalGroup:
  40441. v, ok := value.(int64)
  40442. if !ok {
  40443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40444. }
  40445. m.AddTotalGroup(v)
  40446. return nil
  40447. case usagestatisticmonth.FieldAccountBalance:
  40448. v, ok := value.(int64)
  40449. if !ok {
  40450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40451. }
  40452. m.AddAccountBalance(v)
  40453. return nil
  40454. case usagestatisticmonth.FieldConsumeToken:
  40455. v, ok := value.(int64)
  40456. if !ok {
  40457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40458. }
  40459. m.AddConsumeToken(v)
  40460. return nil
  40461. case usagestatisticmonth.FieldActiveUser:
  40462. v, ok := value.(int64)
  40463. if !ok {
  40464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40465. }
  40466. m.AddActiveUser(v)
  40467. return nil
  40468. case usagestatisticmonth.FieldNewUser:
  40469. v, ok := value.(int64)
  40470. if !ok {
  40471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40472. }
  40473. m.AddNewUser(v)
  40474. return nil
  40475. case usagestatisticmonth.FieldConsumeCoin:
  40476. v, ok := value.(float64)
  40477. if !ok {
  40478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40479. }
  40480. m.AddConsumeCoin(v)
  40481. return nil
  40482. }
  40483. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  40484. }
  40485. // ClearedFields returns all nullable fields that were cleared during this
  40486. // mutation.
  40487. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  40488. var fields []string
  40489. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  40490. fields = append(fields, usagestatisticmonth.FieldStatus)
  40491. }
  40492. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  40493. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40494. }
  40495. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  40496. fields = append(fields, usagestatisticmonth.FieldBotID)
  40497. }
  40498. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  40499. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40500. }
  40501. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  40502. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40503. }
  40504. return fields
  40505. }
  40506. // FieldCleared returns a boolean indicating if a field with the given name was
  40507. // cleared in this mutation.
  40508. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  40509. _, ok := m.clearedFields[name]
  40510. return ok
  40511. }
  40512. // ClearField clears the value of the field with the given name. It returns an
  40513. // error if the field is not defined in the schema.
  40514. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  40515. switch name {
  40516. case usagestatisticmonth.FieldStatus:
  40517. m.ClearStatus()
  40518. return nil
  40519. case usagestatisticmonth.FieldDeletedAt:
  40520. m.ClearDeletedAt()
  40521. return nil
  40522. case usagestatisticmonth.FieldBotID:
  40523. m.ClearBotID()
  40524. return nil
  40525. case usagestatisticmonth.FieldOrganizationID:
  40526. m.ClearOrganizationID()
  40527. return nil
  40528. case usagestatisticmonth.FieldConsumeCoin:
  40529. m.ClearConsumeCoin()
  40530. return nil
  40531. }
  40532. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  40533. }
  40534. // ResetField resets all changes in the mutation for the field with the given name.
  40535. // It returns an error if the field is not defined in the schema.
  40536. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  40537. switch name {
  40538. case usagestatisticmonth.FieldCreatedAt:
  40539. m.ResetCreatedAt()
  40540. return nil
  40541. case usagestatisticmonth.FieldUpdatedAt:
  40542. m.ResetUpdatedAt()
  40543. return nil
  40544. case usagestatisticmonth.FieldStatus:
  40545. m.ResetStatus()
  40546. return nil
  40547. case usagestatisticmonth.FieldDeletedAt:
  40548. m.ResetDeletedAt()
  40549. return nil
  40550. case usagestatisticmonth.FieldAddtime:
  40551. m.ResetAddtime()
  40552. return nil
  40553. case usagestatisticmonth.FieldType:
  40554. m.ResetType()
  40555. return nil
  40556. case usagestatisticmonth.FieldBotID:
  40557. m.ResetBotID()
  40558. return nil
  40559. case usagestatisticmonth.FieldOrganizationID:
  40560. m.ResetOrganizationID()
  40561. return nil
  40562. case usagestatisticmonth.FieldAiResponse:
  40563. m.ResetAiResponse()
  40564. return nil
  40565. case usagestatisticmonth.FieldSopRun:
  40566. m.ResetSopRun()
  40567. return nil
  40568. case usagestatisticmonth.FieldTotalFriend:
  40569. m.ResetTotalFriend()
  40570. return nil
  40571. case usagestatisticmonth.FieldTotalGroup:
  40572. m.ResetTotalGroup()
  40573. return nil
  40574. case usagestatisticmonth.FieldAccountBalance:
  40575. m.ResetAccountBalance()
  40576. return nil
  40577. case usagestatisticmonth.FieldConsumeToken:
  40578. m.ResetConsumeToken()
  40579. return nil
  40580. case usagestatisticmonth.FieldActiveUser:
  40581. m.ResetActiveUser()
  40582. return nil
  40583. case usagestatisticmonth.FieldNewUser:
  40584. m.ResetNewUser()
  40585. return nil
  40586. case usagestatisticmonth.FieldLabelDist:
  40587. m.ResetLabelDist()
  40588. return nil
  40589. case usagestatisticmonth.FieldConsumeCoin:
  40590. m.ResetConsumeCoin()
  40591. return nil
  40592. }
  40593. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40594. }
  40595. // AddedEdges returns all edge names that were set/added in this mutation.
  40596. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  40597. edges := make([]string, 0, 0)
  40598. return edges
  40599. }
  40600. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40601. // name in this mutation.
  40602. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  40603. return nil
  40604. }
  40605. // RemovedEdges returns all edge names that were removed in this mutation.
  40606. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  40607. edges := make([]string, 0, 0)
  40608. return edges
  40609. }
  40610. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40611. // the given name in this mutation.
  40612. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  40613. return nil
  40614. }
  40615. // ClearedEdges returns all edge names that were cleared in this mutation.
  40616. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  40617. edges := make([]string, 0, 0)
  40618. return edges
  40619. }
  40620. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40621. // was cleared in this mutation.
  40622. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  40623. return false
  40624. }
  40625. // ClearEdge clears the value of the edge with the given name. It returns an error
  40626. // if that edge is not defined in the schema.
  40627. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  40628. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  40629. }
  40630. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40631. // It returns an error if the edge is not defined in the schema.
  40632. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  40633. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  40634. }
  40635. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  40636. type UsageTotalMutation struct {
  40637. config
  40638. op Op
  40639. typ string
  40640. id *uint64
  40641. created_at *time.Time
  40642. updated_at *time.Time
  40643. status *uint8
  40644. addstatus *int8
  40645. _type *int
  40646. add_type *int
  40647. bot_id *string
  40648. total_tokens *uint64
  40649. addtotal_tokens *int64
  40650. start_index *uint64
  40651. addstart_index *int64
  40652. end_index *uint64
  40653. addend_index *int64
  40654. organization_id *uint64
  40655. addorganization_id *int64
  40656. clearedFields map[string]struct{}
  40657. done bool
  40658. oldValue func(context.Context) (*UsageTotal, error)
  40659. predicates []predicate.UsageTotal
  40660. }
  40661. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40662. // usagetotalOption allows management of the mutation configuration using functional options.
  40663. type usagetotalOption func(*UsageTotalMutation)
  40664. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40665. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40666. m := &UsageTotalMutation{
  40667. config: c,
  40668. op: op,
  40669. typ: TypeUsageTotal,
  40670. clearedFields: make(map[string]struct{}),
  40671. }
  40672. for _, opt := range opts {
  40673. opt(m)
  40674. }
  40675. return m
  40676. }
  40677. // withUsageTotalID sets the ID field of the mutation.
  40678. func withUsageTotalID(id uint64) usagetotalOption {
  40679. return func(m *UsageTotalMutation) {
  40680. var (
  40681. err error
  40682. once sync.Once
  40683. value *UsageTotal
  40684. )
  40685. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40686. once.Do(func() {
  40687. if m.done {
  40688. err = errors.New("querying old values post mutation is not allowed")
  40689. } else {
  40690. value, err = m.Client().UsageTotal.Get(ctx, id)
  40691. }
  40692. })
  40693. return value, err
  40694. }
  40695. m.id = &id
  40696. }
  40697. }
  40698. // withUsageTotal sets the old UsageTotal of the mutation.
  40699. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40700. return func(m *UsageTotalMutation) {
  40701. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40702. return node, nil
  40703. }
  40704. m.id = &node.ID
  40705. }
  40706. }
  40707. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40708. // executed in a transaction (ent.Tx), a transactional client is returned.
  40709. func (m UsageTotalMutation) Client() *Client {
  40710. client := &Client{config: m.config}
  40711. client.init()
  40712. return client
  40713. }
  40714. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40715. // it returns an error otherwise.
  40716. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40717. if _, ok := m.driver.(*txDriver); !ok {
  40718. return nil, errors.New("ent: mutation is not running in a transaction")
  40719. }
  40720. tx := &Tx{config: m.config}
  40721. tx.init()
  40722. return tx, nil
  40723. }
  40724. // SetID sets the value of the id field. Note that this
  40725. // operation is only accepted on creation of UsageTotal entities.
  40726. func (m *UsageTotalMutation) SetID(id uint64) {
  40727. m.id = &id
  40728. }
  40729. // ID returns the ID value in the mutation. Note that the ID is only available
  40730. // if it was provided to the builder or after it was returned from the database.
  40731. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40732. if m.id == nil {
  40733. return
  40734. }
  40735. return *m.id, true
  40736. }
  40737. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40738. // That means, if the mutation is applied within a transaction with an isolation level such
  40739. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40740. // or updated by the mutation.
  40741. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  40742. switch {
  40743. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40744. id, exists := m.ID()
  40745. if exists {
  40746. return []uint64{id}, nil
  40747. }
  40748. fallthrough
  40749. case m.op.Is(OpUpdate | OpDelete):
  40750. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  40751. default:
  40752. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40753. }
  40754. }
  40755. // SetCreatedAt sets the "created_at" field.
  40756. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  40757. m.created_at = &t
  40758. }
  40759. // CreatedAt returns the value of the "created_at" field in the mutation.
  40760. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  40761. v := m.created_at
  40762. if v == nil {
  40763. return
  40764. }
  40765. return *v, true
  40766. }
  40767. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  40768. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40770. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40771. if !m.op.Is(OpUpdateOne) {
  40772. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40773. }
  40774. if m.id == nil || m.oldValue == nil {
  40775. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40776. }
  40777. oldValue, err := m.oldValue(ctx)
  40778. if err != nil {
  40779. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40780. }
  40781. return oldValue.CreatedAt, nil
  40782. }
  40783. // ResetCreatedAt resets all changes to the "created_at" field.
  40784. func (m *UsageTotalMutation) ResetCreatedAt() {
  40785. m.created_at = nil
  40786. }
  40787. // SetUpdatedAt sets the "updated_at" field.
  40788. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  40789. m.updated_at = &t
  40790. }
  40791. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40792. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  40793. v := m.updated_at
  40794. if v == nil {
  40795. return
  40796. }
  40797. return *v, true
  40798. }
  40799. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  40800. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40802. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40803. if !m.op.Is(OpUpdateOne) {
  40804. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40805. }
  40806. if m.id == nil || m.oldValue == nil {
  40807. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40808. }
  40809. oldValue, err := m.oldValue(ctx)
  40810. if err != nil {
  40811. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40812. }
  40813. return oldValue.UpdatedAt, nil
  40814. }
  40815. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40816. func (m *UsageTotalMutation) ResetUpdatedAt() {
  40817. m.updated_at = nil
  40818. }
  40819. // SetStatus sets the "status" field.
  40820. func (m *UsageTotalMutation) SetStatus(u uint8) {
  40821. m.status = &u
  40822. m.addstatus = nil
  40823. }
  40824. // Status returns the value of the "status" field in the mutation.
  40825. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  40826. v := m.status
  40827. if v == nil {
  40828. return
  40829. }
  40830. return *v, true
  40831. }
  40832. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  40833. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40835. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40836. if !m.op.Is(OpUpdateOne) {
  40837. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40838. }
  40839. if m.id == nil || m.oldValue == nil {
  40840. return v, errors.New("OldStatus requires an ID field in the mutation")
  40841. }
  40842. oldValue, err := m.oldValue(ctx)
  40843. if err != nil {
  40844. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40845. }
  40846. return oldValue.Status, nil
  40847. }
  40848. // AddStatus adds u to the "status" field.
  40849. func (m *UsageTotalMutation) AddStatus(u int8) {
  40850. if m.addstatus != nil {
  40851. *m.addstatus += u
  40852. } else {
  40853. m.addstatus = &u
  40854. }
  40855. }
  40856. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40857. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  40858. v := m.addstatus
  40859. if v == nil {
  40860. return
  40861. }
  40862. return *v, true
  40863. }
  40864. // ClearStatus clears the value of the "status" field.
  40865. func (m *UsageTotalMutation) ClearStatus() {
  40866. m.status = nil
  40867. m.addstatus = nil
  40868. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  40869. }
  40870. // StatusCleared returns if the "status" field was cleared in this mutation.
  40871. func (m *UsageTotalMutation) StatusCleared() bool {
  40872. _, ok := m.clearedFields[usagetotal.FieldStatus]
  40873. return ok
  40874. }
  40875. // ResetStatus resets all changes to the "status" field.
  40876. func (m *UsageTotalMutation) ResetStatus() {
  40877. m.status = nil
  40878. m.addstatus = nil
  40879. delete(m.clearedFields, usagetotal.FieldStatus)
  40880. }
  40881. // SetType sets the "type" field.
  40882. func (m *UsageTotalMutation) SetType(i int) {
  40883. m._type = &i
  40884. m.add_type = nil
  40885. }
  40886. // GetType returns the value of the "type" field in the mutation.
  40887. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  40888. v := m._type
  40889. if v == nil {
  40890. return
  40891. }
  40892. return *v, true
  40893. }
  40894. // OldType returns the old "type" field's value of the UsageTotal entity.
  40895. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40897. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  40898. if !m.op.Is(OpUpdateOne) {
  40899. return v, errors.New("OldType is only allowed on UpdateOne operations")
  40900. }
  40901. if m.id == nil || m.oldValue == nil {
  40902. return v, errors.New("OldType requires an ID field in the mutation")
  40903. }
  40904. oldValue, err := m.oldValue(ctx)
  40905. if err != nil {
  40906. return v, fmt.Errorf("querying old value for OldType: %w", err)
  40907. }
  40908. return oldValue.Type, nil
  40909. }
  40910. // AddType adds i to the "type" field.
  40911. func (m *UsageTotalMutation) AddType(i int) {
  40912. if m.add_type != nil {
  40913. *m.add_type += i
  40914. } else {
  40915. m.add_type = &i
  40916. }
  40917. }
  40918. // AddedType returns the value that was added to the "type" field in this mutation.
  40919. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  40920. v := m.add_type
  40921. if v == nil {
  40922. return
  40923. }
  40924. return *v, true
  40925. }
  40926. // ClearType clears the value of the "type" field.
  40927. func (m *UsageTotalMutation) ClearType() {
  40928. m._type = nil
  40929. m.add_type = nil
  40930. m.clearedFields[usagetotal.FieldType] = struct{}{}
  40931. }
  40932. // TypeCleared returns if the "type" field was cleared in this mutation.
  40933. func (m *UsageTotalMutation) TypeCleared() bool {
  40934. _, ok := m.clearedFields[usagetotal.FieldType]
  40935. return ok
  40936. }
  40937. // ResetType resets all changes to the "type" field.
  40938. func (m *UsageTotalMutation) ResetType() {
  40939. m._type = nil
  40940. m.add_type = nil
  40941. delete(m.clearedFields, usagetotal.FieldType)
  40942. }
  40943. // SetBotID sets the "bot_id" field.
  40944. func (m *UsageTotalMutation) SetBotID(s string) {
  40945. m.bot_id = &s
  40946. }
  40947. // BotID returns the value of the "bot_id" field in the mutation.
  40948. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  40949. v := m.bot_id
  40950. if v == nil {
  40951. return
  40952. }
  40953. return *v, true
  40954. }
  40955. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  40956. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40958. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  40959. if !m.op.Is(OpUpdateOne) {
  40960. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  40961. }
  40962. if m.id == nil || m.oldValue == nil {
  40963. return v, errors.New("OldBotID requires an ID field in the mutation")
  40964. }
  40965. oldValue, err := m.oldValue(ctx)
  40966. if err != nil {
  40967. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  40968. }
  40969. return oldValue.BotID, nil
  40970. }
  40971. // ResetBotID resets all changes to the "bot_id" field.
  40972. func (m *UsageTotalMutation) ResetBotID() {
  40973. m.bot_id = nil
  40974. }
  40975. // SetTotalTokens sets the "total_tokens" field.
  40976. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  40977. m.total_tokens = &u
  40978. m.addtotal_tokens = nil
  40979. }
  40980. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  40981. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  40982. v := m.total_tokens
  40983. if v == nil {
  40984. return
  40985. }
  40986. return *v, true
  40987. }
  40988. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  40989. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40991. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  40992. if !m.op.Is(OpUpdateOne) {
  40993. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  40994. }
  40995. if m.id == nil || m.oldValue == nil {
  40996. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  40997. }
  40998. oldValue, err := m.oldValue(ctx)
  40999. if err != nil {
  41000. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41001. }
  41002. return oldValue.TotalTokens, nil
  41003. }
  41004. // AddTotalTokens adds u to the "total_tokens" field.
  41005. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41006. if m.addtotal_tokens != nil {
  41007. *m.addtotal_tokens += u
  41008. } else {
  41009. m.addtotal_tokens = &u
  41010. }
  41011. }
  41012. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41013. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41014. v := m.addtotal_tokens
  41015. if v == nil {
  41016. return
  41017. }
  41018. return *v, true
  41019. }
  41020. // ClearTotalTokens clears the value of the "total_tokens" field.
  41021. func (m *UsageTotalMutation) ClearTotalTokens() {
  41022. m.total_tokens = nil
  41023. m.addtotal_tokens = nil
  41024. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41025. }
  41026. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41027. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41028. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41029. return ok
  41030. }
  41031. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41032. func (m *UsageTotalMutation) ResetTotalTokens() {
  41033. m.total_tokens = nil
  41034. m.addtotal_tokens = nil
  41035. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41036. }
  41037. // SetStartIndex sets the "start_index" field.
  41038. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41039. m.start_index = &u
  41040. m.addstart_index = nil
  41041. }
  41042. // StartIndex returns the value of the "start_index" field in the mutation.
  41043. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41044. v := m.start_index
  41045. if v == nil {
  41046. return
  41047. }
  41048. return *v, true
  41049. }
  41050. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41051. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41053. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41054. if !m.op.Is(OpUpdateOne) {
  41055. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41056. }
  41057. if m.id == nil || m.oldValue == nil {
  41058. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41059. }
  41060. oldValue, err := m.oldValue(ctx)
  41061. if err != nil {
  41062. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41063. }
  41064. return oldValue.StartIndex, nil
  41065. }
  41066. // AddStartIndex adds u to the "start_index" field.
  41067. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41068. if m.addstart_index != nil {
  41069. *m.addstart_index += u
  41070. } else {
  41071. m.addstart_index = &u
  41072. }
  41073. }
  41074. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41075. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41076. v := m.addstart_index
  41077. if v == nil {
  41078. return
  41079. }
  41080. return *v, true
  41081. }
  41082. // ClearStartIndex clears the value of the "start_index" field.
  41083. func (m *UsageTotalMutation) ClearStartIndex() {
  41084. m.start_index = nil
  41085. m.addstart_index = nil
  41086. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41087. }
  41088. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41089. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41090. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41091. return ok
  41092. }
  41093. // ResetStartIndex resets all changes to the "start_index" field.
  41094. func (m *UsageTotalMutation) ResetStartIndex() {
  41095. m.start_index = nil
  41096. m.addstart_index = nil
  41097. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41098. }
  41099. // SetEndIndex sets the "end_index" field.
  41100. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41101. m.end_index = &u
  41102. m.addend_index = nil
  41103. }
  41104. // EndIndex returns the value of the "end_index" field in the mutation.
  41105. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41106. v := m.end_index
  41107. if v == nil {
  41108. return
  41109. }
  41110. return *v, true
  41111. }
  41112. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41113. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41115. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41116. if !m.op.Is(OpUpdateOne) {
  41117. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41118. }
  41119. if m.id == nil || m.oldValue == nil {
  41120. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41121. }
  41122. oldValue, err := m.oldValue(ctx)
  41123. if err != nil {
  41124. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41125. }
  41126. return oldValue.EndIndex, nil
  41127. }
  41128. // AddEndIndex adds u to the "end_index" field.
  41129. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41130. if m.addend_index != nil {
  41131. *m.addend_index += u
  41132. } else {
  41133. m.addend_index = &u
  41134. }
  41135. }
  41136. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41137. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41138. v := m.addend_index
  41139. if v == nil {
  41140. return
  41141. }
  41142. return *v, true
  41143. }
  41144. // ClearEndIndex clears the value of the "end_index" field.
  41145. func (m *UsageTotalMutation) ClearEndIndex() {
  41146. m.end_index = nil
  41147. m.addend_index = nil
  41148. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41149. }
  41150. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41151. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41152. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41153. return ok
  41154. }
  41155. // ResetEndIndex resets all changes to the "end_index" field.
  41156. func (m *UsageTotalMutation) ResetEndIndex() {
  41157. m.end_index = nil
  41158. m.addend_index = nil
  41159. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41160. }
  41161. // SetOrganizationID sets the "organization_id" field.
  41162. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41163. m.organization_id = &u
  41164. m.addorganization_id = nil
  41165. }
  41166. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41167. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41168. v := m.organization_id
  41169. if v == nil {
  41170. return
  41171. }
  41172. return *v, true
  41173. }
  41174. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41175. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41177. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41178. if !m.op.Is(OpUpdateOne) {
  41179. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41180. }
  41181. if m.id == nil || m.oldValue == nil {
  41182. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41183. }
  41184. oldValue, err := m.oldValue(ctx)
  41185. if err != nil {
  41186. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41187. }
  41188. return oldValue.OrganizationID, nil
  41189. }
  41190. // AddOrganizationID adds u to the "organization_id" field.
  41191. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41192. if m.addorganization_id != nil {
  41193. *m.addorganization_id += u
  41194. } else {
  41195. m.addorganization_id = &u
  41196. }
  41197. }
  41198. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41199. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41200. v := m.addorganization_id
  41201. if v == nil {
  41202. return
  41203. }
  41204. return *v, true
  41205. }
  41206. // ClearOrganizationID clears the value of the "organization_id" field.
  41207. func (m *UsageTotalMutation) ClearOrganizationID() {
  41208. m.organization_id = nil
  41209. m.addorganization_id = nil
  41210. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41211. }
  41212. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41213. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41214. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41215. return ok
  41216. }
  41217. // ResetOrganizationID resets all changes to the "organization_id" field.
  41218. func (m *UsageTotalMutation) ResetOrganizationID() {
  41219. m.organization_id = nil
  41220. m.addorganization_id = nil
  41221. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41222. }
  41223. // Where appends a list predicates to the UsageTotalMutation builder.
  41224. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41225. m.predicates = append(m.predicates, ps...)
  41226. }
  41227. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41228. // users can use type-assertion to append predicates that do not depend on any generated package.
  41229. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41230. p := make([]predicate.UsageTotal, len(ps))
  41231. for i := range ps {
  41232. p[i] = ps[i]
  41233. }
  41234. m.Where(p...)
  41235. }
  41236. // Op returns the operation name.
  41237. func (m *UsageTotalMutation) Op() Op {
  41238. return m.op
  41239. }
  41240. // SetOp allows setting the mutation operation.
  41241. func (m *UsageTotalMutation) SetOp(op Op) {
  41242. m.op = op
  41243. }
  41244. // Type returns the node type of this mutation (UsageTotal).
  41245. func (m *UsageTotalMutation) Type() string {
  41246. return m.typ
  41247. }
  41248. // Fields returns all fields that were changed during this mutation. Note that in
  41249. // order to get all numeric fields that were incremented/decremented, call
  41250. // AddedFields().
  41251. func (m *UsageTotalMutation) Fields() []string {
  41252. fields := make([]string, 0, 9)
  41253. if m.created_at != nil {
  41254. fields = append(fields, usagetotal.FieldCreatedAt)
  41255. }
  41256. if m.updated_at != nil {
  41257. fields = append(fields, usagetotal.FieldUpdatedAt)
  41258. }
  41259. if m.status != nil {
  41260. fields = append(fields, usagetotal.FieldStatus)
  41261. }
  41262. if m._type != nil {
  41263. fields = append(fields, usagetotal.FieldType)
  41264. }
  41265. if m.bot_id != nil {
  41266. fields = append(fields, usagetotal.FieldBotID)
  41267. }
  41268. if m.total_tokens != nil {
  41269. fields = append(fields, usagetotal.FieldTotalTokens)
  41270. }
  41271. if m.start_index != nil {
  41272. fields = append(fields, usagetotal.FieldStartIndex)
  41273. }
  41274. if m.end_index != nil {
  41275. fields = append(fields, usagetotal.FieldEndIndex)
  41276. }
  41277. if m.organization_id != nil {
  41278. fields = append(fields, usagetotal.FieldOrganizationID)
  41279. }
  41280. return fields
  41281. }
  41282. // Field returns the value of a field with the given name. The second boolean
  41283. // return value indicates that this field was not set, or was not defined in the
  41284. // schema.
  41285. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41286. switch name {
  41287. case usagetotal.FieldCreatedAt:
  41288. return m.CreatedAt()
  41289. case usagetotal.FieldUpdatedAt:
  41290. return m.UpdatedAt()
  41291. case usagetotal.FieldStatus:
  41292. return m.Status()
  41293. case usagetotal.FieldType:
  41294. return m.GetType()
  41295. case usagetotal.FieldBotID:
  41296. return m.BotID()
  41297. case usagetotal.FieldTotalTokens:
  41298. return m.TotalTokens()
  41299. case usagetotal.FieldStartIndex:
  41300. return m.StartIndex()
  41301. case usagetotal.FieldEndIndex:
  41302. return m.EndIndex()
  41303. case usagetotal.FieldOrganizationID:
  41304. return m.OrganizationID()
  41305. }
  41306. return nil, false
  41307. }
  41308. // OldField returns the old value of the field from the database. An error is
  41309. // returned if the mutation operation is not UpdateOne, or the query to the
  41310. // database failed.
  41311. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41312. switch name {
  41313. case usagetotal.FieldCreatedAt:
  41314. return m.OldCreatedAt(ctx)
  41315. case usagetotal.FieldUpdatedAt:
  41316. return m.OldUpdatedAt(ctx)
  41317. case usagetotal.FieldStatus:
  41318. return m.OldStatus(ctx)
  41319. case usagetotal.FieldType:
  41320. return m.OldType(ctx)
  41321. case usagetotal.FieldBotID:
  41322. return m.OldBotID(ctx)
  41323. case usagetotal.FieldTotalTokens:
  41324. return m.OldTotalTokens(ctx)
  41325. case usagetotal.FieldStartIndex:
  41326. return m.OldStartIndex(ctx)
  41327. case usagetotal.FieldEndIndex:
  41328. return m.OldEndIndex(ctx)
  41329. case usagetotal.FieldOrganizationID:
  41330. return m.OldOrganizationID(ctx)
  41331. }
  41332. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41333. }
  41334. // SetField sets the value of a field with the given name. It returns an error if
  41335. // the field is not defined in the schema, or if the type mismatched the field
  41336. // type.
  41337. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41338. switch name {
  41339. case usagetotal.FieldCreatedAt:
  41340. v, ok := value.(time.Time)
  41341. if !ok {
  41342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41343. }
  41344. m.SetCreatedAt(v)
  41345. return nil
  41346. case usagetotal.FieldUpdatedAt:
  41347. v, ok := value.(time.Time)
  41348. if !ok {
  41349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41350. }
  41351. m.SetUpdatedAt(v)
  41352. return nil
  41353. case usagetotal.FieldStatus:
  41354. v, ok := value.(uint8)
  41355. if !ok {
  41356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41357. }
  41358. m.SetStatus(v)
  41359. return nil
  41360. case usagetotal.FieldType:
  41361. v, ok := value.(int)
  41362. if !ok {
  41363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41364. }
  41365. m.SetType(v)
  41366. return nil
  41367. case usagetotal.FieldBotID:
  41368. v, ok := value.(string)
  41369. if !ok {
  41370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41371. }
  41372. m.SetBotID(v)
  41373. return nil
  41374. case usagetotal.FieldTotalTokens:
  41375. v, ok := value.(uint64)
  41376. if !ok {
  41377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41378. }
  41379. m.SetTotalTokens(v)
  41380. return nil
  41381. case usagetotal.FieldStartIndex:
  41382. v, ok := value.(uint64)
  41383. if !ok {
  41384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41385. }
  41386. m.SetStartIndex(v)
  41387. return nil
  41388. case usagetotal.FieldEndIndex:
  41389. v, ok := value.(uint64)
  41390. if !ok {
  41391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41392. }
  41393. m.SetEndIndex(v)
  41394. return nil
  41395. case usagetotal.FieldOrganizationID:
  41396. v, ok := value.(uint64)
  41397. if !ok {
  41398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41399. }
  41400. m.SetOrganizationID(v)
  41401. return nil
  41402. }
  41403. return fmt.Errorf("unknown UsageTotal field %s", name)
  41404. }
  41405. // AddedFields returns all numeric fields that were incremented/decremented during
  41406. // this mutation.
  41407. func (m *UsageTotalMutation) AddedFields() []string {
  41408. var fields []string
  41409. if m.addstatus != nil {
  41410. fields = append(fields, usagetotal.FieldStatus)
  41411. }
  41412. if m.add_type != nil {
  41413. fields = append(fields, usagetotal.FieldType)
  41414. }
  41415. if m.addtotal_tokens != nil {
  41416. fields = append(fields, usagetotal.FieldTotalTokens)
  41417. }
  41418. if m.addstart_index != nil {
  41419. fields = append(fields, usagetotal.FieldStartIndex)
  41420. }
  41421. if m.addend_index != nil {
  41422. fields = append(fields, usagetotal.FieldEndIndex)
  41423. }
  41424. if m.addorganization_id != nil {
  41425. fields = append(fields, usagetotal.FieldOrganizationID)
  41426. }
  41427. return fields
  41428. }
  41429. // AddedField returns the numeric value that was incremented/decremented on a field
  41430. // with the given name. The second boolean return value indicates that this field
  41431. // was not set, or was not defined in the schema.
  41432. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41433. switch name {
  41434. case usagetotal.FieldStatus:
  41435. return m.AddedStatus()
  41436. case usagetotal.FieldType:
  41437. return m.AddedType()
  41438. case usagetotal.FieldTotalTokens:
  41439. return m.AddedTotalTokens()
  41440. case usagetotal.FieldStartIndex:
  41441. return m.AddedStartIndex()
  41442. case usagetotal.FieldEndIndex:
  41443. return m.AddedEndIndex()
  41444. case usagetotal.FieldOrganizationID:
  41445. return m.AddedOrganizationID()
  41446. }
  41447. return nil, false
  41448. }
  41449. // AddField adds the value to the field with the given name. It returns an error if
  41450. // the field is not defined in the schema, or if the type mismatched the field
  41451. // type.
  41452. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41453. switch name {
  41454. case usagetotal.FieldStatus:
  41455. v, ok := value.(int8)
  41456. if !ok {
  41457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41458. }
  41459. m.AddStatus(v)
  41460. return nil
  41461. case usagetotal.FieldType:
  41462. v, ok := value.(int)
  41463. if !ok {
  41464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41465. }
  41466. m.AddType(v)
  41467. return nil
  41468. case usagetotal.FieldTotalTokens:
  41469. v, ok := value.(int64)
  41470. if !ok {
  41471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41472. }
  41473. m.AddTotalTokens(v)
  41474. return nil
  41475. case usagetotal.FieldStartIndex:
  41476. v, ok := value.(int64)
  41477. if !ok {
  41478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41479. }
  41480. m.AddStartIndex(v)
  41481. return nil
  41482. case usagetotal.FieldEndIndex:
  41483. v, ok := value.(int64)
  41484. if !ok {
  41485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41486. }
  41487. m.AddEndIndex(v)
  41488. return nil
  41489. case usagetotal.FieldOrganizationID:
  41490. v, ok := value.(int64)
  41491. if !ok {
  41492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41493. }
  41494. m.AddOrganizationID(v)
  41495. return nil
  41496. }
  41497. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41498. }
  41499. // ClearedFields returns all nullable fields that were cleared during this
  41500. // mutation.
  41501. func (m *UsageTotalMutation) ClearedFields() []string {
  41502. var fields []string
  41503. if m.FieldCleared(usagetotal.FieldStatus) {
  41504. fields = append(fields, usagetotal.FieldStatus)
  41505. }
  41506. if m.FieldCleared(usagetotal.FieldType) {
  41507. fields = append(fields, usagetotal.FieldType)
  41508. }
  41509. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41510. fields = append(fields, usagetotal.FieldTotalTokens)
  41511. }
  41512. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41513. fields = append(fields, usagetotal.FieldStartIndex)
  41514. }
  41515. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41516. fields = append(fields, usagetotal.FieldEndIndex)
  41517. }
  41518. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41519. fields = append(fields, usagetotal.FieldOrganizationID)
  41520. }
  41521. return fields
  41522. }
  41523. // FieldCleared returns a boolean indicating if a field with the given name was
  41524. // cleared in this mutation.
  41525. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41526. _, ok := m.clearedFields[name]
  41527. return ok
  41528. }
  41529. // ClearField clears the value of the field with the given name. It returns an
  41530. // error if the field is not defined in the schema.
  41531. func (m *UsageTotalMutation) ClearField(name string) error {
  41532. switch name {
  41533. case usagetotal.FieldStatus:
  41534. m.ClearStatus()
  41535. return nil
  41536. case usagetotal.FieldType:
  41537. m.ClearType()
  41538. return nil
  41539. case usagetotal.FieldTotalTokens:
  41540. m.ClearTotalTokens()
  41541. return nil
  41542. case usagetotal.FieldStartIndex:
  41543. m.ClearStartIndex()
  41544. return nil
  41545. case usagetotal.FieldEndIndex:
  41546. m.ClearEndIndex()
  41547. return nil
  41548. case usagetotal.FieldOrganizationID:
  41549. m.ClearOrganizationID()
  41550. return nil
  41551. }
  41552. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41553. }
  41554. // ResetField resets all changes in the mutation for the field with the given name.
  41555. // It returns an error if the field is not defined in the schema.
  41556. func (m *UsageTotalMutation) ResetField(name string) error {
  41557. switch name {
  41558. case usagetotal.FieldCreatedAt:
  41559. m.ResetCreatedAt()
  41560. return nil
  41561. case usagetotal.FieldUpdatedAt:
  41562. m.ResetUpdatedAt()
  41563. return nil
  41564. case usagetotal.FieldStatus:
  41565. m.ResetStatus()
  41566. return nil
  41567. case usagetotal.FieldType:
  41568. m.ResetType()
  41569. return nil
  41570. case usagetotal.FieldBotID:
  41571. m.ResetBotID()
  41572. return nil
  41573. case usagetotal.FieldTotalTokens:
  41574. m.ResetTotalTokens()
  41575. return nil
  41576. case usagetotal.FieldStartIndex:
  41577. m.ResetStartIndex()
  41578. return nil
  41579. case usagetotal.FieldEndIndex:
  41580. m.ResetEndIndex()
  41581. return nil
  41582. case usagetotal.FieldOrganizationID:
  41583. m.ResetOrganizationID()
  41584. return nil
  41585. }
  41586. return fmt.Errorf("unknown UsageTotal field %s", name)
  41587. }
  41588. // AddedEdges returns all edge names that were set/added in this mutation.
  41589. func (m *UsageTotalMutation) AddedEdges() []string {
  41590. edges := make([]string, 0, 0)
  41591. return edges
  41592. }
  41593. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41594. // name in this mutation.
  41595. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41596. return nil
  41597. }
  41598. // RemovedEdges returns all edge names that were removed in this mutation.
  41599. func (m *UsageTotalMutation) RemovedEdges() []string {
  41600. edges := make([]string, 0, 0)
  41601. return edges
  41602. }
  41603. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41604. // the given name in this mutation.
  41605. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41606. return nil
  41607. }
  41608. // ClearedEdges returns all edge names that were cleared in this mutation.
  41609. func (m *UsageTotalMutation) ClearedEdges() []string {
  41610. edges := make([]string, 0, 0)
  41611. return edges
  41612. }
  41613. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41614. // was cleared in this mutation.
  41615. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41616. return false
  41617. }
  41618. // ClearEdge clears the value of the edge with the given name. It returns an error
  41619. // if that edge is not defined in the schema.
  41620. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41621. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41622. }
  41623. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41624. // It returns an error if the edge is not defined in the schema.
  41625. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41626. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41627. }
  41628. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41629. type WhatsappMutation struct {
  41630. config
  41631. op Op
  41632. typ string
  41633. id *uint64
  41634. created_at *time.Time
  41635. updated_at *time.Time
  41636. status *uint8
  41637. addstatus *int8
  41638. deleted_at *time.Time
  41639. wa_id *string
  41640. wa_name *string
  41641. callback *string
  41642. account *string
  41643. cc *string
  41644. phone *string
  41645. cc_phone *string
  41646. phone_name *string
  41647. phone_status *int8
  41648. addphone_status *int8
  41649. organization_id *uint64
  41650. addorganization_id *int64
  41651. api_base *string
  41652. api_key *string
  41653. allow_list *[]string
  41654. appendallow_list []string
  41655. group_allow_list *[]string
  41656. appendgroup_allow_list []string
  41657. block_list *[]string
  41658. appendblock_list []string
  41659. group_block_list *[]string
  41660. appendgroup_block_list []string
  41661. clearedFields map[string]struct{}
  41662. agent *uint64
  41663. clearedagent bool
  41664. done bool
  41665. oldValue func(context.Context) (*Whatsapp, error)
  41666. predicates []predicate.Whatsapp
  41667. }
  41668. var _ ent.Mutation = (*WhatsappMutation)(nil)
  41669. // whatsappOption allows management of the mutation configuration using functional options.
  41670. type whatsappOption func(*WhatsappMutation)
  41671. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  41672. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  41673. m := &WhatsappMutation{
  41674. config: c,
  41675. op: op,
  41676. typ: TypeWhatsapp,
  41677. clearedFields: make(map[string]struct{}),
  41678. }
  41679. for _, opt := range opts {
  41680. opt(m)
  41681. }
  41682. return m
  41683. }
  41684. // withWhatsappID sets the ID field of the mutation.
  41685. func withWhatsappID(id uint64) whatsappOption {
  41686. return func(m *WhatsappMutation) {
  41687. var (
  41688. err error
  41689. once sync.Once
  41690. value *Whatsapp
  41691. )
  41692. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  41693. once.Do(func() {
  41694. if m.done {
  41695. err = errors.New("querying old values post mutation is not allowed")
  41696. } else {
  41697. value, err = m.Client().Whatsapp.Get(ctx, id)
  41698. }
  41699. })
  41700. return value, err
  41701. }
  41702. m.id = &id
  41703. }
  41704. }
  41705. // withWhatsapp sets the old Whatsapp of the mutation.
  41706. func withWhatsapp(node *Whatsapp) whatsappOption {
  41707. return func(m *WhatsappMutation) {
  41708. m.oldValue = func(context.Context) (*Whatsapp, error) {
  41709. return node, nil
  41710. }
  41711. m.id = &node.ID
  41712. }
  41713. }
  41714. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41715. // executed in a transaction (ent.Tx), a transactional client is returned.
  41716. func (m WhatsappMutation) Client() *Client {
  41717. client := &Client{config: m.config}
  41718. client.init()
  41719. return client
  41720. }
  41721. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41722. // it returns an error otherwise.
  41723. func (m WhatsappMutation) Tx() (*Tx, error) {
  41724. if _, ok := m.driver.(*txDriver); !ok {
  41725. return nil, errors.New("ent: mutation is not running in a transaction")
  41726. }
  41727. tx := &Tx{config: m.config}
  41728. tx.init()
  41729. return tx, nil
  41730. }
  41731. // SetID sets the value of the id field. Note that this
  41732. // operation is only accepted on creation of Whatsapp entities.
  41733. func (m *WhatsappMutation) SetID(id uint64) {
  41734. m.id = &id
  41735. }
  41736. // ID returns the ID value in the mutation. Note that the ID is only available
  41737. // if it was provided to the builder or after it was returned from the database.
  41738. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  41739. if m.id == nil {
  41740. return
  41741. }
  41742. return *m.id, true
  41743. }
  41744. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41745. // That means, if the mutation is applied within a transaction with an isolation level such
  41746. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41747. // or updated by the mutation.
  41748. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  41749. switch {
  41750. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41751. id, exists := m.ID()
  41752. if exists {
  41753. return []uint64{id}, nil
  41754. }
  41755. fallthrough
  41756. case m.op.Is(OpUpdate | OpDelete):
  41757. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  41758. default:
  41759. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41760. }
  41761. }
  41762. // SetCreatedAt sets the "created_at" field.
  41763. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  41764. m.created_at = &t
  41765. }
  41766. // CreatedAt returns the value of the "created_at" field in the mutation.
  41767. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  41768. v := m.created_at
  41769. if v == nil {
  41770. return
  41771. }
  41772. return *v, true
  41773. }
  41774. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  41775. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41777. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41778. if !m.op.Is(OpUpdateOne) {
  41779. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41780. }
  41781. if m.id == nil || m.oldValue == nil {
  41782. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41783. }
  41784. oldValue, err := m.oldValue(ctx)
  41785. if err != nil {
  41786. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41787. }
  41788. return oldValue.CreatedAt, nil
  41789. }
  41790. // ResetCreatedAt resets all changes to the "created_at" field.
  41791. func (m *WhatsappMutation) ResetCreatedAt() {
  41792. m.created_at = nil
  41793. }
  41794. // SetUpdatedAt sets the "updated_at" field.
  41795. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  41796. m.updated_at = &t
  41797. }
  41798. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41799. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  41800. v := m.updated_at
  41801. if v == nil {
  41802. return
  41803. }
  41804. return *v, true
  41805. }
  41806. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  41807. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41809. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41810. if !m.op.Is(OpUpdateOne) {
  41811. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41812. }
  41813. if m.id == nil || m.oldValue == nil {
  41814. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41815. }
  41816. oldValue, err := m.oldValue(ctx)
  41817. if err != nil {
  41818. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41819. }
  41820. return oldValue.UpdatedAt, nil
  41821. }
  41822. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41823. func (m *WhatsappMutation) ResetUpdatedAt() {
  41824. m.updated_at = nil
  41825. }
  41826. // SetStatus sets the "status" field.
  41827. func (m *WhatsappMutation) SetStatus(u uint8) {
  41828. m.status = &u
  41829. m.addstatus = nil
  41830. }
  41831. // Status returns the value of the "status" field in the mutation.
  41832. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  41833. v := m.status
  41834. if v == nil {
  41835. return
  41836. }
  41837. return *v, true
  41838. }
  41839. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  41840. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41842. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41843. if !m.op.Is(OpUpdateOne) {
  41844. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41845. }
  41846. if m.id == nil || m.oldValue == nil {
  41847. return v, errors.New("OldStatus requires an ID field in the mutation")
  41848. }
  41849. oldValue, err := m.oldValue(ctx)
  41850. if err != nil {
  41851. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41852. }
  41853. return oldValue.Status, nil
  41854. }
  41855. // AddStatus adds u to the "status" field.
  41856. func (m *WhatsappMutation) AddStatus(u int8) {
  41857. if m.addstatus != nil {
  41858. *m.addstatus += u
  41859. } else {
  41860. m.addstatus = &u
  41861. }
  41862. }
  41863. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41864. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  41865. v := m.addstatus
  41866. if v == nil {
  41867. return
  41868. }
  41869. return *v, true
  41870. }
  41871. // ClearStatus clears the value of the "status" field.
  41872. func (m *WhatsappMutation) ClearStatus() {
  41873. m.status = nil
  41874. m.addstatus = nil
  41875. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  41876. }
  41877. // StatusCleared returns if the "status" field was cleared in this mutation.
  41878. func (m *WhatsappMutation) StatusCleared() bool {
  41879. _, ok := m.clearedFields[whatsapp.FieldStatus]
  41880. return ok
  41881. }
  41882. // ResetStatus resets all changes to the "status" field.
  41883. func (m *WhatsappMutation) ResetStatus() {
  41884. m.status = nil
  41885. m.addstatus = nil
  41886. delete(m.clearedFields, whatsapp.FieldStatus)
  41887. }
  41888. // SetDeletedAt sets the "deleted_at" field.
  41889. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  41890. m.deleted_at = &t
  41891. }
  41892. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41893. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  41894. v := m.deleted_at
  41895. if v == nil {
  41896. return
  41897. }
  41898. return *v, true
  41899. }
  41900. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  41901. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41903. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41904. if !m.op.Is(OpUpdateOne) {
  41905. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41906. }
  41907. if m.id == nil || m.oldValue == nil {
  41908. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41909. }
  41910. oldValue, err := m.oldValue(ctx)
  41911. if err != nil {
  41912. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41913. }
  41914. return oldValue.DeletedAt, nil
  41915. }
  41916. // ClearDeletedAt clears the value of the "deleted_at" field.
  41917. func (m *WhatsappMutation) ClearDeletedAt() {
  41918. m.deleted_at = nil
  41919. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  41920. }
  41921. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41922. func (m *WhatsappMutation) DeletedAtCleared() bool {
  41923. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  41924. return ok
  41925. }
  41926. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41927. func (m *WhatsappMutation) ResetDeletedAt() {
  41928. m.deleted_at = nil
  41929. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  41930. }
  41931. // SetWaID sets the "wa_id" field.
  41932. func (m *WhatsappMutation) SetWaID(s string) {
  41933. m.wa_id = &s
  41934. }
  41935. // WaID returns the value of the "wa_id" field in the mutation.
  41936. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  41937. v := m.wa_id
  41938. if v == nil {
  41939. return
  41940. }
  41941. return *v, true
  41942. }
  41943. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  41944. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41946. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  41947. if !m.op.Is(OpUpdateOne) {
  41948. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41949. }
  41950. if m.id == nil || m.oldValue == nil {
  41951. return v, errors.New("OldWaID requires an ID field in the mutation")
  41952. }
  41953. oldValue, err := m.oldValue(ctx)
  41954. if err != nil {
  41955. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41956. }
  41957. return oldValue.WaID, nil
  41958. }
  41959. // ClearWaID clears the value of the "wa_id" field.
  41960. func (m *WhatsappMutation) ClearWaID() {
  41961. m.wa_id = nil
  41962. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  41963. }
  41964. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41965. func (m *WhatsappMutation) WaIDCleared() bool {
  41966. _, ok := m.clearedFields[whatsapp.FieldWaID]
  41967. return ok
  41968. }
  41969. // ResetWaID resets all changes to the "wa_id" field.
  41970. func (m *WhatsappMutation) ResetWaID() {
  41971. m.wa_id = nil
  41972. delete(m.clearedFields, whatsapp.FieldWaID)
  41973. }
  41974. // SetWaName sets the "wa_name" field.
  41975. func (m *WhatsappMutation) SetWaName(s string) {
  41976. m.wa_name = &s
  41977. }
  41978. // WaName returns the value of the "wa_name" field in the mutation.
  41979. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  41980. v := m.wa_name
  41981. if v == nil {
  41982. return
  41983. }
  41984. return *v, true
  41985. }
  41986. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  41987. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  41988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41989. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  41990. if !m.op.Is(OpUpdateOne) {
  41991. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41992. }
  41993. if m.id == nil || m.oldValue == nil {
  41994. return v, errors.New("OldWaName requires an ID field in the mutation")
  41995. }
  41996. oldValue, err := m.oldValue(ctx)
  41997. if err != nil {
  41998. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41999. }
  42000. return oldValue.WaName, nil
  42001. }
  42002. // ClearWaName clears the value of the "wa_name" field.
  42003. func (m *WhatsappMutation) ClearWaName() {
  42004. m.wa_name = nil
  42005. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42006. }
  42007. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42008. func (m *WhatsappMutation) WaNameCleared() bool {
  42009. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42010. return ok
  42011. }
  42012. // ResetWaName resets all changes to the "wa_name" field.
  42013. func (m *WhatsappMutation) ResetWaName() {
  42014. m.wa_name = nil
  42015. delete(m.clearedFields, whatsapp.FieldWaName)
  42016. }
  42017. // SetCallback sets the "callback" field.
  42018. func (m *WhatsappMutation) SetCallback(s string) {
  42019. m.callback = &s
  42020. }
  42021. // Callback returns the value of the "callback" field in the mutation.
  42022. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42023. v := m.callback
  42024. if v == nil {
  42025. return
  42026. }
  42027. return *v, true
  42028. }
  42029. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42030. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42032. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42033. if !m.op.Is(OpUpdateOne) {
  42034. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42035. }
  42036. if m.id == nil || m.oldValue == nil {
  42037. return v, errors.New("OldCallback requires an ID field in the mutation")
  42038. }
  42039. oldValue, err := m.oldValue(ctx)
  42040. if err != nil {
  42041. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42042. }
  42043. return oldValue.Callback, nil
  42044. }
  42045. // ClearCallback clears the value of the "callback" field.
  42046. func (m *WhatsappMutation) ClearCallback() {
  42047. m.callback = nil
  42048. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42049. }
  42050. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42051. func (m *WhatsappMutation) CallbackCleared() bool {
  42052. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42053. return ok
  42054. }
  42055. // ResetCallback resets all changes to the "callback" field.
  42056. func (m *WhatsappMutation) ResetCallback() {
  42057. m.callback = nil
  42058. delete(m.clearedFields, whatsapp.FieldCallback)
  42059. }
  42060. // SetAgentID sets the "agent_id" field.
  42061. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42062. m.agent = &u
  42063. }
  42064. // AgentID returns the value of the "agent_id" field in the mutation.
  42065. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42066. v := m.agent
  42067. if v == nil {
  42068. return
  42069. }
  42070. return *v, true
  42071. }
  42072. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42073. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42075. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42076. if !m.op.Is(OpUpdateOne) {
  42077. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42078. }
  42079. if m.id == nil || m.oldValue == nil {
  42080. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42081. }
  42082. oldValue, err := m.oldValue(ctx)
  42083. if err != nil {
  42084. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42085. }
  42086. return oldValue.AgentID, nil
  42087. }
  42088. // ResetAgentID resets all changes to the "agent_id" field.
  42089. func (m *WhatsappMutation) ResetAgentID() {
  42090. m.agent = nil
  42091. }
  42092. // SetAccount sets the "account" field.
  42093. func (m *WhatsappMutation) SetAccount(s string) {
  42094. m.account = &s
  42095. }
  42096. // Account returns the value of the "account" field in the mutation.
  42097. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42098. v := m.account
  42099. if v == nil {
  42100. return
  42101. }
  42102. return *v, true
  42103. }
  42104. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42105. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42107. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42108. if !m.op.Is(OpUpdateOne) {
  42109. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42110. }
  42111. if m.id == nil || m.oldValue == nil {
  42112. return v, errors.New("OldAccount requires an ID field in the mutation")
  42113. }
  42114. oldValue, err := m.oldValue(ctx)
  42115. if err != nil {
  42116. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42117. }
  42118. return oldValue.Account, nil
  42119. }
  42120. // ClearAccount clears the value of the "account" field.
  42121. func (m *WhatsappMutation) ClearAccount() {
  42122. m.account = nil
  42123. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42124. }
  42125. // AccountCleared returns if the "account" field was cleared in this mutation.
  42126. func (m *WhatsappMutation) AccountCleared() bool {
  42127. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42128. return ok
  42129. }
  42130. // ResetAccount resets all changes to the "account" field.
  42131. func (m *WhatsappMutation) ResetAccount() {
  42132. m.account = nil
  42133. delete(m.clearedFields, whatsapp.FieldAccount)
  42134. }
  42135. // SetCc sets the "cc" field.
  42136. func (m *WhatsappMutation) SetCc(s string) {
  42137. m.cc = &s
  42138. }
  42139. // Cc returns the value of the "cc" field in the mutation.
  42140. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42141. v := m.cc
  42142. if v == nil {
  42143. return
  42144. }
  42145. return *v, true
  42146. }
  42147. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42148. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42150. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42151. if !m.op.Is(OpUpdateOne) {
  42152. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42153. }
  42154. if m.id == nil || m.oldValue == nil {
  42155. return v, errors.New("OldCc requires an ID field in the mutation")
  42156. }
  42157. oldValue, err := m.oldValue(ctx)
  42158. if err != nil {
  42159. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42160. }
  42161. return oldValue.Cc, nil
  42162. }
  42163. // ResetCc resets all changes to the "cc" field.
  42164. func (m *WhatsappMutation) ResetCc() {
  42165. m.cc = nil
  42166. }
  42167. // SetPhone sets the "phone" field.
  42168. func (m *WhatsappMutation) SetPhone(s string) {
  42169. m.phone = &s
  42170. }
  42171. // Phone returns the value of the "phone" field in the mutation.
  42172. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42173. v := m.phone
  42174. if v == nil {
  42175. return
  42176. }
  42177. return *v, true
  42178. }
  42179. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42182. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42183. if !m.op.Is(OpUpdateOne) {
  42184. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42185. }
  42186. if m.id == nil || m.oldValue == nil {
  42187. return v, errors.New("OldPhone requires an ID field in the mutation")
  42188. }
  42189. oldValue, err := m.oldValue(ctx)
  42190. if err != nil {
  42191. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42192. }
  42193. return oldValue.Phone, nil
  42194. }
  42195. // ResetPhone resets all changes to the "phone" field.
  42196. func (m *WhatsappMutation) ResetPhone() {
  42197. m.phone = nil
  42198. }
  42199. // SetCcPhone sets the "cc_phone" field.
  42200. func (m *WhatsappMutation) SetCcPhone(s string) {
  42201. m.cc_phone = &s
  42202. }
  42203. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42204. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42205. v := m.cc_phone
  42206. if v == nil {
  42207. return
  42208. }
  42209. return *v, true
  42210. }
  42211. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42212. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42214. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42215. if !m.op.Is(OpUpdateOne) {
  42216. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42217. }
  42218. if m.id == nil || m.oldValue == nil {
  42219. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42220. }
  42221. oldValue, err := m.oldValue(ctx)
  42222. if err != nil {
  42223. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42224. }
  42225. return oldValue.CcPhone, nil
  42226. }
  42227. // ResetCcPhone resets all changes to the "cc_phone" field.
  42228. func (m *WhatsappMutation) ResetCcPhone() {
  42229. m.cc_phone = nil
  42230. }
  42231. // SetPhoneName sets the "phone_name" field.
  42232. func (m *WhatsappMutation) SetPhoneName(s string) {
  42233. m.phone_name = &s
  42234. }
  42235. // PhoneName returns the value of the "phone_name" field in the mutation.
  42236. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42237. v := m.phone_name
  42238. if v == nil {
  42239. return
  42240. }
  42241. return *v, true
  42242. }
  42243. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42244. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42246. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42247. if !m.op.Is(OpUpdateOne) {
  42248. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42249. }
  42250. if m.id == nil || m.oldValue == nil {
  42251. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42252. }
  42253. oldValue, err := m.oldValue(ctx)
  42254. if err != nil {
  42255. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42256. }
  42257. return oldValue.PhoneName, nil
  42258. }
  42259. // ResetPhoneName resets all changes to the "phone_name" field.
  42260. func (m *WhatsappMutation) ResetPhoneName() {
  42261. m.phone_name = nil
  42262. }
  42263. // SetPhoneStatus sets the "phone_status" field.
  42264. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42265. m.phone_status = &i
  42266. m.addphone_status = nil
  42267. }
  42268. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42269. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42270. v := m.phone_status
  42271. if v == nil {
  42272. return
  42273. }
  42274. return *v, true
  42275. }
  42276. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42277. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42279. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42280. if !m.op.Is(OpUpdateOne) {
  42281. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42282. }
  42283. if m.id == nil || m.oldValue == nil {
  42284. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42285. }
  42286. oldValue, err := m.oldValue(ctx)
  42287. if err != nil {
  42288. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42289. }
  42290. return oldValue.PhoneStatus, nil
  42291. }
  42292. // AddPhoneStatus adds i to the "phone_status" field.
  42293. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42294. if m.addphone_status != nil {
  42295. *m.addphone_status += i
  42296. } else {
  42297. m.addphone_status = &i
  42298. }
  42299. }
  42300. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42301. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42302. v := m.addphone_status
  42303. if v == nil {
  42304. return
  42305. }
  42306. return *v, true
  42307. }
  42308. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42309. func (m *WhatsappMutation) ResetPhoneStatus() {
  42310. m.phone_status = nil
  42311. m.addphone_status = nil
  42312. }
  42313. // SetOrganizationID sets the "organization_id" field.
  42314. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42315. m.organization_id = &u
  42316. m.addorganization_id = nil
  42317. }
  42318. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42319. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42320. v := m.organization_id
  42321. if v == nil {
  42322. return
  42323. }
  42324. return *v, true
  42325. }
  42326. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42327. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42329. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42330. if !m.op.Is(OpUpdateOne) {
  42331. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42332. }
  42333. if m.id == nil || m.oldValue == nil {
  42334. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42335. }
  42336. oldValue, err := m.oldValue(ctx)
  42337. if err != nil {
  42338. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42339. }
  42340. return oldValue.OrganizationID, nil
  42341. }
  42342. // AddOrganizationID adds u to the "organization_id" field.
  42343. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42344. if m.addorganization_id != nil {
  42345. *m.addorganization_id += u
  42346. } else {
  42347. m.addorganization_id = &u
  42348. }
  42349. }
  42350. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42351. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42352. v := m.addorganization_id
  42353. if v == nil {
  42354. return
  42355. }
  42356. return *v, true
  42357. }
  42358. // ClearOrganizationID clears the value of the "organization_id" field.
  42359. func (m *WhatsappMutation) ClearOrganizationID() {
  42360. m.organization_id = nil
  42361. m.addorganization_id = nil
  42362. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42363. }
  42364. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42365. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42366. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42367. return ok
  42368. }
  42369. // ResetOrganizationID resets all changes to the "organization_id" field.
  42370. func (m *WhatsappMutation) ResetOrganizationID() {
  42371. m.organization_id = nil
  42372. m.addorganization_id = nil
  42373. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42374. }
  42375. // SetAPIBase sets the "api_base" field.
  42376. func (m *WhatsappMutation) SetAPIBase(s string) {
  42377. m.api_base = &s
  42378. }
  42379. // APIBase returns the value of the "api_base" field in the mutation.
  42380. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42381. v := m.api_base
  42382. if v == nil {
  42383. return
  42384. }
  42385. return *v, true
  42386. }
  42387. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42388. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42390. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42391. if !m.op.Is(OpUpdateOne) {
  42392. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42393. }
  42394. if m.id == nil || m.oldValue == nil {
  42395. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42396. }
  42397. oldValue, err := m.oldValue(ctx)
  42398. if err != nil {
  42399. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42400. }
  42401. return oldValue.APIBase, nil
  42402. }
  42403. // ClearAPIBase clears the value of the "api_base" field.
  42404. func (m *WhatsappMutation) ClearAPIBase() {
  42405. m.api_base = nil
  42406. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42407. }
  42408. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42409. func (m *WhatsappMutation) APIBaseCleared() bool {
  42410. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42411. return ok
  42412. }
  42413. // ResetAPIBase resets all changes to the "api_base" field.
  42414. func (m *WhatsappMutation) ResetAPIBase() {
  42415. m.api_base = nil
  42416. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42417. }
  42418. // SetAPIKey sets the "api_key" field.
  42419. func (m *WhatsappMutation) SetAPIKey(s string) {
  42420. m.api_key = &s
  42421. }
  42422. // APIKey returns the value of the "api_key" field in the mutation.
  42423. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42424. v := m.api_key
  42425. if v == nil {
  42426. return
  42427. }
  42428. return *v, true
  42429. }
  42430. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42431. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42433. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42434. if !m.op.Is(OpUpdateOne) {
  42435. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42436. }
  42437. if m.id == nil || m.oldValue == nil {
  42438. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42439. }
  42440. oldValue, err := m.oldValue(ctx)
  42441. if err != nil {
  42442. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42443. }
  42444. return oldValue.APIKey, nil
  42445. }
  42446. // ClearAPIKey clears the value of the "api_key" field.
  42447. func (m *WhatsappMutation) ClearAPIKey() {
  42448. m.api_key = nil
  42449. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42450. }
  42451. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42452. func (m *WhatsappMutation) APIKeyCleared() bool {
  42453. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42454. return ok
  42455. }
  42456. // ResetAPIKey resets all changes to the "api_key" field.
  42457. func (m *WhatsappMutation) ResetAPIKey() {
  42458. m.api_key = nil
  42459. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42460. }
  42461. // SetAllowList sets the "allow_list" field.
  42462. func (m *WhatsappMutation) SetAllowList(s []string) {
  42463. m.allow_list = &s
  42464. m.appendallow_list = nil
  42465. }
  42466. // AllowList returns the value of the "allow_list" field in the mutation.
  42467. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42468. v := m.allow_list
  42469. if v == nil {
  42470. return
  42471. }
  42472. return *v, true
  42473. }
  42474. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42475. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42477. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42478. if !m.op.Is(OpUpdateOne) {
  42479. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42480. }
  42481. if m.id == nil || m.oldValue == nil {
  42482. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42483. }
  42484. oldValue, err := m.oldValue(ctx)
  42485. if err != nil {
  42486. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42487. }
  42488. return oldValue.AllowList, nil
  42489. }
  42490. // AppendAllowList adds s to the "allow_list" field.
  42491. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42492. m.appendallow_list = append(m.appendallow_list, s...)
  42493. }
  42494. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42495. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42496. if len(m.appendallow_list) == 0 {
  42497. return nil, false
  42498. }
  42499. return m.appendallow_list, true
  42500. }
  42501. // ClearAllowList clears the value of the "allow_list" field.
  42502. func (m *WhatsappMutation) ClearAllowList() {
  42503. m.allow_list = nil
  42504. m.appendallow_list = nil
  42505. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42506. }
  42507. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42508. func (m *WhatsappMutation) AllowListCleared() bool {
  42509. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42510. return ok
  42511. }
  42512. // ResetAllowList resets all changes to the "allow_list" field.
  42513. func (m *WhatsappMutation) ResetAllowList() {
  42514. m.allow_list = nil
  42515. m.appendallow_list = nil
  42516. delete(m.clearedFields, whatsapp.FieldAllowList)
  42517. }
  42518. // SetGroupAllowList sets the "group_allow_list" field.
  42519. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42520. m.group_allow_list = &s
  42521. m.appendgroup_allow_list = nil
  42522. }
  42523. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42524. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42525. v := m.group_allow_list
  42526. if v == nil {
  42527. return
  42528. }
  42529. return *v, true
  42530. }
  42531. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42532. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42534. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42535. if !m.op.Is(OpUpdateOne) {
  42536. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42537. }
  42538. if m.id == nil || m.oldValue == nil {
  42539. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42540. }
  42541. oldValue, err := m.oldValue(ctx)
  42542. if err != nil {
  42543. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42544. }
  42545. return oldValue.GroupAllowList, nil
  42546. }
  42547. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42548. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42549. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42550. }
  42551. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42552. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42553. if len(m.appendgroup_allow_list) == 0 {
  42554. return nil, false
  42555. }
  42556. return m.appendgroup_allow_list, true
  42557. }
  42558. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42559. func (m *WhatsappMutation) ClearGroupAllowList() {
  42560. m.group_allow_list = nil
  42561. m.appendgroup_allow_list = nil
  42562. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42563. }
  42564. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42565. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42566. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42567. return ok
  42568. }
  42569. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42570. func (m *WhatsappMutation) ResetGroupAllowList() {
  42571. m.group_allow_list = nil
  42572. m.appendgroup_allow_list = nil
  42573. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42574. }
  42575. // SetBlockList sets the "block_list" field.
  42576. func (m *WhatsappMutation) SetBlockList(s []string) {
  42577. m.block_list = &s
  42578. m.appendblock_list = nil
  42579. }
  42580. // BlockList returns the value of the "block_list" field in the mutation.
  42581. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42582. v := m.block_list
  42583. if v == nil {
  42584. return
  42585. }
  42586. return *v, true
  42587. }
  42588. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42589. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42591. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42592. if !m.op.Is(OpUpdateOne) {
  42593. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42594. }
  42595. if m.id == nil || m.oldValue == nil {
  42596. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42597. }
  42598. oldValue, err := m.oldValue(ctx)
  42599. if err != nil {
  42600. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42601. }
  42602. return oldValue.BlockList, nil
  42603. }
  42604. // AppendBlockList adds s to the "block_list" field.
  42605. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42606. m.appendblock_list = append(m.appendblock_list, s...)
  42607. }
  42608. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42609. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42610. if len(m.appendblock_list) == 0 {
  42611. return nil, false
  42612. }
  42613. return m.appendblock_list, true
  42614. }
  42615. // ClearBlockList clears the value of the "block_list" field.
  42616. func (m *WhatsappMutation) ClearBlockList() {
  42617. m.block_list = nil
  42618. m.appendblock_list = nil
  42619. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42620. }
  42621. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42622. func (m *WhatsappMutation) BlockListCleared() bool {
  42623. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42624. return ok
  42625. }
  42626. // ResetBlockList resets all changes to the "block_list" field.
  42627. func (m *WhatsappMutation) ResetBlockList() {
  42628. m.block_list = nil
  42629. m.appendblock_list = nil
  42630. delete(m.clearedFields, whatsapp.FieldBlockList)
  42631. }
  42632. // SetGroupBlockList sets the "group_block_list" field.
  42633. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42634. m.group_block_list = &s
  42635. m.appendgroup_block_list = nil
  42636. }
  42637. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42638. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  42639. v := m.group_block_list
  42640. if v == nil {
  42641. return
  42642. }
  42643. return *v, true
  42644. }
  42645. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  42646. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42648. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42649. if !m.op.Is(OpUpdateOne) {
  42650. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42651. }
  42652. if m.id == nil || m.oldValue == nil {
  42653. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42654. }
  42655. oldValue, err := m.oldValue(ctx)
  42656. if err != nil {
  42657. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42658. }
  42659. return oldValue.GroupBlockList, nil
  42660. }
  42661. // AppendGroupBlockList adds s to the "group_block_list" field.
  42662. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  42663. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42664. }
  42665. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42666. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  42667. if len(m.appendgroup_block_list) == 0 {
  42668. return nil, false
  42669. }
  42670. return m.appendgroup_block_list, true
  42671. }
  42672. // ClearGroupBlockList clears the value of the "group_block_list" field.
  42673. func (m *WhatsappMutation) ClearGroupBlockList() {
  42674. m.group_block_list = nil
  42675. m.appendgroup_block_list = nil
  42676. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  42677. }
  42678. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  42679. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  42680. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  42681. return ok
  42682. }
  42683. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42684. func (m *WhatsappMutation) ResetGroupBlockList() {
  42685. m.group_block_list = nil
  42686. m.appendgroup_block_list = nil
  42687. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  42688. }
  42689. // ClearAgent clears the "agent" edge to the Agent entity.
  42690. func (m *WhatsappMutation) ClearAgent() {
  42691. m.clearedagent = true
  42692. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  42693. }
  42694. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42695. func (m *WhatsappMutation) AgentCleared() bool {
  42696. return m.clearedagent
  42697. }
  42698. // AgentIDs returns the "agent" edge IDs in the mutation.
  42699. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42700. // AgentID instead. It exists only for internal usage by the builders.
  42701. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  42702. if id := m.agent; id != nil {
  42703. ids = append(ids, *id)
  42704. }
  42705. return
  42706. }
  42707. // ResetAgent resets all changes to the "agent" edge.
  42708. func (m *WhatsappMutation) ResetAgent() {
  42709. m.agent = nil
  42710. m.clearedagent = false
  42711. }
  42712. // Where appends a list predicates to the WhatsappMutation builder.
  42713. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  42714. m.predicates = append(m.predicates, ps...)
  42715. }
  42716. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  42717. // users can use type-assertion to append predicates that do not depend on any generated package.
  42718. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  42719. p := make([]predicate.Whatsapp, len(ps))
  42720. for i := range ps {
  42721. p[i] = ps[i]
  42722. }
  42723. m.Where(p...)
  42724. }
  42725. // Op returns the operation name.
  42726. func (m *WhatsappMutation) Op() Op {
  42727. return m.op
  42728. }
  42729. // SetOp allows setting the mutation operation.
  42730. func (m *WhatsappMutation) SetOp(op Op) {
  42731. m.op = op
  42732. }
  42733. // Type returns the node type of this mutation (Whatsapp).
  42734. func (m *WhatsappMutation) Type() string {
  42735. return m.typ
  42736. }
  42737. // Fields returns all fields that were changed during this mutation. Note that in
  42738. // order to get all numeric fields that were incremented/decremented, call
  42739. // AddedFields().
  42740. func (m *WhatsappMutation) Fields() []string {
  42741. fields := make([]string, 0, 21)
  42742. if m.created_at != nil {
  42743. fields = append(fields, whatsapp.FieldCreatedAt)
  42744. }
  42745. if m.updated_at != nil {
  42746. fields = append(fields, whatsapp.FieldUpdatedAt)
  42747. }
  42748. if m.status != nil {
  42749. fields = append(fields, whatsapp.FieldStatus)
  42750. }
  42751. if m.deleted_at != nil {
  42752. fields = append(fields, whatsapp.FieldDeletedAt)
  42753. }
  42754. if m.wa_id != nil {
  42755. fields = append(fields, whatsapp.FieldWaID)
  42756. }
  42757. if m.wa_name != nil {
  42758. fields = append(fields, whatsapp.FieldWaName)
  42759. }
  42760. if m.callback != nil {
  42761. fields = append(fields, whatsapp.FieldCallback)
  42762. }
  42763. if m.agent != nil {
  42764. fields = append(fields, whatsapp.FieldAgentID)
  42765. }
  42766. if m.account != nil {
  42767. fields = append(fields, whatsapp.FieldAccount)
  42768. }
  42769. if m.cc != nil {
  42770. fields = append(fields, whatsapp.FieldCc)
  42771. }
  42772. if m.phone != nil {
  42773. fields = append(fields, whatsapp.FieldPhone)
  42774. }
  42775. if m.cc_phone != nil {
  42776. fields = append(fields, whatsapp.FieldCcPhone)
  42777. }
  42778. if m.phone_name != nil {
  42779. fields = append(fields, whatsapp.FieldPhoneName)
  42780. }
  42781. if m.phone_status != nil {
  42782. fields = append(fields, whatsapp.FieldPhoneStatus)
  42783. }
  42784. if m.organization_id != nil {
  42785. fields = append(fields, whatsapp.FieldOrganizationID)
  42786. }
  42787. if m.api_base != nil {
  42788. fields = append(fields, whatsapp.FieldAPIBase)
  42789. }
  42790. if m.api_key != nil {
  42791. fields = append(fields, whatsapp.FieldAPIKey)
  42792. }
  42793. if m.allow_list != nil {
  42794. fields = append(fields, whatsapp.FieldAllowList)
  42795. }
  42796. if m.group_allow_list != nil {
  42797. fields = append(fields, whatsapp.FieldGroupAllowList)
  42798. }
  42799. if m.block_list != nil {
  42800. fields = append(fields, whatsapp.FieldBlockList)
  42801. }
  42802. if m.group_block_list != nil {
  42803. fields = append(fields, whatsapp.FieldGroupBlockList)
  42804. }
  42805. return fields
  42806. }
  42807. // Field returns the value of a field with the given name. The second boolean
  42808. // return value indicates that this field was not set, or was not defined in the
  42809. // schema.
  42810. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  42811. switch name {
  42812. case whatsapp.FieldCreatedAt:
  42813. return m.CreatedAt()
  42814. case whatsapp.FieldUpdatedAt:
  42815. return m.UpdatedAt()
  42816. case whatsapp.FieldStatus:
  42817. return m.Status()
  42818. case whatsapp.FieldDeletedAt:
  42819. return m.DeletedAt()
  42820. case whatsapp.FieldWaID:
  42821. return m.WaID()
  42822. case whatsapp.FieldWaName:
  42823. return m.WaName()
  42824. case whatsapp.FieldCallback:
  42825. return m.Callback()
  42826. case whatsapp.FieldAgentID:
  42827. return m.AgentID()
  42828. case whatsapp.FieldAccount:
  42829. return m.Account()
  42830. case whatsapp.FieldCc:
  42831. return m.Cc()
  42832. case whatsapp.FieldPhone:
  42833. return m.Phone()
  42834. case whatsapp.FieldCcPhone:
  42835. return m.CcPhone()
  42836. case whatsapp.FieldPhoneName:
  42837. return m.PhoneName()
  42838. case whatsapp.FieldPhoneStatus:
  42839. return m.PhoneStatus()
  42840. case whatsapp.FieldOrganizationID:
  42841. return m.OrganizationID()
  42842. case whatsapp.FieldAPIBase:
  42843. return m.APIBase()
  42844. case whatsapp.FieldAPIKey:
  42845. return m.APIKey()
  42846. case whatsapp.FieldAllowList:
  42847. return m.AllowList()
  42848. case whatsapp.FieldGroupAllowList:
  42849. return m.GroupAllowList()
  42850. case whatsapp.FieldBlockList:
  42851. return m.BlockList()
  42852. case whatsapp.FieldGroupBlockList:
  42853. return m.GroupBlockList()
  42854. }
  42855. return nil, false
  42856. }
  42857. // OldField returns the old value of the field from the database. An error is
  42858. // returned if the mutation operation is not UpdateOne, or the query to the
  42859. // database failed.
  42860. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42861. switch name {
  42862. case whatsapp.FieldCreatedAt:
  42863. return m.OldCreatedAt(ctx)
  42864. case whatsapp.FieldUpdatedAt:
  42865. return m.OldUpdatedAt(ctx)
  42866. case whatsapp.FieldStatus:
  42867. return m.OldStatus(ctx)
  42868. case whatsapp.FieldDeletedAt:
  42869. return m.OldDeletedAt(ctx)
  42870. case whatsapp.FieldWaID:
  42871. return m.OldWaID(ctx)
  42872. case whatsapp.FieldWaName:
  42873. return m.OldWaName(ctx)
  42874. case whatsapp.FieldCallback:
  42875. return m.OldCallback(ctx)
  42876. case whatsapp.FieldAgentID:
  42877. return m.OldAgentID(ctx)
  42878. case whatsapp.FieldAccount:
  42879. return m.OldAccount(ctx)
  42880. case whatsapp.FieldCc:
  42881. return m.OldCc(ctx)
  42882. case whatsapp.FieldPhone:
  42883. return m.OldPhone(ctx)
  42884. case whatsapp.FieldCcPhone:
  42885. return m.OldCcPhone(ctx)
  42886. case whatsapp.FieldPhoneName:
  42887. return m.OldPhoneName(ctx)
  42888. case whatsapp.FieldPhoneStatus:
  42889. return m.OldPhoneStatus(ctx)
  42890. case whatsapp.FieldOrganizationID:
  42891. return m.OldOrganizationID(ctx)
  42892. case whatsapp.FieldAPIBase:
  42893. return m.OldAPIBase(ctx)
  42894. case whatsapp.FieldAPIKey:
  42895. return m.OldAPIKey(ctx)
  42896. case whatsapp.FieldAllowList:
  42897. return m.OldAllowList(ctx)
  42898. case whatsapp.FieldGroupAllowList:
  42899. return m.OldGroupAllowList(ctx)
  42900. case whatsapp.FieldBlockList:
  42901. return m.OldBlockList(ctx)
  42902. case whatsapp.FieldGroupBlockList:
  42903. return m.OldGroupBlockList(ctx)
  42904. }
  42905. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  42906. }
  42907. // SetField sets the value of a field with the given name. It returns an error if
  42908. // the field is not defined in the schema, or if the type mismatched the field
  42909. // type.
  42910. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  42911. switch name {
  42912. case whatsapp.FieldCreatedAt:
  42913. v, ok := value.(time.Time)
  42914. if !ok {
  42915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42916. }
  42917. m.SetCreatedAt(v)
  42918. return nil
  42919. case whatsapp.FieldUpdatedAt:
  42920. v, ok := value.(time.Time)
  42921. if !ok {
  42922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42923. }
  42924. m.SetUpdatedAt(v)
  42925. return nil
  42926. case whatsapp.FieldStatus:
  42927. v, ok := value.(uint8)
  42928. if !ok {
  42929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42930. }
  42931. m.SetStatus(v)
  42932. return nil
  42933. case whatsapp.FieldDeletedAt:
  42934. v, ok := value.(time.Time)
  42935. if !ok {
  42936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42937. }
  42938. m.SetDeletedAt(v)
  42939. return nil
  42940. case whatsapp.FieldWaID:
  42941. v, ok := value.(string)
  42942. if !ok {
  42943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42944. }
  42945. m.SetWaID(v)
  42946. return nil
  42947. case whatsapp.FieldWaName:
  42948. v, ok := value.(string)
  42949. if !ok {
  42950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42951. }
  42952. m.SetWaName(v)
  42953. return nil
  42954. case whatsapp.FieldCallback:
  42955. v, ok := value.(string)
  42956. if !ok {
  42957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42958. }
  42959. m.SetCallback(v)
  42960. return nil
  42961. case whatsapp.FieldAgentID:
  42962. v, ok := value.(uint64)
  42963. if !ok {
  42964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42965. }
  42966. m.SetAgentID(v)
  42967. return nil
  42968. case whatsapp.FieldAccount:
  42969. v, ok := value.(string)
  42970. if !ok {
  42971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42972. }
  42973. m.SetAccount(v)
  42974. return nil
  42975. case whatsapp.FieldCc:
  42976. v, ok := value.(string)
  42977. if !ok {
  42978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42979. }
  42980. m.SetCc(v)
  42981. return nil
  42982. case whatsapp.FieldPhone:
  42983. v, ok := value.(string)
  42984. if !ok {
  42985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42986. }
  42987. m.SetPhone(v)
  42988. return nil
  42989. case whatsapp.FieldCcPhone:
  42990. v, ok := value.(string)
  42991. if !ok {
  42992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42993. }
  42994. m.SetCcPhone(v)
  42995. return nil
  42996. case whatsapp.FieldPhoneName:
  42997. v, ok := value.(string)
  42998. if !ok {
  42999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43000. }
  43001. m.SetPhoneName(v)
  43002. return nil
  43003. case whatsapp.FieldPhoneStatus:
  43004. v, ok := value.(int8)
  43005. if !ok {
  43006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43007. }
  43008. m.SetPhoneStatus(v)
  43009. return nil
  43010. case whatsapp.FieldOrganizationID:
  43011. v, ok := value.(uint64)
  43012. if !ok {
  43013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43014. }
  43015. m.SetOrganizationID(v)
  43016. return nil
  43017. case whatsapp.FieldAPIBase:
  43018. v, ok := value.(string)
  43019. if !ok {
  43020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43021. }
  43022. m.SetAPIBase(v)
  43023. return nil
  43024. case whatsapp.FieldAPIKey:
  43025. v, ok := value.(string)
  43026. if !ok {
  43027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43028. }
  43029. m.SetAPIKey(v)
  43030. return nil
  43031. case whatsapp.FieldAllowList:
  43032. v, ok := value.([]string)
  43033. if !ok {
  43034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43035. }
  43036. m.SetAllowList(v)
  43037. return nil
  43038. case whatsapp.FieldGroupAllowList:
  43039. v, ok := value.([]string)
  43040. if !ok {
  43041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43042. }
  43043. m.SetGroupAllowList(v)
  43044. return nil
  43045. case whatsapp.FieldBlockList:
  43046. v, ok := value.([]string)
  43047. if !ok {
  43048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43049. }
  43050. m.SetBlockList(v)
  43051. return nil
  43052. case whatsapp.FieldGroupBlockList:
  43053. v, ok := value.([]string)
  43054. if !ok {
  43055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43056. }
  43057. m.SetGroupBlockList(v)
  43058. return nil
  43059. }
  43060. return fmt.Errorf("unknown Whatsapp field %s", name)
  43061. }
  43062. // AddedFields returns all numeric fields that were incremented/decremented during
  43063. // this mutation.
  43064. func (m *WhatsappMutation) AddedFields() []string {
  43065. var fields []string
  43066. if m.addstatus != nil {
  43067. fields = append(fields, whatsapp.FieldStatus)
  43068. }
  43069. if m.addphone_status != nil {
  43070. fields = append(fields, whatsapp.FieldPhoneStatus)
  43071. }
  43072. if m.addorganization_id != nil {
  43073. fields = append(fields, whatsapp.FieldOrganizationID)
  43074. }
  43075. return fields
  43076. }
  43077. // AddedField returns the numeric value that was incremented/decremented on a field
  43078. // with the given name. The second boolean return value indicates that this field
  43079. // was not set, or was not defined in the schema.
  43080. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43081. switch name {
  43082. case whatsapp.FieldStatus:
  43083. return m.AddedStatus()
  43084. case whatsapp.FieldPhoneStatus:
  43085. return m.AddedPhoneStatus()
  43086. case whatsapp.FieldOrganizationID:
  43087. return m.AddedOrganizationID()
  43088. }
  43089. return nil, false
  43090. }
  43091. // AddField adds the value to the field with the given name. It returns an error if
  43092. // the field is not defined in the schema, or if the type mismatched the field
  43093. // type.
  43094. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43095. switch name {
  43096. case whatsapp.FieldStatus:
  43097. v, ok := value.(int8)
  43098. if !ok {
  43099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43100. }
  43101. m.AddStatus(v)
  43102. return nil
  43103. case whatsapp.FieldPhoneStatus:
  43104. v, ok := value.(int8)
  43105. if !ok {
  43106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43107. }
  43108. m.AddPhoneStatus(v)
  43109. return nil
  43110. case whatsapp.FieldOrganizationID:
  43111. v, ok := value.(int64)
  43112. if !ok {
  43113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43114. }
  43115. m.AddOrganizationID(v)
  43116. return nil
  43117. }
  43118. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43119. }
  43120. // ClearedFields returns all nullable fields that were cleared during this
  43121. // mutation.
  43122. func (m *WhatsappMutation) ClearedFields() []string {
  43123. var fields []string
  43124. if m.FieldCleared(whatsapp.FieldStatus) {
  43125. fields = append(fields, whatsapp.FieldStatus)
  43126. }
  43127. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43128. fields = append(fields, whatsapp.FieldDeletedAt)
  43129. }
  43130. if m.FieldCleared(whatsapp.FieldWaID) {
  43131. fields = append(fields, whatsapp.FieldWaID)
  43132. }
  43133. if m.FieldCleared(whatsapp.FieldWaName) {
  43134. fields = append(fields, whatsapp.FieldWaName)
  43135. }
  43136. if m.FieldCleared(whatsapp.FieldCallback) {
  43137. fields = append(fields, whatsapp.FieldCallback)
  43138. }
  43139. if m.FieldCleared(whatsapp.FieldAccount) {
  43140. fields = append(fields, whatsapp.FieldAccount)
  43141. }
  43142. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43143. fields = append(fields, whatsapp.FieldOrganizationID)
  43144. }
  43145. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43146. fields = append(fields, whatsapp.FieldAPIBase)
  43147. }
  43148. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43149. fields = append(fields, whatsapp.FieldAPIKey)
  43150. }
  43151. if m.FieldCleared(whatsapp.FieldAllowList) {
  43152. fields = append(fields, whatsapp.FieldAllowList)
  43153. }
  43154. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43155. fields = append(fields, whatsapp.FieldGroupAllowList)
  43156. }
  43157. if m.FieldCleared(whatsapp.FieldBlockList) {
  43158. fields = append(fields, whatsapp.FieldBlockList)
  43159. }
  43160. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43161. fields = append(fields, whatsapp.FieldGroupBlockList)
  43162. }
  43163. return fields
  43164. }
  43165. // FieldCleared returns a boolean indicating if a field with the given name was
  43166. // cleared in this mutation.
  43167. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43168. _, ok := m.clearedFields[name]
  43169. return ok
  43170. }
  43171. // ClearField clears the value of the field with the given name. It returns an
  43172. // error if the field is not defined in the schema.
  43173. func (m *WhatsappMutation) ClearField(name string) error {
  43174. switch name {
  43175. case whatsapp.FieldStatus:
  43176. m.ClearStatus()
  43177. return nil
  43178. case whatsapp.FieldDeletedAt:
  43179. m.ClearDeletedAt()
  43180. return nil
  43181. case whatsapp.FieldWaID:
  43182. m.ClearWaID()
  43183. return nil
  43184. case whatsapp.FieldWaName:
  43185. m.ClearWaName()
  43186. return nil
  43187. case whatsapp.FieldCallback:
  43188. m.ClearCallback()
  43189. return nil
  43190. case whatsapp.FieldAccount:
  43191. m.ClearAccount()
  43192. return nil
  43193. case whatsapp.FieldOrganizationID:
  43194. m.ClearOrganizationID()
  43195. return nil
  43196. case whatsapp.FieldAPIBase:
  43197. m.ClearAPIBase()
  43198. return nil
  43199. case whatsapp.FieldAPIKey:
  43200. m.ClearAPIKey()
  43201. return nil
  43202. case whatsapp.FieldAllowList:
  43203. m.ClearAllowList()
  43204. return nil
  43205. case whatsapp.FieldGroupAllowList:
  43206. m.ClearGroupAllowList()
  43207. return nil
  43208. case whatsapp.FieldBlockList:
  43209. m.ClearBlockList()
  43210. return nil
  43211. case whatsapp.FieldGroupBlockList:
  43212. m.ClearGroupBlockList()
  43213. return nil
  43214. }
  43215. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43216. }
  43217. // ResetField resets all changes in the mutation for the field with the given name.
  43218. // It returns an error if the field is not defined in the schema.
  43219. func (m *WhatsappMutation) ResetField(name string) error {
  43220. switch name {
  43221. case whatsapp.FieldCreatedAt:
  43222. m.ResetCreatedAt()
  43223. return nil
  43224. case whatsapp.FieldUpdatedAt:
  43225. m.ResetUpdatedAt()
  43226. return nil
  43227. case whatsapp.FieldStatus:
  43228. m.ResetStatus()
  43229. return nil
  43230. case whatsapp.FieldDeletedAt:
  43231. m.ResetDeletedAt()
  43232. return nil
  43233. case whatsapp.FieldWaID:
  43234. m.ResetWaID()
  43235. return nil
  43236. case whatsapp.FieldWaName:
  43237. m.ResetWaName()
  43238. return nil
  43239. case whatsapp.FieldCallback:
  43240. m.ResetCallback()
  43241. return nil
  43242. case whatsapp.FieldAgentID:
  43243. m.ResetAgentID()
  43244. return nil
  43245. case whatsapp.FieldAccount:
  43246. m.ResetAccount()
  43247. return nil
  43248. case whatsapp.FieldCc:
  43249. m.ResetCc()
  43250. return nil
  43251. case whatsapp.FieldPhone:
  43252. m.ResetPhone()
  43253. return nil
  43254. case whatsapp.FieldCcPhone:
  43255. m.ResetCcPhone()
  43256. return nil
  43257. case whatsapp.FieldPhoneName:
  43258. m.ResetPhoneName()
  43259. return nil
  43260. case whatsapp.FieldPhoneStatus:
  43261. m.ResetPhoneStatus()
  43262. return nil
  43263. case whatsapp.FieldOrganizationID:
  43264. m.ResetOrganizationID()
  43265. return nil
  43266. case whatsapp.FieldAPIBase:
  43267. m.ResetAPIBase()
  43268. return nil
  43269. case whatsapp.FieldAPIKey:
  43270. m.ResetAPIKey()
  43271. return nil
  43272. case whatsapp.FieldAllowList:
  43273. m.ResetAllowList()
  43274. return nil
  43275. case whatsapp.FieldGroupAllowList:
  43276. m.ResetGroupAllowList()
  43277. return nil
  43278. case whatsapp.FieldBlockList:
  43279. m.ResetBlockList()
  43280. return nil
  43281. case whatsapp.FieldGroupBlockList:
  43282. m.ResetGroupBlockList()
  43283. return nil
  43284. }
  43285. return fmt.Errorf("unknown Whatsapp field %s", name)
  43286. }
  43287. // AddedEdges returns all edge names that were set/added in this mutation.
  43288. func (m *WhatsappMutation) AddedEdges() []string {
  43289. edges := make([]string, 0, 1)
  43290. if m.agent != nil {
  43291. edges = append(edges, whatsapp.EdgeAgent)
  43292. }
  43293. return edges
  43294. }
  43295. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43296. // name in this mutation.
  43297. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43298. switch name {
  43299. case whatsapp.EdgeAgent:
  43300. if id := m.agent; id != nil {
  43301. return []ent.Value{*id}
  43302. }
  43303. }
  43304. return nil
  43305. }
  43306. // RemovedEdges returns all edge names that were removed in this mutation.
  43307. func (m *WhatsappMutation) RemovedEdges() []string {
  43308. edges := make([]string, 0, 1)
  43309. return edges
  43310. }
  43311. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43312. // the given name in this mutation.
  43313. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43314. return nil
  43315. }
  43316. // ClearedEdges returns all edge names that were cleared in this mutation.
  43317. func (m *WhatsappMutation) ClearedEdges() []string {
  43318. edges := make([]string, 0, 1)
  43319. if m.clearedagent {
  43320. edges = append(edges, whatsapp.EdgeAgent)
  43321. }
  43322. return edges
  43323. }
  43324. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43325. // was cleared in this mutation.
  43326. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43327. switch name {
  43328. case whatsapp.EdgeAgent:
  43329. return m.clearedagent
  43330. }
  43331. return false
  43332. }
  43333. // ClearEdge clears the value of the edge with the given name. It returns an error
  43334. // if that edge is not defined in the schema.
  43335. func (m *WhatsappMutation) ClearEdge(name string) error {
  43336. switch name {
  43337. case whatsapp.EdgeAgent:
  43338. m.ClearAgent()
  43339. return nil
  43340. }
  43341. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43342. }
  43343. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43344. // It returns an error if the edge is not defined in the schema.
  43345. func (m *WhatsappMutation) ResetEdge(name string) error {
  43346. switch name {
  43347. case whatsapp.EdgeAgent:
  43348. m.ResetAgent()
  43349. return nil
  43350. }
  43351. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43352. }
  43353. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43354. type WhatsappChannelMutation struct {
  43355. config
  43356. op Op
  43357. typ string
  43358. id *uint64
  43359. created_at *time.Time
  43360. updated_at *time.Time
  43361. status *uint8
  43362. addstatus *int8
  43363. deleted_at *time.Time
  43364. ak *string
  43365. sk *string
  43366. wa_id *string
  43367. wa_name *string
  43368. waba_id *uint64
  43369. addwaba_id *int64
  43370. business_id *uint64
  43371. addbusiness_id *int64
  43372. organization_id *uint64
  43373. addorganization_id *int64
  43374. verify_account *string
  43375. clearedFields map[string]struct{}
  43376. done bool
  43377. oldValue func(context.Context) (*WhatsappChannel, error)
  43378. predicates []predicate.WhatsappChannel
  43379. }
  43380. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43381. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43382. type whatsappchannelOption func(*WhatsappChannelMutation)
  43383. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43384. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43385. m := &WhatsappChannelMutation{
  43386. config: c,
  43387. op: op,
  43388. typ: TypeWhatsappChannel,
  43389. clearedFields: make(map[string]struct{}),
  43390. }
  43391. for _, opt := range opts {
  43392. opt(m)
  43393. }
  43394. return m
  43395. }
  43396. // withWhatsappChannelID sets the ID field of the mutation.
  43397. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43398. return func(m *WhatsappChannelMutation) {
  43399. var (
  43400. err error
  43401. once sync.Once
  43402. value *WhatsappChannel
  43403. )
  43404. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43405. once.Do(func() {
  43406. if m.done {
  43407. err = errors.New("querying old values post mutation is not allowed")
  43408. } else {
  43409. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43410. }
  43411. })
  43412. return value, err
  43413. }
  43414. m.id = &id
  43415. }
  43416. }
  43417. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43418. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43419. return func(m *WhatsappChannelMutation) {
  43420. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43421. return node, nil
  43422. }
  43423. m.id = &node.ID
  43424. }
  43425. }
  43426. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43427. // executed in a transaction (ent.Tx), a transactional client is returned.
  43428. func (m WhatsappChannelMutation) Client() *Client {
  43429. client := &Client{config: m.config}
  43430. client.init()
  43431. return client
  43432. }
  43433. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43434. // it returns an error otherwise.
  43435. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43436. if _, ok := m.driver.(*txDriver); !ok {
  43437. return nil, errors.New("ent: mutation is not running in a transaction")
  43438. }
  43439. tx := &Tx{config: m.config}
  43440. tx.init()
  43441. return tx, nil
  43442. }
  43443. // SetID sets the value of the id field. Note that this
  43444. // operation is only accepted on creation of WhatsappChannel entities.
  43445. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43446. m.id = &id
  43447. }
  43448. // ID returns the ID value in the mutation. Note that the ID is only available
  43449. // if it was provided to the builder or after it was returned from the database.
  43450. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43451. if m.id == nil {
  43452. return
  43453. }
  43454. return *m.id, true
  43455. }
  43456. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43457. // That means, if the mutation is applied within a transaction with an isolation level such
  43458. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43459. // or updated by the mutation.
  43460. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43461. switch {
  43462. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43463. id, exists := m.ID()
  43464. if exists {
  43465. return []uint64{id}, nil
  43466. }
  43467. fallthrough
  43468. case m.op.Is(OpUpdate | OpDelete):
  43469. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43470. default:
  43471. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43472. }
  43473. }
  43474. // SetCreatedAt sets the "created_at" field.
  43475. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43476. m.created_at = &t
  43477. }
  43478. // CreatedAt returns the value of the "created_at" field in the mutation.
  43479. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43480. v := m.created_at
  43481. if v == nil {
  43482. return
  43483. }
  43484. return *v, true
  43485. }
  43486. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43487. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43489. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43490. if !m.op.Is(OpUpdateOne) {
  43491. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43492. }
  43493. if m.id == nil || m.oldValue == nil {
  43494. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43495. }
  43496. oldValue, err := m.oldValue(ctx)
  43497. if err != nil {
  43498. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43499. }
  43500. return oldValue.CreatedAt, nil
  43501. }
  43502. // ResetCreatedAt resets all changes to the "created_at" field.
  43503. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43504. m.created_at = nil
  43505. }
  43506. // SetUpdatedAt sets the "updated_at" field.
  43507. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43508. m.updated_at = &t
  43509. }
  43510. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43511. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43512. v := m.updated_at
  43513. if v == nil {
  43514. return
  43515. }
  43516. return *v, true
  43517. }
  43518. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43519. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43521. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43522. if !m.op.Is(OpUpdateOne) {
  43523. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43524. }
  43525. if m.id == nil || m.oldValue == nil {
  43526. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43527. }
  43528. oldValue, err := m.oldValue(ctx)
  43529. if err != nil {
  43530. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43531. }
  43532. return oldValue.UpdatedAt, nil
  43533. }
  43534. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43535. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43536. m.updated_at = nil
  43537. }
  43538. // SetStatus sets the "status" field.
  43539. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43540. m.status = &u
  43541. m.addstatus = nil
  43542. }
  43543. // Status returns the value of the "status" field in the mutation.
  43544. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43545. v := m.status
  43546. if v == nil {
  43547. return
  43548. }
  43549. return *v, true
  43550. }
  43551. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43552. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43554. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43555. if !m.op.Is(OpUpdateOne) {
  43556. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43557. }
  43558. if m.id == nil || m.oldValue == nil {
  43559. return v, errors.New("OldStatus requires an ID field in the mutation")
  43560. }
  43561. oldValue, err := m.oldValue(ctx)
  43562. if err != nil {
  43563. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43564. }
  43565. return oldValue.Status, nil
  43566. }
  43567. // AddStatus adds u to the "status" field.
  43568. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43569. if m.addstatus != nil {
  43570. *m.addstatus += u
  43571. } else {
  43572. m.addstatus = &u
  43573. }
  43574. }
  43575. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43576. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43577. v := m.addstatus
  43578. if v == nil {
  43579. return
  43580. }
  43581. return *v, true
  43582. }
  43583. // ClearStatus clears the value of the "status" field.
  43584. func (m *WhatsappChannelMutation) ClearStatus() {
  43585. m.status = nil
  43586. m.addstatus = nil
  43587. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43588. }
  43589. // StatusCleared returns if the "status" field was cleared in this mutation.
  43590. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43591. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43592. return ok
  43593. }
  43594. // ResetStatus resets all changes to the "status" field.
  43595. func (m *WhatsappChannelMutation) ResetStatus() {
  43596. m.status = nil
  43597. m.addstatus = nil
  43598. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43599. }
  43600. // SetDeletedAt sets the "deleted_at" field.
  43601. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43602. m.deleted_at = &t
  43603. }
  43604. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43605. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43606. v := m.deleted_at
  43607. if v == nil {
  43608. return
  43609. }
  43610. return *v, true
  43611. }
  43612. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43613. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43615. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43616. if !m.op.Is(OpUpdateOne) {
  43617. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43618. }
  43619. if m.id == nil || m.oldValue == nil {
  43620. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43621. }
  43622. oldValue, err := m.oldValue(ctx)
  43623. if err != nil {
  43624. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43625. }
  43626. return oldValue.DeletedAt, nil
  43627. }
  43628. // ClearDeletedAt clears the value of the "deleted_at" field.
  43629. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43630. m.deleted_at = nil
  43631. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43632. }
  43633. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43634. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43635. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  43636. return ok
  43637. }
  43638. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43639. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  43640. m.deleted_at = nil
  43641. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  43642. }
  43643. // SetAk sets the "ak" field.
  43644. func (m *WhatsappChannelMutation) SetAk(s string) {
  43645. m.ak = &s
  43646. }
  43647. // Ak returns the value of the "ak" field in the mutation.
  43648. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  43649. v := m.ak
  43650. if v == nil {
  43651. return
  43652. }
  43653. return *v, true
  43654. }
  43655. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  43656. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43658. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  43659. if !m.op.Is(OpUpdateOne) {
  43660. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  43661. }
  43662. if m.id == nil || m.oldValue == nil {
  43663. return v, errors.New("OldAk requires an ID field in the mutation")
  43664. }
  43665. oldValue, err := m.oldValue(ctx)
  43666. if err != nil {
  43667. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  43668. }
  43669. return oldValue.Ak, nil
  43670. }
  43671. // ClearAk clears the value of the "ak" field.
  43672. func (m *WhatsappChannelMutation) ClearAk() {
  43673. m.ak = nil
  43674. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  43675. }
  43676. // AkCleared returns if the "ak" field was cleared in this mutation.
  43677. func (m *WhatsappChannelMutation) AkCleared() bool {
  43678. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  43679. return ok
  43680. }
  43681. // ResetAk resets all changes to the "ak" field.
  43682. func (m *WhatsappChannelMutation) ResetAk() {
  43683. m.ak = nil
  43684. delete(m.clearedFields, whatsappchannel.FieldAk)
  43685. }
  43686. // SetSk sets the "sk" field.
  43687. func (m *WhatsappChannelMutation) SetSk(s string) {
  43688. m.sk = &s
  43689. }
  43690. // Sk returns the value of the "sk" field in the mutation.
  43691. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  43692. v := m.sk
  43693. if v == nil {
  43694. return
  43695. }
  43696. return *v, true
  43697. }
  43698. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  43699. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43701. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  43702. if !m.op.Is(OpUpdateOne) {
  43703. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  43704. }
  43705. if m.id == nil || m.oldValue == nil {
  43706. return v, errors.New("OldSk requires an ID field in the mutation")
  43707. }
  43708. oldValue, err := m.oldValue(ctx)
  43709. if err != nil {
  43710. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  43711. }
  43712. return oldValue.Sk, nil
  43713. }
  43714. // ResetSk resets all changes to the "sk" field.
  43715. func (m *WhatsappChannelMutation) ResetSk() {
  43716. m.sk = nil
  43717. }
  43718. // SetWaID sets the "wa_id" field.
  43719. func (m *WhatsappChannelMutation) SetWaID(s string) {
  43720. m.wa_id = &s
  43721. }
  43722. // WaID returns the value of the "wa_id" field in the mutation.
  43723. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  43724. v := m.wa_id
  43725. if v == nil {
  43726. return
  43727. }
  43728. return *v, true
  43729. }
  43730. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  43731. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43733. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  43734. if !m.op.Is(OpUpdateOne) {
  43735. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  43736. }
  43737. if m.id == nil || m.oldValue == nil {
  43738. return v, errors.New("OldWaID requires an ID field in the mutation")
  43739. }
  43740. oldValue, err := m.oldValue(ctx)
  43741. if err != nil {
  43742. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  43743. }
  43744. return oldValue.WaID, nil
  43745. }
  43746. // ClearWaID clears the value of the "wa_id" field.
  43747. func (m *WhatsappChannelMutation) ClearWaID() {
  43748. m.wa_id = nil
  43749. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  43750. }
  43751. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  43752. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  43753. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  43754. return ok
  43755. }
  43756. // ResetWaID resets all changes to the "wa_id" field.
  43757. func (m *WhatsappChannelMutation) ResetWaID() {
  43758. m.wa_id = nil
  43759. delete(m.clearedFields, whatsappchannel.FieldWaID)
  43760. }
  43761. // SetWaName sets the "wa_name" field.
  43762. func (m *WhatsappChannelMutation) SetWaName(s string) {
  43763. m.wa_name = &s
  43764. }
  43765. // WaName returns the value of the "wa_name" field in the mutation.
  43766. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  43767. v := m.wa_name
  43768. if v == nil {
  43769. return
  43770. }
  43771. return *v, true
  43772. }
  43773. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  43774. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43776. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  43777. if !m.op.Is(OpUpdateOne) {
  43778. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  43779. }
  43780. if m.id == nil || m.oldValue == nil {
  43781. return v, errors.New("OldWaName requires an ID field in the mutation")
  43782. }
  43783. oldValue, err := m.oldValue(ctx)
  43784. if err != nil {
  43785. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  43786. }
  43787. return oldValue.WaName, nil
  43788. }
  43789. // ClearWaName clears the value of the "wa_name" field.
  43790. func (m *WhatsappChannelMutation) ClearWaName() {
  43791. m.wa_name = nil
  43792. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  43793. }
  43794. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  43795. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  43796. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  43797. return ok
  43798. }
  43799. // ResetWaName resets all changes to the "wa_name" field.
  43800. func (m *WhatsappChannelMutation) ResetWaName() {
  43801. m.wa_name = nil
  43802. delete(m.clearedFields, whatsappchannel.FieldWaName)
  43803. }
  43804. // SetWabaID sets the "waba_id" field.
  43805. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  43806. m.waba_id = &u
  43807. m.addwaba_id = nil
  43808. }
  43809. // WabaID returns the value of the "waba_id" field in the mutation.
  43810. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  43811. v := m.waba_id
  43812. if v == nil {
  43813. return
  43814. }
  43815. return *v, true
  43816. }
  43817. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  43818. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43820. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  43821. if !m.op.Is(OpUpdateOne) {
  43822. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  43823. }
  43824. if m.id == nil || m.oldValue == nil {
  43825. return v, errors.New("OldWabaID requires an ID field in the mutation")
  43826. }
  43827. oldValue, err := m.oldValue(ctx)
  43828. if err != nil {
  43829. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  43830. }
  43831. return oldValue.WabaID, nil
  43832. }
  43833. // AddWabaID adds u to the "waba_id" field.
  43834. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  43835. if m.addwaba_id != nil {
  43836. *m.addwaba_id += u
  43837. } else {
  43838. m.addwaba_id = &u
  43839. }
  43840. }
  43841. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  43842. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  43843. v := m.addwaba_id
  43844. if v == nil {
  43845. return
  43846. }
  43847. return *v, true
  43848. }
  43849. // ResetWabaID resets all changes to the "waba_id" field.
  43850. func (m *WhatsappChannelMutation) ResetWabaID() {
  43851. m.waba_id = nil
  43852. m.addwaba_id = nil
  43853. }
  43854. // SetBusinessID sets the "business_id" field.
  43855. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  43856. m.business_id = &u
  43857. m.addbusiness_id = nil
  43858. }
  43859. // BusinessID returns the value of the "business_id" field in the mutation.
  43860. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  43861. v := m.business_id
  43862. if v == nil {
  43863. return
  43864. }
  43865. return *v, true
  43866. }
  43867. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  43868. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43870. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  43871. if !m.op.Is(OpUpdateOne) {
  43872. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  43873. }
  43874. if m.id == nil || m.oldValue == nil {
  43875. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  43876. }
  43877. oldValue, err := m.oldValue(ctx)
  43878. if err != nil {
  43879. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  43880. }
  43881. return oldValue.BusinessID, nil
  43882. }
  43883. // AddBusinessID adds u to the "business_id" field.
  43884. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  43885. if m.addbusiness_id != nil {
  43886. *m.addbusiness_id += u
  43887. } else {
  43888. m.addbusiness_id = &u
  43889. }
  43890. }
  43891. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  43892. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  43893. v := m.addbusiness_id
  43894. if v == nil {
  43895. return
  43896. }
  43897. return *v, true
  43898. }
  43899. // ResetBusinessID resets all changes to the "business_id" field.
  43900. func (m *WhatsappChannelMutation) ResetBusinessID() {
  43901. m.business_id = nil
  43902. m.addbusiness_id = nil
  43903. }
  43904. // SetOrganizationID sets the "organization_id" field.
  43905. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  43906. m.organization_id = &u
  43907. m.addorganization_id = nil
  43908. }
  43909. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43910. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  43911. v := m.organization_id
  43912. if v == nil {
  43913. return
  43914. }
  43915. return *v, true
  43916. }
  43917. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  43918. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43920. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43921. if !m.op.Is(OpUpdateOne) {
  43922. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43923. }
  43924. if m.id == nil || m.oldValue == nil {
  43925. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43926. }
  43927. oldValue, err := m.oldValue(ctx)
  43928. if err != nil {
  43929. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43930. }
  43931. return oldValue.OrganizationID, nil
  43932. }
  43933. // AddOrganizationID adds u to the "organization_id" field.
  43934. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  43935. if m.addorganization_id != nil {
  43936. *m.addorganization_id += u
  43937. } else {
  43938. m.addorganization_id = &u
  43939. }
  43940. }
  43941. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43942. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  43943. v := m.addorganization_id
  43944. if v == nil {
  43945. return
  43946. }
  43947. return *v, true
  43948. }
  43949. // ClearOrganizationID clears the value of the "organization_id" field.
  43950. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  43951. m.organization_id = nil
  43952. m.addorganization_id = nil
  43953. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  43954. }
  43955. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43956. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  43957. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  43958. return ok
  43959. }
  43960. // ResetOrganizationID resets all changes to the "organization_id" field.
  43961. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  43962. m.organization_id = nil
  43963. m.addorganization_id = nil
  43964. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  43965. }
  43966. // SetVerifyAccount sets the "verify_account" field.
  43967. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  43968. m.verify_account = &s
  43969. }
  43970. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  43971. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  43972. v := m.verify_account
  43973. if v == nil {
  43974. return
  43975. }
  43976. return *v, true
  43977. }
  43978. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  43979. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43981. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  43982. if !m.op.Is(OpUpdateOne) {
  43983. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  43984. }
  43985. if m.id == nil || m.oldValue == nil {
  43986. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  43987. }
  43988. oldValue, err := m.oldValue(ctx)
  43989. if err != nil {
  43990. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  43991. }
  43992. return oldValue.VerifyAccount, nil
  43993. }
  43994. // ResetVerifyAccount resets all changes to the "verify_account" field.
  43995. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  43996. m.verify_account = nil
  43997. }
  43998. // Where appends a list predicates to the WhatsappChannelMutation builder.
  43999. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44000. m.predicates = append(m.predicates, ps...)
  44001. }
  44002. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44003. // users can use type-assertion to append predicates that do not depend on any generated package.
  44004. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44005. p := make([]predicate.WhatsappChannel, len(ps))
  44006. for i := range ps {
  44007. p[i] = ps[i]
  44008. }
  44009. m.Where(p...)
  44010. }
  44011. // Op returns the operation name.
  44012. func (m *WhatsappChannelMutation) Op() Op {
  44013. return m.op
  44014. }
  44015. // SetOp allows setting the mutation operation.
  44016. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44017. m.op = op
  44018. }
  44019. // Type returns the node type of this mutation (WhatsappChannel).
  44020. func (m *WhatsappChannelMutation) Type() string {
  44021. return m.typ
  44022. }
  44023. // Fields returns all fields that were changed during this mutation. Note that in
  44024. // order to get all numeric fields that were incremented/decremented, call
  44025. // AddedFields().
  44026. func (m *WhatsappChannelMutation) Fields() []string {
  44027. fields := make([]string, 0, 12)
  44028. if m.created_at != nil {
  44029. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44030. }
  44031. if m.updated_at != nil {
  44032. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44033. }
  44034. if m.status != nil {
  44035. fields = append(fields, whatsappchannel.FieldStatus)
  44036. }
  44037. if m.deleted_at != nil {
  44038. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44039. }
  44040. if m.ak != nil {
  44041. fields = append(fields, whatsappchannel.FieldAk)
  44042. }
  44043. if m.sk != nil {
  44044. fields = append(fields, whatsappchannel.FieldSk)
  44045. }
  44046. if m.wa_id != nil {
  44047. fields = append(fields, whatsappchannel.FieldWaID)
  44048. }
  44049. if m.wa_name != nil {
  44050. fields = append(fields, whatsappchannel.FieldWaName)
  44051. }
  44052. if m.waba_id != nil {
  44053. fields = append(fields, whatsappchannel.FieldWabaID)
  44054. }
  44055. if m.business_id != nil {
  44056. fields = append(fields, whatsappchannel.FieldBusinessID)
  44057. }
  44058. if m.organization_id != nil {
  44059. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44060. }
  44061. if m.verify_account != nil {
  44062. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44063. }
  44064. return fields
  44065. }
  44066. // Field returns the value of a field with the given name. The second boolean
  44067. // return value indicates that this field was not set, or was not defined in the
  44068. // schema.
  44069. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44070. switch name {
  44071. case whatsappchannel.FieldCreatedAt:
  44072. return m.CreatedAt()
  44073. case whatsappchannel.FieldUpdatedAt:
  44074. return m.UpdatedAt()
  44075. case whatsappchannel.FieldStatus:
  44076. return m.Status()
  44077. case whatsappchannel.FieldDeletedAt:
  44078. return m.DeletedAt()
  44079. case whatsappchannel.FieldAk:
  44080. return m.Ak()
  44081. case whatsappchannel.FieldSk:
  44082. return m.Sk()
  44083. case whatsappchannel.FieldWaID:
  44084. return m.WaID()
  44085. case whatsappchannel.FieldWaName:
  44086. return m.WaName()
  44087. case whatsappchannel.FieldWabaID:
  44088. return m.WabaID()
  44089. case whatsappchannel.FieldBusinessID:
  44090. return m.BusinessID()
  44091. case whatsappchannel.FieldOrganizationID:
  44092. return m.OrganizationID()
  44093. case whatsappchannel.FieldVerifyAccount:
  44094. return m.VerifyAccount()
  44095. }
  44096. return nil, false
  44097. }
  44098. // OldField returns the old value of the field from the database. An error is
  44099. // returned if the mutation operation is not UpdateOne, or the query to the
  44100. // database failed.
  44101. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44102. switch name {
  44103. case whatsappchannel.FieldCreatedAt:
  44104. return m.OldCreatedAt(ctx)
  44105. case whatsappchannel.FieldUpdatedAt:
  44106. return m.OldUpdatedAt(ctx)
  44107. case whatsappchannel.FieldStatus:
  44108. return m.OldStatus(ctx)
  44109. case whatsappchannel.FieldDeletedAt:
  44110. return m.OldDeletedAt(ctx)
  44111. case whatsappchannel.FieldAk:
  44112. return m.OldAk(ctx)
  44113. case whatsappchannel.FieldSk:
  44114. return m.OldSk(ctx)
  44115. case whatsappchannel.FieldWaID:
  44116. return m.OldWaID(ctx)
  44117. case whatsappchannel.FieldWaName:
  44118. return m.OldWaName(ctx)
  44119. case whatsappchannel.FieldWabaID:
  44120. return m.OldWabaID(ctx)
  44121. case whatsappchannel.FieldBusinessID:
  44122. return m.OldBusinessID(ctx)
  44123. case whatsappchannel.FieldOrganizationID:
  44124. return m.OldOrganizationID(ctx)
  44125. case whatsappchannel.FieldVerifyAccount:
  44126. return m.OldVerifyAccount(ctx)
  44127. }
  44128. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44129. }
  44130. // SetField sets the value of a field with the given name. It returns an error if
  44131. // the field is not defined in the schema, or if the type mismatched the field
  44132. // type.
  44133. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44134. switch name {
  44135. case whatsappchannel.FieldCreatedAt:
  44136. v, ok := value.(time.Time)
  44137. if !ok {
  44138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44139. }
  44140. m.SetCreatedAt(v)
  44141. return nil
  44142. case whatsappchannel.FieldUpdatedAt:
  44143. v, ok := value.(time.Time)
  44144. if !ok {
  44145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44146. }
  44147. m.SetUpdatedAt(v)
  44148. return nil
  44149. case whatsappchannel.FieldStatus:
  44150. v, ok := value.(uint8)
  44151. if !ok {
  44152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44153. }
  44154. m.SetStatus(v)
  44155. return nil
  44156. case whatsappchannel.FieldDeletedAt:
  44157. v, ok := value.(time.Time)
  44158. if !ok {
  44159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44160. }
  44161. m.SetDeletedAt(v)
  44162. return nil
  44163. case whatsappchannel.FieldAk:
  44164. v, ok := value.(string)
  44165. if !ok {
  44166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44167. }
  44168. m.SetAk(v)
  44169. return nil
  44170. case whatsappchannel.FieldSk:
  44171. v, ok := value.(string)
  44172. if !ok {
  44173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44174. }
  44175. m.SetSk(v)
  44176. return nil
  44177. case whatsappchannel.FieldWaID:
  44178. v, ok := value.(string)
  44179. if !ok {
  44180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44181. }
  44182. m.SetWaID(v)
  44183. return nil
  44184. case whatsappchannel.FieldWaName:
  44185. v, ok := value.(string)
  44186. if !ok {
  44187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44188. }
  44189. m.SetWaName(v)
  44190. return nil
  44191. case whatsappchannel.FieldWabaID:
  44192. v, ok := value.(uint64)
  44193. if !ok {
  44194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44195. }
  44196. m.SetWabaID(v)
  44197. return nil
  44198. case whatsappchannel.FieldBusinessID:
  44199. v, ok := value.(uint64)
  44200. if !ok {
  44201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44202. }
  44203. m.SetBusinessID(v)
  44204. return nil
  44205. case whatsappchannel.FieldOrganizationID:
  44206. v, ok := value.(uint64)
  44207. if !ok {
  44208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44209. }
  44210. m.SetOrganizationID(v)
  44211. return nil
  44212. case whatsappchannel.FieldVerifyAccount:
  44213. v, ok := value.(string)
  44214. if !ok {
  44215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44216. }
  44217. m.SetVerifyAccount(v)
  44218. return nil
  44219. }
  44220. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44221. }
  44222. // AddedFields returns all numeric fields that were incremented/decremented during
  44223. // this mutation.
  44224. func (m *WhatsappChannelMutation) AddedFields() []string {
  44225. var fields []string
  44226. if m.addstatus != nil {
  44227. fields = append(fields, whatsappchannel.FieldStatus)
  44228. }
  44229. if m.addwaba_id != nil {
  44230. fields = append(fields, whatsappchannel.FieldWabaID)
  44231. }
  44232. if m.addbusiness_id != nil {
  44233. fields = append(fields, whatsappchannel.FieldBusinessID)
  44234. }
  44235. if m.addorganization_id != nil {
  44236. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44237. }
  44238. return fields
  44239. }
  44240. // AddedField returns the numeric value that was incremented/decremented on a field
  44241. // with the given name. The second boolean return value indicates that this field
  44242. // was not set, or was not defined in the schema.
  44243. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44244. switch name {
  44245. case whatsappchannel.FieldStatus:
  44246. return m.AddedStatus()
  44247. case whatsappchannel.FieldWabaID:
  44248. return m.AddedWabaID()
  44249. case whatsappchannel.FieldBusinessID:
  44250. return m.AddedBusinessID()
  44251. case whatsappchannel.FieldOrganizationID:
  44252. return m.AddedOrganizationID()
  44253. }
  44254. return nil, false
  44255. }
  44256. // AddField adds the value to the field with the given name. It returns an error if
  44257. // the field is not defined in the schema, or if the type mismatched the field
  44258. // type.
  44259. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44260. switch name {
  44261. case whatsappchannel.FieldStatus:
  44262. v, ok := value.(int8)
  44263. if !ok {
  44264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44265. }
  44266. m.AddStatus(v)
  44267. return nil
  44268. case whatsappchannel.FieldWabaID:
  44269. v, ok := value.(int64)
  44270. if !ok {
  44271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44272. }
  44273. m.AddWabaID(v)
  44274. return nil
  44275. case whatsappchannel.FieldBusinessID:
  44276. v, ok := value.(int64)
  44277. if !ok {
  44278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44279. }
  44280. m.AddBusinessID(v)
  44281. return nil
  44282. case whatsappchannel.FieldOrganizationID:
  44283. v, ok := value.(int64)
  44284. if !ok {
  44285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44286. }
  44287. m.AddOrganizationID(v)
  44288. return nil
  44289. }
  44290. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44291. }
  44292. // ClearedFields returns all nullable fields that were cleared during this
  44293. // mutation.
  44294. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44295. var fields []string
  44296. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44297. fields = append(fields, whatsappchannel.FieldStatus)
  44298. }
  44299. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44300. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44301. }
  44302. if m.FieldCleared(whatsappchannel.FieldAk) {
  44303. fields = append(fields, whatsappchannel.FieldAk)
  44304. }
  44305. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44306. fields = append(fields, whatsappchannel.FieldWaID)
  44307. }
  44308. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44309. fields = append(fields, whatsappchannel.FieldWaName)
  44310. }
  44311. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44312. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44313. }
  44314. return fields
  44315. }
  44316. // FieldCleared returns a boolean indicating if a field with the given name was
  44317. // cleared in this mutation.
  44318. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44319. _, ok := m.clearedFields[name]
  44320. return ok
  44321. }
  44322. // ClearField clears the value of the field with the given name. It returns an
  44323. // error if the field is not defined in the schema.
  44324. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44325. switch name {
  44326. case whatsappchannel.FieldStatus:
  44327. m.ClearStatus()
  44328. return nil
  44329. case whatsappchannel.FieldDeletedAt:
  44330. m.ClearDeletedAt()
  44331. return nil
  44332. case whatsappchannel.FieldAk:
  44333. m.ClearAk()
  44334. return nil
  44335. case whatsappchannel.FieldWaID:
  44336. m.ClearWaID()
  44337. return nil
  44338. case whatsappchannel.FieldWaName:
  44339. m.ClearWaName()
  44340. return nil
  44341. case whatsappchannel.FieldOrganizationID:
  44342. m.ClearOrganizationID()
  44343. return nil
  44344. }
  44345. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44346. }
  44347. // ResetField resets all changes in the mutation for the field with the given name.
  44348. // It returns an error if the field is not defined in the schema.
  44349. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44350. switch name {
  44351. case whatsappchannel.FieldCreatedAt:
  44352. m.ResetCreatedAt()
  44353. return nil
  44354. case whatsappchannel.FieldUpdatedAt:
  44355. m.ResetUpdatedAt()
  44356. return nil
  44357. case whatsappchannel.FieldStatus:
  44358. m.ResetStatus()
  44359. return nil
  44360. case whatsappchannel.FieldDeletedAt:
  44361. m.ResetDeletedAt()
  44362. return nil
  44363. case whatsappchannel.FieldAk:
  44364. m.ResetAk()
  44365. return nil
  44366. case whatsappchannel.FieldSk:
  44367. m.ResetSk()
  44368. return nil
  44369. case whatsappchannel.FieldWaID:
  44370. m.ResetWaID()
  44371. return nil
  44372. case whatsappchannel.FieldWaName:
  44373. m.ResetWaName()
  44374. return nil
  44375. case whatsappchannel.FieldWabaID:
  44376. m.ResetWabaID()
  44377. return nil
  44378. case whatsappchannel.FieldBusinessID:
  44379. m.ResetBusinessID()
  44380. return nil
  44381. case whatsappchannel.FieldOrganizationID:
  44382. m.ResetOrganizationID()
  44383. return nil
  44384. case whatsappchannel.FieldVerifyAccount:
  44385. m.ResetVerifyAccount()
  44386. return nil
  44387. }
  44388. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44389. }
  44390. // AddedEdges returns all edge names that were set/added in this mutation.
  44391. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44392. edges := make([]string, 0, 0)
  44393. return edges
  44394. }
  44395. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44396. // name in this mutation.
  44397. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44398. return nil
  44399. }
  44400. // RemovedEdges returns all edge names that were removed in this mutation.
  44401. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44402. edges := make([]string, 0, 0)
  44403. return edges
  44404. }
  44405. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44406. // the given name in this mutation.
  44407. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44408. return nil
  44409. }
  44410. // ClearedEdges returns all edge names that were cleared in this mutation.
  44411. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44412. edges := make([]string, 0, 0)
  44413. return edges
  44414. }
  44415. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44416. // was cleared in this mutation.
  44417. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44418. return false
  44419. }
  44420. // ClearEdge clears the value of the edge with the given name. It returns an error
  44421. // if that edge is not defined in the schema.
  44422. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44423. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44424. }
  44425. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44426. // It returns an error if the edge is not defined in the schema.
  44427. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44428. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44429. }
  44430. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44431. type WorkExperienceMutation struct {
  44432. config
  44433. op Op
  44434. typ string
  44435. id *uint64
  44436. created_at *time.Time
  44437. updated_at *time.Time
  44438. deleted_at *time.Time
  44439. start_date *time.Time
  44440. end_date *time.Time
  44441. company *string
  44442. experience *string
  44443. organization_id *uint64
  44444. addorganization_id *int64
  44445. clearedFields map[string]struct{}
  44446. employee *uint64
  44447. clearedemployee bool
  44448. done bool
  44449. oldValue func(context.Context) (*WorkExperience, error)
  44450. predicates []predicate.WorkExperience
  44451. }
  44452. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44453. // workexperienceOption allows management of the mutation configuration using functional options.
  44454. type workexperienceOption func(*WorkExperienceMutation)
  44455. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44456. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44457. m := &WorkExperienceMutation{
  44458. config: c,
  44459. op: op,
  44460. typ: TypeWorkExperience,
  44461. clearedFields: make(map[string]struct{}),
  44462. }
  44463. for _, opt := range opts {
  44464. opt(m)
  44465. }
  44466. return m
  44467. }
  44468. // withWorkExperienceID sets the ID field of the mutation.
  44469. func withWorkExperienceID(id uint64) workexperienceOption {
  44470. return func(m *WorkExperienceMutation) {
  44471. var (
  44472. err error
  44473. once sync.Once
  44474. value *WorkExperience
  44475. )
  44476. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44477. once.Do(func() {
  44478. if m.done {
  44479. err = errors.New("querying old values post mutation is not allowed")
  44480. } else {
  44481. value, err = m.Client().WorkExperience.Get(ctx, id)
  44482. }
  44483. })
  44484. return value, err
  44485. }
  44486. m.id = &id
  44487. }
  44488. }
  44489. // withWorkExperience sets the old WorkExperience of the mutation.
  44490. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44491. return func(m *WorkExperienceMutation) {
  44492. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44493. return node, nil
  44494. }
  44495. m.id = &node.ID
  44496. }
  44497. }
  44498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44499. // executed in a transaction (ent.Tx), a transactional client is returned.
  44500. func (m WorkExperienceMutation) Client() *Client {
  44501. client := &Client{config: m.config}
  44502. client.init()
  44503. return client
  44504. }
  44505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44506. // it returns an error otherwise.
  44507. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44508. if _, ok := m.driver.(*txDriver); !ok {
  44509. return nil, errors.New("ent: mutation is not running in a transaction")
  44510. }
  44511. tx := &Tx{config: m.config}
  44512. tx.init()
  44513. return tx, nil
  44514. }
  44515. // SetID sets the value of the id field. Note that this
  44516. // operation is only accepted on creation of WorkExperience entities.
  44517. func (m *WorkExperienceMutation) SetID(id uint64) {
  44518. m.id = &id
  44519. }
  44520. // ID returns the ID value in the mutation. Note that the ID is only available
  44521. // if it was provided to the builder or after it was returned from the database.
  44522. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44523. if m.id == nil {
  44524. return
  44525. }
  44526. return *m.id, true
  44527. }
  44528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44529. // That means, if the mutation is applied within a transaction with an isolation level such
  44530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44531. // or updated by the mutation.
  44532. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44533. switch {
  44534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44535. id, exists := m.ID()
  44536. if exists {
  44537. return []uint64{id}, nil
  44538. }
  44539. fallthrough
  44540. case m.op.Is(OpUpdate | OpDelete):
  44541. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44542. default:
  44543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44544. }
  44545. }
  44546. // SetCreatedAt sets the "created_at" field.
  44547. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44548. m.created_at = &t
  44549. }
  44550. // CreatedAt returns the value of the "created_at" field in the mutation.
  44551. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44552. v := m.created_at
  44553. if v == nil {
  44554. return
  44555. }
  44556. return *v, true
  44557. }
  44558. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44559. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44561. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44562. if !m.op.Is(OpUpdateOne) {
  44563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44564. }
  44565. if m.id == nil || m.oldValue == nil {
  44566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44567. }
  44568. oldValue, err := m.oldValue(ctx)
  44569. if err != nil {
  44570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44571. }
  44572. return oldValue.CreatedAt, nil
  44573. }
  44574. // ResetCreatedAt resets all changes to the "created_at" field.
  44575. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44576. m.created_at = nil
  44577. }
  44578. // SetUpdatedAt sets the "updated_at" field.
  44579. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44580. m.updated_at = &t
  44581. }
  44582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44583. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44584. v := m.updated_at
  44585. if v == nil {
  44586. return
  44587. }
  44588. return *v, true
  44589. }
  44590. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44591. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44593. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44594. if !m.op.Is(OpUpdateOne) {
  44595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44596. }
  44597. if m.id == nil || m.oldValue == nil {
  44598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44599. }
  44600. oldValue, err := m.oldValue(ctx)
  44601. if err != nil {
  44602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44603. }
  44604. return oldValue.UpdatedAt, nil
  44605. }
  44606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44607. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44608. m.updated_at = nil
  44609. }
  44610. // SetDeletedAt sets the "deleted_at" field.
  44611. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44612. m.deleted_at = &t
  44613. }
  44614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44615. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44616. v := m.deleted_at
  44617. if v == nil {
  44618. return
  44619. }
  44620. return *v, true
  44621. }
  44622. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44623. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44625. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44626. if !m.op.Is(OpUpdateOne) {
  44627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44628. }
  44629. if m.id == nil || m.oldValue == nil {
  44630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44631. }
  44632. oldValue, err := m.oldValue(ctx)
  44633. if err != nil {
  44634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44635. }
  44636. return oldValue.DeletedAt, nil
  44637. }
  44638. // ClearDeletedAt clears the value of the "deleted_at" field.
  44639. func (m *WorkExperienceMutation) ClearDeletedAt() {
  44640. m.deleted_at = nil
  44641. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  44642. }
  44643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44644. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  44645. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  44646. return ok
  44647. }
  44648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44649. func (m *WorkExperienceMutation) ResetDeletedAt() {
  44650. m.deleted_at = nil
  44651. delete(m.clearedFields, workexperience.FieldDeletedAt)
  44652. }
  44653. // SetEmployeeID sets the "employee_id" field.
  44654. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  44655. m.employee = &u
  44656. }
  44657. // EmployeeID returns the value of the "employee_id" field in the mutation.
  44658. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  44659. v := m.employee
  44660. if v == nil {
  44661. return
  44662. }
  44663. return *v, true
  44664. }
  44665. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  44666. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44668. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  44669. if !m.op.Is(OpUpdateOne) {
  44670. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  44671. }
  44672. if m.id == nil || m.oldValue == nil {
  44673. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  44674. }
  44675. oldValue, err := m.oldValue(ctx)
  44676. if err != nil {
  44677. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  44678. }
  44679. return oldValue.EmployeeID, nil
  44680. }
  44681. // ResetEmployeeID resets all changes to the "employee_id" field.
  44682. func (m *WorkExperienceMutation) ResetEmployeeID() {
  44683. m.employee = nil
  44684. }
  44685. // SetStartDate sets the "start_date" field.
  44686. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  44687. m.start_date = &t
  44688. }
  44689. // StartDate returns the value of the "start_date" field in the mutation.
  44690. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  44691. v := m.start_date
  44692. if v == nil {
  44693. return
  44694. }
  44695. return *v, true
  44696. }
  44697. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  44698. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44700. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  44701. if !m.op.Is(OpUpdateOne) {
  44702. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  44703. }
  44704. if m.id == nil || m.oldValue == nil {
  44705. return v, errors.New("OldStartDate requires an ID field in the mutation")
  44706. }
  44707. oldValue, err := m.oldValue(ctx)
  44708. if err != nil {
  44709. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  44710. }
  44711. return oldValue.StartDate, nil
  44712. }
  44713. // ResetStartDate resets all changes to the "start_date" field.
  44714. func (m *WorkExperienceMutation) ResetStartDate() {
  44715. m.start_date = nil
  44716. }
  44717. // SetEndDate sets the "end_date" field.
  44718. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  44719. m.end_date = &t
  44720. }
  44721. // EndDate returns the value of the "end_date" field in the mutation.
  44722. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  44723. v := m.end_date
  44724. if v == nil {
  44725. return
  44726. }
  44727. return *v, true
  44728. }
  44729. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  44730. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44732. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  44733. if !m.op.Is(OpUpdateOne) {
  44734. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  44735. }
  44736. if m.id == nil || m.oldValue == nil {
  44737. return v, errors.New("OldEndDate requires an ID field in the mutation")
  44738. }
  44739. oldValue, err := m.oldValue(ctx)
  44740. if err != nil {
  44741. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  44742. }
  44743. return oldValue.EndDate, nil
  44744. }
  44745. // ResetEndDate resets all changes to the "end_date" field.
  44746. func (m *WorkExperienceMutation) ResetEndDate() {
  44747. m.end_date = nil
  44748. }
  44749. // SetCompany sets the "company" field.
  44750. func (m *WorkExperienceMutation) SetCompany(s string) {
  44751. m.company = &s
  44752. }
  44753. // Company returns the value of the "company" field in the mutation.
  44754. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  44755. v := m.company
  44756. if v == nil {
  44757. return
  44758. }
  44759. return *v, true
  44760. }
  44761. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  44762. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44764. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  44765. if !m.op.Is(OpUpdateOne) {
  44766. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44767. }
  44768. if m.id == nil || m.oldValue == nil {
  44769. return v, errors.New("OldCompany requires an ID field in the mutation")
  44770. }
  44771. oldValue, err := m.oldValue(ctx)
  44772. if err != nil {
  44773. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44774. }
  44775. return oldValue.Company, nil
  44776. }
  44777. // ResetCompany resets all changes to the "company" field.
  44778. func (m *WorkExperienceMutation) ResetCompany() {
  44779. m.company = nil
  44780. }
  44781. // SetExperience sets the "experience" field.
  44782. func (m *WorkExperienceMutation) SetExperience(s string) {
  44783. m.experience = &s
  44784. }
  44785. // Experience returns the value of the "experience" field in the mutation.
  44786. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  44787. v := m.experience
  44788. if v == nil {
  44789. return
  44790. }
  44791. return *v, true
  44792. }
  44793. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  44794. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44796. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  44797. if !m.op.Is(OpUpdateOne) {
  44798. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  44799. }
  44800. if m.id == nil || m.oldValue == nil {
  44801. return v, errors.New("OldExperience requires an ID field in the mutation")
  44802. }
  44803. oldValue, err := m.oldValue(ctx)
  44804. if err != nil {
  44805. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  44806. }
  44807. return oldValue.Experience, nil
  44808. }
  44809. // ResetExperience resets all changes to the "experience" field.
  44810. func (m *WorkExperienceMutation) ResetExperience() {
  44811. m.experience = nil
  44812. }
  44813. // SetOrganizationID sets the "organization_id" field.
  44814. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  44815. m.organization_id = &u
  44816. m.addorganization_id = nil
  44817. }
  44818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44819. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  44820. v := m.organization_id
  44821. if v == nil {
  44822. return
  44823. }
  44824. return *v, true
  44825. }
  44826. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  44827. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44829. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44830. if !m.op.Is(OpUpdateOne) {
  44831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44832. }
  44833. if m.id == nil || m.oldValue == nil {
  44834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44835. }
  44836. oldValue, err := m.oldValue(ctx)
  44837. if err != nil {
  44838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44839. }
  44840. return oldValue.OrganizationID, nil
  44841. }
  44842. // AddOrganizationID adds u to the "organization_id" field.
  44843. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  44844. if m.addorganization_id != nil {
  44845. *m.addorganization_id += u
  44846. } else {
  44847. m.addorganization_id = &u
  44848. }
  44849. }
  44850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44851. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  44852. v := m.addorganization_id
  44853. if v == nil {
  44854. return
  44855. }
  44856. return *v, true
  44857. }
  44858. // ResetOrganizationID resets all changes to the "organization_id" field.
  44859. func (m *WorkExperienceMutation) ResetOrganizationID() {
  44860. m.organization_id = nil
  44861. m.addorganization_id = nil
  44862. }
  44863. // ClearEmployee clears the "employee" edge to the Employee entity.
  44864. func (m *WorkExperienceMutation) ClearEmployee() {
  44865. m.clearedemployee = true
  44866. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  44867. }
  44868. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  44869. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  44870. return m.clearedemployee
  44871. }
  44872. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  44873. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44874. // EmployeeID instead. It exists only for internal usage by the builders.
  44875. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  44876. if id := m.employee; id != nil {
  44877. ids = append(ids, *id)
  44878. }
  44879. return
  44880. }
  44881. // ResetEmployee resets all changes to the "employee" edge.
  44882. func (m *WorkExperienceMutation) ResetEmployee() {
  44883. m.employee = nil
  44884. m.clearedemployee = false
  44885. }
  44886. // Where appends a list predicates to the WorkExperienceMutation builder.
  44887. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  44888. m.predicates = append(m.predicates, ps...)
  44889. }
  44890. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  44891. // users can use type-assertion to append predicates that do not depend on any generated package.
  44892. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  44893. p := make([]predicate.WorkExperience, len(ps))
  44894. for i := range ps {
  44895. p[i] = ps[i]
  44896. }
  44897. m.Where(p...)
  44898. }
  44899. // Op returns the operation name.
  44900. func (m *WorkExperienceMutation) Op() Op {
  44901. return m.op
  44902. }
  44903. // SetOp allows setting the mutation operation.
  44904. func (m *WorkExperienceMutation) SetOp(op Op) {
  44905. m.op = op
  44906. }
  44907. // Type returns the node type of this mutation (WorkExperience).
  44908. func (m *WorkExperienceMutation) Type() string {
  44909. return m.typ
  44910. }
  44911. // Fields returns all fields that were changed during this mutation. Note that in
  44912. // order to get all numeric fields that were incremented/decremented, call
  44913. // AddedFields().
  44914. func (m *WorkExperienceMutation) Fields() []string {
  44915. fields := make([]string, 0, 9)
  44916. if m.created_at != nil {
  44917. fields = append(fields, workexperience.FieldCreatedAt)
  44918. }
  44919. if m.updated_at != nil {
  44920. fields = append(fields, workexperience.FieldUpdatedAt)
  44921. }
  44922. if m.deleted_at != nil {
  44923. fields = append(fields, workexperience.FieldDeletedAt)
  44924. }
  44925. if m.employee != nil {
  44926. fields = append(fields, workexperience.FieldEmployeeID)
  44927. }
  44928. if m.start_date != nil {
  44929. fields = append(fields, workexperience.FieldStartDate)
  44930. }
  44931. if m.end_date != nil {
  44932. fields = append(fields, workexperience.FieldEndDate)
  44933. }
  44934. if m.company != nil {
  44935. fields = append(fields, workexperience.FieldCompany)
  44936. }
  44937. if m.experience != nil {
  44938. fields = append(fields, workexperience.FieldExperience)
  44939. }
  44940. if m.organization_id != nil {
  44941. fields = append(fields, workexperience.FieldOrganizationID)
  44942. }
  44943. return fields
  44944. }
  44945. // Field returns the value of a field with the given name. The second boolean
  44946. // return value indicates that this field was not set, or was not defined in the
  44947. // schema.
  44948. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  44949. switch name {
  44950. case workexperience.FieldCreatedAt:
  44951. return m.CreatedAt()
  44952. case workexperience.FieldUpdatedAt:
  44953. return m.UpdatedAt()
  44954. case workexperience.FieldDeletedAt:
  44955. return m.DeletedAt()
  44956. case workexperience.FieldEmployeeID:
  44957. return m.EmployeeID()
  44958. case workexperience.FieldStartDate:
  44959. return m.StartDate()
  44960. case workexperience.FieldEndDate:
  44961. return m.EndDate()
  44962. case workexperience.FieldCompany:
  44963. return m.Company()
  44964. case workexperience.FieldExperience:
  44965. return m.Experience()
  44966. case workexperience.FieldOrganizationID:
  44967. return m.OrganizationID()
  44968. }
  44969. return nil, false
  44970. }
  44971. // OldField returns the old value of the field from the database. An error is
  44972. // returned if the mutation operation is not UpdateOne, or the query to the
  44973. // database failed.
  44974. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44975. switch name {
  44976. case workexperience.FieldCreatedAt:
  44977. return m.OldCreatedAt(ctx)
  44978. case workexperience.FieldUpdatedAt:
  44979. return m.OldUpdatedAt(ctx)
  44980. case workexperience.FieldDeletedAt:
  44981. return m.OldDeletedAt(ctx)
  44982. case workexperience.FieldEmployeeID:
  44983. return m.OldEmployeeID(ctx)
  44984. case workexperience.FieldStartDate:
  44985. return m.OldStartDate(ctx)
  44986. case workexperience.FieldEndDate:
  44987. return m.OldEndDate(ctx)
  44988. case workexperience.FieldCompany:
  44989. return m.OldCompany(ctx)
  44990. case workexperience.FieldExperience:
  44991. return m.OldExperience(ctx)
  44992. case workexperience.FieldOrganizationID:
  44993. return m.OldOrganizationID(ctx)
  44994. }
  44995. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  44996. }
  44997. // SetField sets the value of a field with the given name. It returns an error if
  44998. // the field is not defined in the schema, or if the type mismatched the field
  44999. // type.
  45000. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45001. switch name {
  45002. case workexperience.FieldCreatedAt:
  45003. v, ok := value.(time.Time)
  45004. if !ok {
  45005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45006. }
  45007. m.SetCreatedAt(v)
  45008. return nil
  45009. case workexperience.FieldUpdatedAt:
  45010. v, ok := value.(time.Time)
  45011. if !ok {
  45012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45013. }
  45014. m.SetUpdatedAt(v)
  45015. return nil
  45016. case workexperience.FieldDeletedAt:
  45017. v, ok := value.(time.Time)
  45018. if !ok {
  45019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45020. }
  45021. m.SetDeletedAt(v)
  45022. return nil
  45023. case workexperience.FieldEmployeeID:
  45024. v, ok := value.(uint64)
  45025. if !ok {
  45026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45027. }
  45028. m.SetEmployeeID(v)
  45029. return nil
  45030. case workexperience.FieldStartDate:
  45031. v, ok := value.(time.Time)
  45032. if !ok {
  45033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45034. }
  45035. m.SetStartDate(v)
  45036. return nil
  45037. case workexperience.FieldEndDate:
  45038. v, ok := value.(time.Time)
  45039. if !ok {
  45040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45041. }
  45042. m.SetEndDate(v)
  45043. return nil
  45044. case workexperience.FieldCompany:
  45045. v, ok := value.(string)
  45046. if !ok {
  45047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45048. }
  45049. m.SetCompany(v)
  45050. return nil
  45051. case workexperience.FieldExperience:
  45052. v, ok := value.(string)
  45053. if !ok {
  45054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45055. }
  45056. m.SetExperience(v)
  45057. return nil
  45058. case workexperience.FieldOrganizationID:
  45059. v, ok := value.(uint64)
  45060. if !ok {
  45061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45062. }
  45063. m.SetOrganizationID(v)
  45064. return nil
  45065. }
  45066. return fmt.Errorf("unknown WorkExperience field %s", name)
  45067. }
  45068. // AddedFields returns all numeric fields that were incremented/decremented during
  45069. // this mutation.
  45070. func (m *WorkExperienceMutation) AddedFields() []string {
  45071. var fields []string
  45072. if m.addorganization_id != nil {
  45073. fields = append(fields, workexperience.FieldOrganizationID)
  45074. }
  45075. return fields
  45076. }
  45077. // AddedField returns the numeric value that was incremented/decremented on a field
  45078. // with the given name. The second boolean return value indicates that this field
  45079. // was not set, or was not defined in the schema.
  45080. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45081. switch name {
  45082. case workexperience.FieldOrganizationID:
  45083. return m.AddedOrganizationID()
  45084. }
  45085. return nil, false
  45086. }
  45087. // AddField adds the value to the field with the given name. It returns an error if
  45088. // the field is not defined in the schema, or if the type mismatched the field
  45089. // type.
  45090. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45091. switch name {
  45092. case workexperience.FieldOrganizationID:
  45093. v, ok := value.(int64)
  45094. if !ok {
  45095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45096. }
  45097. m.AddOrganizationID(v)
  45098. return nil
  45099. }
  45100. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45101. }
  45102. // ClearedFields returns all nullable fields that were cleared during this
  45103. // mutation.
  45104. func (m *WorkExperienceMutation) ClearedFields() []string {
  45105. var fields []string
  45106. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45107. fields = append(fields, workexperience.FieldDeletedAt)
  45108. }
  45109. return fields
  45110. }
  45111. // FieldCleared returns a boolean indicating if a field with the given name was
  45112. // cleared in this mutation.
  45113. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45114. _, ok := m.clearedFields[name]
  45115. return ok
  45116. }
  45117. // ClearField clears the value of the field with the given name. It returns an
  45118. // error if the field is not defined in the schema.
  45119. func (m *WorkExperienceMutation) ClearField(name string) error {
  45120. switch name {
  45121. case workexperience.FieldDeletedAt:
  45122. m.ClearDeletedAt()
  45123. return nil
  45124. }
  45125. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45126. }
  45127. // ResetField resets all changes in the mutation for the field with the given name.
  45128. // It returns an error if the field is not defined in the schema.
  45129. func (m *WorkExperienceMutation) ResetField(name string) error {
  45130. switch name {
  45131. case workexperience.FieldCreatedAt:
  45132. m.ResetCreatedAt()
  45133. return nil
  45134. case workexperience.FieldUpdatedAt:
  45135. m.ResetUpdatedAt()
  45136. return nil
  45137. case workexperience.FieldDeletedAt:
  45138. m.ResetDeletedAt()
  45139. return nil
  45140. case workexperience.FieldEmployeeID:
  45141. m.ResetEmployeeID()
  45142. return nil
  45143. case workexperience.FieldStartDate:
  45144. m.ResetStartDate()
  45145. return nil
  45146. case workexperience.FieldEndDate:
  45147. m.ResetEndDate()
  45148. return nil
  45149. case workexperience.FieldCompany:
  45150. m.ResetCompany()
  45151. return nil
  45152. case workexperience.FieldExperience:
  45153. m.ResetExperience()
  45154. return nil
  45155. case workexperience.FieldOrganizationID:
  45156. m.ResetOrganizationID()
  45157. return nil
  45158. }
  45159. return fmt.Errorf("unknown WorkExperience field %s", name)
  45160. }
  45161. // AddedEdges returns all edge names that were set/added in this mutation.
  45162. func (m *WorkExperienceMutation) AddedEdges() []string {
  45163. edges := make([]string, 0, 1)
  45164. if m.employee != nil {
  45165. edges = append(edges, workexperience.EdgeEmployee)
  45166. }
  45167. return edges
  45168. }
  45169. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45170. // name in this mutation.
  45171. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45172. switch name {
  45173. case workexperience.EdgeEmployee:
  45174. if id := m.employee; id != nil {
  45175. return []ent.Value{*id}
  45176. }
  45177. }
  45178. return nil
  45179. }
  45180. // RemovedEdges returns all edge names that were removed in this mutation.
  45181. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45182. edges := make([]string, 0, 1)
  45183. return edges
  45184. }
  45185. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45186. // the given name in this mutation.
  45187. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45188. return nil
  45189. }
  45190. // ClearedEdges returns all edge names that were cleared in this mutation.
  45191. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45192. edges := make([]string, 0, 1)
  45193. if m.clearedemployee {
  45194. edges = append(edges, workexperience.EdgeEmployee)
  45195. }
  45196. return edges
  45197. }
  45198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45199. // was cleared in this mutation.
  45200. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45201. switch name {
  45202. case workexperience.EdgeEmployee:
  45203. return m.clearedemployee
  45204. }
  45205. return false
  45206. }
  45207. // ClearEdge clears the value of the edge with the given name. It returns an error
  45208. // if that edge is not defined in the schema.
  45209. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45210. switch name {
  45211. case workexperience.EdgeEmployee:
  45212. m.ClearEmployee()
  45213. return nil
  45214. }
  45215. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45216. }
  45217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45218. // It returns an error if the edge is not defined in the schema.
  45219. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45220. switch name {
  45221. case workexperience.EdgeEmployee:
  45222. m.ResetEmployee()
  45223. return nil
  45224. }
  45225. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45226. }
  45227. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45228. type WpChatroomMutation struct {
  45229. config
  45230. op Op
  45231. typ string
  45232. id *uint64
  45233. created_at *time.Time
  45234. updated_at *time.Time
  45235. status *uint8
  45236. addstatus *int8
  45237. wx_wxid *string
  45238. chatroom_id *string
  45239. nickname *string
  45240. owner *string
  45241. avatar *string
  45242. member_list *[]string
  45243. appendmember_list []string
  45244. clearedFields map[string]struct{}
  45245. done bool
  45246. oldValue func(context.Context) (*WpChatroom, error)
  45247. predicates []predicate.WpChatroom
  45248. }
  45249. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45250. // wpchatroomOption allows management of the mutation configuration using functional options.
  45251. type wpchatroomOption func(*WpChatroomMutation)
  45252. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45253. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45254. m := &WpChatroomMutation{
  45255. config: c,
  45256. op: op,
  45257. typ: TypeWpChatroom,
  45258. clearedFields: make(map[string]struct{}),
  45259. }
  45260. for _, opt := range opts {
  45261. opt(m)
  45262. }
  45263. return m
  45264. }
  45265. // withWpChatroomID sets the ID field of the mutation.
  45266. func withWpChatroomID(id uint64) wpchatroomOption {
  45267. return func(m *WpChatroomMutation) {
  45268. var (
  45269. err error
  45270. once sync.Once
  45271. value *WpChatroom
  45272. )
  45273. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45274. once.Do(func() {
  45275. if m.done {
  45276. err = errors.New("querying old values post mutation is not allowed")
  45277. } else {
  45278. value, err = m.Client().WpChatroom.Get(ctx, id)
  45279. }
  45280. })
  45281. return value, err
  45282. }
  45283. m.id = &id
  45284. }
  45285. }
  45286. // withWpChatroom sets the old WpChatroom of the mutation.
  45287. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45288. return func(m *WpChatroomMutation) {
  45289. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45290. return node, nil
  45291. }
  45292. m.id = &node.ID
  45293. }
  45294. }
  45295. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45296. // executed in a transaction (ent.Tx), a transactional client is returned.
  45297. func (m WpChatroomMutation) Client() *Client {
  45298. client := &Client{config: m.config}
  45299. client.init()
  45300. return client
  45301. }
  45302. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45303. // it returns an error otherwise.
  45304. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45305. if _, ok := m.driver.(*txDriver); !ok {
  45306. return nil, errors.New("ent: mutation is not running in a transaction")
  45307. }
  45308. tx := &Tx{config: m.config}
  45309. tx.init()
  45310. return tx, nil
  45311. }
  45312. // SetID sets the value of the id field. Note that this
  45313. // operation is only accepted on creation of WpChatroom entities.
  45314. func (m *WpChatroomMutation) SetID(id uint64) {
  45315. m.id = &id
  45316. }
  45317. // ID returns the ID value in the mutation. Note that the ID is only available
  45318. // if it was provided to the builder or after it was returned from the database.
  45319. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45320. if m.id == nil {
  45321. return
  45322. }
  45323. return *m.id, true
  45324. }
  45325. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45326. // That means, if the mutation is applied within a transaction with an isolation level such
  45327. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45328. // or updated by the mutation.
  45329. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45330. switch {
  45331. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45332. id, exists := m.ID()
  45333. if exists {
  45334. return []uint64{id}, nil
  45335. }
  45336. fallthrough
  45337. case m.op.Is(OpUpdate | OpDelete):
  45338. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45339. default:
  45340. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45341. }
  45342. }
  45343. // SetCreatedAt sets the "created_at" field.
  45344. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45345. m.created_at = &t
  45346. }
  45347. // CreatedAt returns the value of the "created_at" field in the mutation.
  45348. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45349. v := m.created_at
  45350. if v == nil {
  45351. return
  45352. }
  45353. return *v, true
  45354. }
  45355. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45356. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45358. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45359. if !m.op.Is(OpUpdateOne) {
  45360. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45361. }
  45362. if m.id == nil || m.oldValue == nil {
  45363. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45364. }
  45365. oldValue, err := m.oldValue(ctx)
  45366. if err != nil {
  45367. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45368. }
  45369. return oldValue.CreatedAt, nil
  45370. }
  45371. // ResetCreatedAt resets all changes to the "created_at" field.
  45372. func (m *WpChatroomMutation) ResetCreatedAt() {
  45373. m.created_at = nil
  45374. }
  45375. // SetUpdatedAt sets the "updated_at" field.
  45376. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45377. m.updated_at = &t
  45378. }
  45379. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45380. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45381. v := m.updated_at
  45382. if v == nil {
  45383. return
  45384. }
  45385. return *v, true
  45386. }
  45387. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45388. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45390. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45391. if !m.op.Is(OpUpdateOne) {
  45392. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45393. }
  45394. if m.id == nil || m.oldValue == nil {
  45395. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45396. }
  45397. oldValue, err := m.oldValue(ctx)
  45398. if err != nil {
  45399. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45400. }
  45401. return oldValue.UpdatedAt, nil
  45402. }
  45403. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45404. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45405. m.updated_at = nil
  45406. }
  45407. // SetStatus sets the "status" field.
  45408. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45409. m.status = &u
  45410. m.addstatus = nil
  45411. }
  45412. // Status returns the value of the "status" field in the mutation.
  45413. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45414. v := m.status
  45415. if v == nil {
  45416. return
  45417. }
  45418. return *v, true
  45419. }
  45420. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45421. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45423. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45424. if !m.op.Is(OpUpdateOne) {
  45425. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45426. }
  45427. if m.id == nil || m.oldValue == nil {
  45428. return v, errors.New("OldStatus requires an ID field in the mutation")
  45429. }
  45430. oldValue, err := m.oldValue(ctx)
  45431. if err != nil {
  45432. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45433. }
  45434. return oldValue.Status, nil
  45435. }
  45436. // AddStatus adds u to the "status" field.
  45437. func (m *WpChatroomMutation) AddStatus(u int8) {
  45438. if m.addstatus != nil {
  45439. *m.addstatus += u
  45440. } else {
  45441. m.addstatus = &u
  45442. }
  45443. }
  45444. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45445. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45446. v := m.addstatus
  45447. if v == nil {
  45448. return
  45449. }
  45450. return *v, true
  45451. }
  45452. // ClearStatus clears the value of the "status" field.
  45453. func (m *WpChatroomMutation) ClearStatus() {
  45454. m.status = nil
  45455. m.addstatus = nil
  45456. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45457. }
  45458. // StatusCleared returns if the "status" field was cleared in this mutation.
  45459. func (m *WpChatroomMutation) StatusCleared() bool {
  45460. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45461. return ok
  45462. }
  45463. // ResetStatus resets all changes to the "status" field.
  45464. func (m *WpChatroomMutation) ResetStatus() {
  45465. m.status = nil
  45466. m.addstatus = nil
  45467. delete(m.clearedFields, wpchatroom.FieldStatus)
  45468. }
  45469. // SetWxWxid sets the "wx_wxid" field.
  45470. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45471. m.wx_wxid = &s
  45472. }
  45473. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45474. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45475. v := m.wx_wxid
  45476. if v == nil {
  45477. return
  45478. }
  45479. return *v, true
  45480. }
  45481. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45482. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45484. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45485. if !m.op.Is(OpUpdateOne) {
  45486. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45487. }
  45488. if m.id == nil || m.oldValue == nil {
  45489. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45490. }
  45491. oldValue, err := m.oldValue(ctx)
  45492. if err != nil {
  45493. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45494. }
  45495. return oldValue.WxWxid, nil
  45496. }
  45497. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45498. func (m *WpChatroomMutation) ResetWxWxid() {
  45499. m.wx_wxid = nil
  45500. }
  45501. // SetChatroomID sets the "chatroom_id" field.
  45502. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45503. m.chatroom_id = &s
  45504. }
  45505. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45506. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45507. v := m.chatroom_id
  45508. if v == nil {
  45509. return
  45510. }
  45511. return *v, true
  45512. }
  45513. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45514. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45516. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45517. if !m.op.Is(OpUpdateOne) {
  45518. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45519. }
  45520. if m.id == nil || m.oldValue == nil {
  45521. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45522. }
  45523. oldValue, err := m.oldValue(ctx)
  45524. if err != nil {
  45525. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45526. }
  45527. return oldValue.ChatroomID, nil
  45528. }
  45529. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45530. func (m *WpChatroomMutation) ResetChatroomID() {
  45531. m.chatroom_id = nil
  45532. }
  45533. // SetNickname sets the "nickname" field.
  45534. func (m *WpChatroomMutation) SetNickname(s string) {
  45535. m.nickname = &s
  45536. }
  45537. // Nickname returns the value of the "nickname" field in the mutation.
  45538. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45539. v := m.nickname
  45540. if v == nil {
  45541. return
  45542. }
  45543. return *v, true
  45544. }
  45545. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45546. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45548. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45549. if !m.op.Is(OpUpdateOne) {
  45550. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45551. }
  45552. if m.id == nil || m.oldValue == nil {
  45553. return v, errors.New("OldNickname requires an ID field in the mutation")
  45554. }
  45555. oldValue, err := m.oldValue(ctx)
  45556. if err != nil {
  45557. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45558. }
  45559. return oldValue.Nickname, nil
  45560. }
  45561. // ResetNickname resets all changes to the "nickname" field.
  45562. func (m *WpChatroomMutation) ResetNickname() {
  45563. m.nickname = nil
  45564. }
  45565. // SetOwner sets the "owner" field.
  45566. func (m *WpChatroomMutation) SetOwner(s string) {
  45567. m.owner = &s
  45568. }
  45569. // Owner returns the value of the "owner" field in the mutation.
  45570. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45571. v := m.owner
  45572. if v == nil {
  45573. return
  45574. }
  45575. return *v, true
  45576. }
  45577. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45578. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45580. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45581. if !m.op.Is(OpUpdateOne) {
  45582. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45583. }
  45584. if m.id == nil || m.oldValue == nil {
  45585. return v, errors.New("OldOwner requires an ID field in the mutation")
  45586. }
  45587. oldValue, err := m.oldValue(ctx)
  45588. if err != nil {
  45589. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45590. }
  45591. return oldValue.Owner, nil
  45592. }
  45593. // ResetOwner resets all changes to the "owner" field.
  45594. func (m *WpChatroomMutation) ResetOwner() {
  45595. m.owner = nil
  45596. }
  45597. // SetAvatar sets the "avatar" field.
  45598. func (m *WpChatroomMutation) SetAvatar(s string) {
  45599. m.avatar = &s
  45600. }
  45601. // Avatar returns the value of the "avatar" field in the mutation.
  45602. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45603. v := m.avatar
  45604. if v == nil {
  45605. return
  45606. }
  45607. return *v, true
  45608. }
  45609. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45610. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45612. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45613. if !m.op.Is(OpUpdateOne) {
  45614. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45615. }
  45616. if m.id == nil || m.oldValue == nil {
  45617. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45618. }
  45619. oldValue, err := m.oldValue(ctx)
  45620. if err != nil {
  45621. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45622. }
  45623. return oldValue.Avatar, nil
  45624. }
  45625. // ResetAvatar resets all changes to the "avatar" field.
  45626. func (m *WpChatroomMutation) ResetAvatar() {
  45627. m.avatar = nil
  45628. }
  45629. // SetMemberList sets the "member_list" field.
  45630. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45631. m.member_list = &s
  45632. m.appendmember_list = nil
  45633. }
  45634. // MemberList returns the value of the "member_list" field in the mutation.
  45635. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  45636. v := m.member_list
  45637. if v == nil {
  45638. return
  45639. }
  45640. return *v, true
  45641. }
  45642. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  45643. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45645. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  45646. if !m.op.Is(OpUpdateOne) {
  45647. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  45648. }
  45649. if m.id == nil || m.oldValue == nil {
  45650. return v, errors.New("OldMemberList requires an ID field in the mutation")
  45651. }
  45652. oldValue, err := m.oldValue(ctx)
  45653. if err != nil {
  45654. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  45655. }
  45656. return oldValue.MemberList, nil
  45657. }
  45658. // AppendMemberList adds s to the "member_list" field.
  45659. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  45660. m.appendmember_list = append(m.appendmember_list, s...)
  45661. }
  45662. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  45663. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  45664. if len(m.appendmember_list) == 0 {
  45665. return nil, false
  45666. }
  45667. return m.appendmember_list, true
  45668. }
  45669. // ResetMemberList resets all changes to the "member_list" field.
  45670. func (m *WpChatroomMutation) ResetMemberList() {
  45671. m.member_list = nil
  45672. m.appendmember_list = nil
  45673. }
  45674. // Where appends a list predicates to the WpChatroomMutation builder.
  45675. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  45676. m.predicates = append(m.predicates, ps...)
  45677. }
  45678. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  45679. // users can use type-assertion to append predicates that do not depend on any generated package.
  45680. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  45681. p := make([]predicate.WpChatroom, len(ps))
  45682. for i := range ps {
  45683. p[i] = ps[i]
  45684. }
  45685. m.Where(p...)
  45686. }
  45687. // Op returns the operation name.
  45688. func (m *WpChatroomMutation) Op() Op {
  45689. return m.op
  45690. }
  45691. // SetOp allows setting the mutation operation.
  45692. func (m *WpChatroomMutation) SetOp(op Op) {
  45693. m.op = op
  45694. }
  45695. // Type returns the node type of this mutation (WpChatroom).
  45696. func (m *WpChatroomMutation) Type() string {
  45697. return m.typ
  45698. }
  45699. // Fields returns all fields that were changed during this mutation. Note that in
  45700. // order to get all numeric fields that were incremented/decremented, call
  45701. // AddedFields().
  45702. func (m *WpChatroomMutation) Fields() []string {
  45703. fields := make([]string, 0, 9)
  45704. if m.created_at != nil {
  45705. fields = append(fields, wpchatroom.FieldCreatedAt)
  45706. }
  45707. if m.updated_at != nil {
  45708. fields = append(fields, wpchatroom.FieldUpdatedAt)
  45709. }
  45710. if m.status != nil {
  45711. fields = append(fields, wpchatroom.FieldStatus)
  45712. }
  45713. if m.wx_wxid != nil {
  45714. fields = append(fields, wpchatroom.FieldWxWxid)
  45715. }
  45716. if m.chatroom_id != nil {
  45717. fields = append(fields, wpchatroom.FieldChatroomID)
  45718. }
  45719. if m.nickname != nil {
  45720. fields = append(fields, wpchatroom.FieldNickname)
  45721. }
  45722. if m.owner != nil {
  45723. fields = append(fields, wpchatroom.FieldOwner)
  45724. }
  45725. if m.avatar != nil {
  45726. fields = append(fields, wpchatroom.FieldAvatar)
  45727. }
  45728. if m.member_list != nil {
  45729. fields = append(fields, wpchatroom.FieldMemberList)
  45730. }
  45731. return fields
  45732. }
  45733. // Field returns the value of a field with the given name. The second boolean
  45734. // return value indicates that this field was not set, or was not defined in the
  45735. // schema.
  45736. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  45737. switch name {
  45738. case wpchatroom.FieldCreatedAt:
  45739. return m.CreatedAt()
  45740. case wpchatroom.FieldUpdatedAt:
  45741. return m.UpdatedAt()
  45742. case wpchatroom.FieldStatus:
  45743. return m.Status()
  45744. case wpchatroom.FieldWxWxid:
  45745. return m.WxWxid()
  45746. case wpchatroom.FieldChatroomID:
  45747. return m.ChatroomID()
  45748. case wpchatroom.FieldNickname:
  45749. return m.Nickname()
  45750. case wpchatroom.FieldOwner:
  45751. return m.Owner()
  45752. case wpchatroom.FieldAvatar:
  45753. return m.Avatar()
  45754. case wpchatroom.FieldMemberList:
  45755. return m.MemberList()
  45756. }
  45757. return nil, false
  45758. }
  45759. // OldField returns the old value of the field from the database. An error is
  45760. // returned if the mutation operation is not UpdateOne, or the query to the
  45761. // database failed.
  45762. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45763. switch name {
  45764. case wpchatroom.FieldCreatedAt:
  45765. return m.OldCreatedAt(ctx)
  45766. case wpchatroom.FieldUpdatedAt:
  45767. return m.OldUpdatedAt(ctx)
  45768. case wpchatroom.FieldStatus:
  45769. return m.OldStatus(ctx)
  45770. case wpchatroom.FieldWxWxid:
  45771. return m.OldWxWxid(ctx)
  45772. case wpchatroom.FieldChatroomID:
  45773. return m.OldChatroomID(ctx)
  45774. case wpchatroom.FieldNickname:
  45775. return m.OldNickname(ctx)
  45776. case wpchatroom.FieldOwner:
  45777. return m.OldOwner(ctx)
  45778. case wpchatroom.FieldAvatar:
  45779. return m.OldAvatar(ctx)
  45780. case wpchatroom.FieldMemberList:
  45781. return m.OldMemberList(ctx)
  45782. }
  45783. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  45784. }
  45785. // SetField sets the value of a field with the given name. It returns an error if
  45786. // the field is not defined in the schema, or if the type mismatched the field
  45787. // type.
  45788. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  45789. switch name {
  45790. case wpchatroom.FieldCreatedAt:
  45791. v, ok := value.(time.Time)
  45792. if !ok {
  45793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45794. }
  45795. m.SetCreatedAt(v)
  45796. return nil
  45797. case wpchatroom.FieldUpdatedAt:
  45798. v, ok := value.(time.Time)
  45799. if !ok {
  45800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45801. }
  45802. m.SetUpdatedAt(v)
  45803. return nil
  45804. case wpchatroom.FieldStatus:
  45805. v, ok := value.(uint8)
  45806. if !ok {
  45807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45808. }
  45809. m.SetStatus(v)
  45810. return nil
  45811. case wpchatroom.FieldWxWxid:
  45812. v, ok := value.(string)
  45813. if !ok {
  45814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45815. }
  45816. m.SetWxWxid(v)
  45817. return nil
  45818. case wpchatroom.FieldChatroomID:
  45819. v, ok := value.(string)
  45820. if !ok {
  45821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45822. }
  45823. m.SetChatroomID(v)
  45824. return nil
  45825. case wpchatroom.FieldNickname:
  45826. v, ok := value.(string)
  45827. if !ok {
  45828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45829. }
  45830. m.SetNickname(v)
  45831. return nil
  45832. case wpchatroom.FieldOwner:
  45833. v, ok := value.(string)
  45834. if !ok {
  45835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45836. }
  45837. m.SetOwner(v)
  45838. return nil
  45839. case wpchatroom.FieldAvatar:
  45840. v, ok := value.(string)
  45841. if !ok {
  45842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45843. }
  45844. m.SetAvatar(v)
  45845. return nil
  45846. case wpchatroom.FieldMemberList:
  45847. v, ok := value.([]string)
  45848. if !ok {
  45849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45850. }
  45851. m.SetMemberList(v)
  45852. return nil
  45853. }
  45854. return fmt.Errorf("unknown WpChatroom field %s", name)
  45855. }
  45856. // AddedFields returns all numeric fields that were incremented/decremented during
  45857. // this mutation.
  45858. func (m *WpChatroomMutation) AddedFields() []string {
  45859. var fields []string
  45860. if m.addstatus != nil {
  45861. fields = append(fields, wpchatroom.FieldStatus)
  45862. }
  45863. return fields
  45864. }
  45865. // AddedField returns the numeric value that was incremented/decremented on a field
  45866. // with the given name. The second boolean return value indicates that this field
  45867. // was not set, or was not defined in the schema.
  45868. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  45869. switch name {
  45870. case wpchatroom.FieldStatus:
  45871. return m.AddedStatus()
  45872. }
  45873. return nil, false
  45874. }
  45875. // AddField adds the value to the field with the given name. It returns an error if
  45876. // the field is not defined in the schema, or if the type mismatched the field
  45877. // type.
  45878. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  45879. switch name {
  45880. case wpchatroom.FieldStatus:
  45881. v, ok := value.(int8)
  45882. if !ok {
  45883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45884. }
  45885. m.AddStatus(v)
  45886. return nil
  45887. }
  45888. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  45889. }
  45890. // ClearedFields returns all nullable fields that were cleared during this
  45891. // mutation.
  45892. func (m *WpChatroomMutation) ClearedFields() []string {
  45893. var fields []string
  45894. if m.FieldCleared(wpchatroom.FieldStatus) {
  45895. fields = append(fields, wpchatroom.FieldStatus)
  45896. }
  45897. return fields
  45898. }
  45899. // FieldCleared returns a boolean indicating if a field with the given name was
  45900. // cleared in this mutation.
  45901. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  45902. _, ok := m.clearedFields[name]
  45903. return ok
  45904. }
  45905. // ClearField clears the value of the field with the given name. It returns an
  45906. // error if the field is not defined in the schema.
  45907. func (m *WpChatroomMutation) ClearField(name string) error {
  45908. switch name {
  45909. case wpchatroom.FieldStatus:
  45910. m.ClearStatus()
  45911. return nil
  45912. }
  45913. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  45914. }
  45915. // ResetField resets all changes in the mutation for the field with the given name.
  45916. // It returns an error if the field is not defined in the schema.
  45917. func (m *WpChatroomMutation) ResetField(name string) error {
  45918. switch name {
  45919. case wpchatroom.FieldCreatedAt:
  45920. m.ResetCreatedAt()
  45921. return nil
  45922. case wpchatroom.FieldUpdatedAt:
  45923. m.ResetUpdatedAt()
  45924. return nil
  45925. case wpchatroom.FieldStatus:
  45926. m.ResetStatus()
  45927. return nil
  45928. case wpchatroom.FieldWxWxid:
  45929. m.ResetWxWxid()
  45930. return nil
  45931. case wpchatroom.FieldChatroomID:
  45932. m.ResetChatroomID()
  45933. return nil
  45934. case wpchatroom.FieldNickname:
  45935. m.ResetNickname()
  45936. return nil
  45937. case wpchatroom.FieldOwner:
  45938. m.ResetOwner()
  45939. return nil
  45940. case wpchatroom.FieldAvatar:
  45941. m.ResetAvatar()
  45942. return nil
  45943. case wpchatroom.FieldMemberList:
  45944. m.ResetMemberList()
  45945. return nil
  45946. }
  45947. return fmt.Errorf("unknown WpChatroom field %s", name)
  45948. }
  45949. // AddedEdges returns all edge names that were set/added in this mutation.
  45950. func (m *WpChatroomMutation) AddedEdges() []string {
  45951. edges := make([]string, 0, 0)
  45952. return edges
  45953. }
  45954. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45955. // name in this mutation.
  45956. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  45957. return nil
  45958. }
  45959. // RemovedEdges returns all edge names that were removed in this mutation.
  45960. func (m *WpChatroomMutation) RemovedEdges() []string {
  45961. edges := make([]string, 0, 0)
  45962. return edges
  45963. }
  45964. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45965. // the given name in this mutation.
  45966. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  45967. return nil
  45968. }
  45969. // ClearedEdges returns all edge names that were cleared in this mutation.
  45970. func (m *WpChatroomMutation) ClearedEdges() []string {
  45971. edges := make([]string, 0, 0)
  45972. return edges
  45973. }
  45974. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45975. // was cleared in this mutation.
  45976. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  45977. return false
  45978. }
  45979. // ClearEdge clears the value of the edge with the given name. It returns an error
  45980. // if that edge is not defined in the schema.
  45981. func (m *WpChatroomMutation) ClearEdge(name string) error {
  45982. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  45983. }
  45984. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45985. // It returns an error if the edge is not defined in the schema.
  45986. func (m *WpChatroomMutation) ResetEdge(name string) error {
  45987. return fmt.Errorf("unknown WpChatroom edge %s", name)
  45988. }
  45989. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  45990. type WpChatroomMemberMutation struct {
  45991. config
  45992. op Op
  45993. typ string
  45994. id *uint64
  45995. created_at *time.Time
  45996. updated_at *time.Time
  45997. status *uint8
  45998. addstatus *int8
  45999. wx_wxid *string
  46000. wxid *string
  46001. nickname *string
  46002. avatar *string
  46003. clearedFields map[string]struct{}
  46004. done bool
  46005. oldValue func(context.Context) (*WpChatroomMember, error)
  46006. predicates []predicate.WpChatroomMember
  46007. }
  46008. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46009. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46010. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46011. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46012. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46013. m := &WpChatroomMemberMutation{
  46014. config: c,
  46015. op: op,
  46016. typ: TypeWpChatroomMember,
  46017. clearedFields: make(map[string]struct{}),
  46018. }
  46019. for _, opt := range opts {
  46020. opt(m)
  46021. }
  46022. return m
  46023. }
  46024. // withWpChatroomMemberID sets the ID field of the mutation.
  46025. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46026. return func(m *WpChatroomMemberMutation) {
  46027. var (
  46028. err error
  46029. once sync.Once
  46030. value *WpChatroomMember
  46031. )
  46032. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46033. once.Do(func() {
  46034. if m.done {
  46035. err = errors.New("querying old values post mutation is not allowed")
  46036. } else {
  46037. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46038. }
  46039. })
  46040. return value, err
  46041. }
  46042. m.id = &id
  46043. }
  46044. }
  46045. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46046. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46047. return func(m *WpChatroomMemberMutation) {
  46048. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46049. return node, nil
  46050. }
  46051. m.id = &node.ID
  46052. }
  46053. }
  46054. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46055. // executed in a transaction (ent.Tx), a transactional client is returned.
  46056. func (m WpChatroomMemberMutation) Client() *Client {
  46057. client := &Client{config: m.config}
  46058. client.init()
  46059. return client
  46060. }
  46061. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46062. // it returns an error otherwise.
  46063. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46064. if _, ok := m.driver.(*txDriver); !ok {
  46065. return nil, errors.New("ent: mutation is not running in a transaction")
  46066. }
  46067. tx := &Tx{config: m.config}
  46068. tx.init()
  46069. return tx, nil
  46070. }
  46071. // SetID sets the value of the id field. Note that this
  46072. // operation is only accepted on creation of WpChatroomMember entities.
  46073. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46074. m.id = &id
  46075. }
  46076. // ID returns the ID value in the mutation. Note that the ID is only available
  46077. // if it was provided to the builder or after it was returned from the database.
  46078. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46079. if m.id == nil {
  46080. return
  46081. }
  46082. return *m.id, true
  46083. }
  46084. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46085. // That means, if the mutation is applied within a transaction with an isolation level such
  46086. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46087. // or updated by the mutation.
  46088. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46089. switch {
  46090. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46091. id, exists := m.ID()
  46092. if exists {
  46093. return []uint64{id}, nil
  46094. }
  46095. fallthrough
  46096. case m.op.Is(OpUpdate | OpDelete):
  46097. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46098. default:
  46099. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46100. }
  46101. }
  46102. // SetCreatedAt sets the "created_at" field.
  46103. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46104. m.created_at = &t
  46105. }
  46106. // CreatedAt returns the value of the "created_at" field in the mutation.
  46107. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46108. v := m.created_at
  46109. if v == nil {
  46110. return
  46111. }
  46112. return *v, true
  46113. }
  46114. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46115. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46117. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46118. if !m.op.Is(OpUpdateOne) {
  46119. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46120. }
  46121. if m.id == nil || m.oldValue == nil {
  46122. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46123. }
  46124. oldValue, err := m.oldValue(ctx)
  46125. if err != nil {
  46126. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46127. }
  46128. return oldValue.CreatedAt, nil
  46129. }
  46130. // ResetCreatedAt resets all changes to the "created_at" field.
  46131. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46132. m.created_at = nil
  46133. }
  46134. // SetUpdatedAt sets the "updated_at" field.
  46135. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46136. m.updated_at = &t
  46137. }
  46138. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46139. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46140. v := m.updated_at
  46141. if v == nil {
  46142. return
  46143. }
  46144. return *v, true
  46145. }
  46146. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46147. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46149. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46150. if !m.op.Is(OpUpdateOne) {
  46151. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46152. }
  46153. if m.id == nil || m.oldValue == nil {
  46154. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46155. }
  46156. oldValue, err := m.oldValue(ctx)
  46157. if err != nil {
  46158. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46159. }
  46160. return oldValue.UpdatedAt, nil
  46161. }
  46162. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46163. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46164. m.updated_at = nil
  46165. }
  46166. // SetStatus sets the "status" field.
  46167. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46168. m.status = &u
  46169. m.addstatus = nil
  46170. }
  46171. // Status returns the value of the "status" field in the mutation.
  46172. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46173. v := m.status
  46174. if v == nil {
  46175. return
  46176. }
  46177. return *v, true
  46178. }
  46179. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46180. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46182. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46183. if !m.op.Is(OpUpdateOne) {
  46184. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46185. }
  46186. if m.id == nil || m.oldValue == nil {
  46187. return v, errors.New("OldStatus requires an ID field in the mutation")
  46188. }
  46189. oldValue, err := m.oldValue(ctx)
  46190. if err != nil {
  46191. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46192. }
  46193. return oldValue.Status, nil
  46194. }
  46195. // AddStatus adds u to the "status" field.
  46196. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46197. if m.addstatus != nil {
  46198. *m.addstatus += u
  46199. } else {
  46200. m.addstatus = &u
  46201. }
  46202. }
  46203. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46204. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46205. v := m.addstatus
  46206. if v == nil {
  46207. return
  46208. }
  46209. return *v, true
  46210. }
  46211. // ClearStatus clears the value of the "status" field.
  46212. func (m *WpChatroomMemberMutation) ClearStatus() {
  46213. m.status = nil
  46214. m.addstatus = nil
  46215. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46216. }
  46217. // StatusCleared returns if the "status" field was cleared in this mutation.
  46218. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46219. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46220. return ok
  46221. }
  46222. // ResetStatus resets all changes to the "status" field.
  46223. func (m *WpChatroomMemberMutation) ResetStatus() {
  46224. m.status = nil
  46225. m.addstatus = nil
  46226. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46227. }
  46228. // SetWxWxid sets the "wx_wxid" field.
  46229. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46230. m.wx_wxid = &s
  46231. }
  46232. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46233. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46234. v := m.wx_wxid
  46235. if v == nil {
  46236. return
  46237. }
  46238. return *v, true
  46239. }
  46240. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46241. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46243. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46244. if !m.op.Is(OpUpdateOne) {
  46245. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46246. }
  46247. if m.id == nil || m.oldValue == nil {
  46248. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46249. }
  46250. oldValue, err := m.oldValue(ctx)
  46251. if err != nil {
  46252. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46253. }
  46254. return oldValue.WxWxid, nil
  46255. }
  46256. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46257. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46258. m.wx_wxid = nil
  46259. }
  46260. // SetWxid sets the "wxid" field.
  46261. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46262. m.wxid = &s
  46263. }
  46264. // Wxid returns the value of the "wxid" field in the mutation.
  46265. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46266. v := m.wxid
  46267. if v == nil {
  46268. return
  46269. }
  46270. return *v, true
  46271. }
  46272. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46273. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46275. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46276. if !m.op.Is(OpUpdateOne) {
  46277. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46278. }
  46279. if m.id == nil || m.oldValue == nil {
  46280. return v, errors.New("OldWxid requires an ID field in the mutation")
  46281. }
  46282. oldValue, err := m.oldValue(ctx)
  46283. if err != nil {
  46284. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46285. }
  46286. return oldValue.Wxid, nil
  46287. }
  46288. // ResetWxid resets all changes to the "wxid" field.
  46289. func (m *WpChatroomMemberMutation) ResetWxid() {
  46290. m.wxid = nil
  46291. }
  46292. // SetNickname sets the "nickname" field.
  46293. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46294. m.nickname = &s
  46295. }
  46296. // Nickname returns the value of the "nickname" field in the mutation.
  46297. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46298. v := m.nickname
  46299. if v == nil {
  46300. return
  46301. }
  46302. return *v, true
  46303. }
  46304. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46305. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46307. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46308. if !m.op.Is(OpUpdateOne) {
  46309. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46310. }
  46311. if m.id == nil || m.oldValue == nil {
  46312. return v, errors.New("OldNickname requires an ID field in the mutation")
  46313. }
  46314. oldValue, err := m.oldValue(ctx)
  46315. if err != nil {
  46316. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46317. }
  46318. return oldValue.Nickname, nil
  46319. }
  46320. // ResetNickname resets all changes to the "nickname" field.
  46321. func (m *WpChatroomMemberMutation) ResetNickname() {
  46322. m.nickname = nil
  46323. }
  46324. // SetAvatar sets the "avatar" field.
  46325. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46326. m.avatar = &s
  46327. }
  46328. // Avatar returns the value of the "avatar" field in the mutation.
  46329. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46330. v := m.avatar
  46331. if v == nil {
  46332. return
  46333. }
  46334. return *v, true
  46335. }
  46336. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46337. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46339. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46340. if !m.op.Is(OpUpdateOne) {
  46341. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46342. }
  46343. if m.id == nil || m.oldValue == nil {
  46344. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46345. }
  46346. oldValue, err := m.oldValue(ctx)
  46347. if err != nil {
  46348. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46349. }
  46350. return oldValue.Avatar, nil
  46351. }
  46352. // ResetAvatar resets all changes to the "avatar" field.
  46353. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46354. m.avatar = nil
  46355. }
  46356. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46357. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46358. m.predicates = append(m.predicates, ps...)
  46359. }
  46360. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46361. // users can use type-assertion to append predicates that do not depend on any generated package.
  46362. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46363. p := make([]predicate.WpChatroomMember, len(ps))
  46364. for i := range ps {
  46365. p[i] = ps[i]
  46366. }
  46367. m.Where(p...)
  46368. }
  46369. // Op returns the operation name.
  46370. func (m *WpChatroomMemberMutation) Op() Op {
  46371. return m.op
  46372. }
  46373. // SetOp allows setting the mutation operation.
  46374. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46375. m.op = op
  46376. }
  46377. // Type returns the node type of this mutation (WpChatroomMember).
  46378. func (m *WpChatroomMemberMutation) Type() string {
  46379. return m.typ
  46380. }
  46381. // Fields returns all fields that were changed during this mutation. Note that in
  46382. // order to get all numeric fields that were incremented/decremented, call
  46383. // AddedFields().
  46384. func (m *WpChatroomMemberMutation) Fields() []string {
  46385. fields := make([]string, 0, 7)
  46386. if m.created_at != nil {
  46387. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46388. }
  46389. if m.updated_at != nil {
  46390. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46391. }
  46392. if m.status != nil {
  46393. fields = append(fields, wpchatroommember.FieldStatus)
  46394. }
  46395. if m.wx_wxid != nil {
  46396. fields = append(fields, wpchatroommember.FieldWxWxid)
  46397. }
  46398. if m.wxid != nil {
  46399. fields = append(fields, wpchatroommember.FieldWxid)
  46400. }
  46401. if m.nickname != nil {
  46402. fields = append(fields, wpchatroommember.FieldNickname)
  46403. }
  46404. if m.avatar != nil {
  46405. fields = append(fields, wpchatroommember.FieldAvatar)
  46406. }
  46407. return fields
  46408. }
  46409. // Field returns the value of a field with the given name. The second boolean
  46410. // return value indicates that this field was not set, or was not defined in the
  46411. // schema.
  46412. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46413. switch name {
  46414. case wpchatroommember.FieldCreatedAt:
  46415. return m.CreatedAt()
  46416. case wpchatroommember.FieldUpdatedAt:
  46417. return m.UpdatedAt()
  46418. case wpchatroommember.FieldStatus:
  46419. return m.Status()
  46420. case wpchatroommember.FieldWxWxid:
  46421. return m.WxWxid()
  46422. case wpchatroommember.FieldWxid:
  46423. return m.Wxid()
  46424. case wpchatroommember.FieldNickname:
  46425. return m.Nickname()
  46426. case wpchatroommember.FieldAvatar:
  46427. return m.Avatar()
  46428. }
  46429. return nil, false
  46430. }
  46431. // OldField returns the old value of the field from the database. An error is
  46432. // returned if the mutation operation is not UpdateOne, or the query to the
  46433. // database failed.
  46434. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46435. switch name {
  46436. case wpchatroommember.FieldCreatedAt:
  46437. return m.OldCreatedAt(ctx)
  46438. case wpchatroommember.FieldUpdatedAt:
  46439. return m.OldUpdatedAt(ctx)
  46440. case wpchatroommember.FieldStatus:
  46441. return m.OldStatus(ctx)
  46442. case wpchatroommember.FieldWxWxid:
  46443. return m.OldWxWxid(ctx)
  46444. case wpchatroommember.FieldWxid:
  46445. return m.OldWxid(ctx)
  46446. case wpchatroommember.FieldNickname:
  46447. return m.OldNickname(ctx)
  46448. case wpchatroommember.FieldAvatar:
  46449. return m.OldAvatar(ctx)
  46450. }
  46451. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46452. }
  46453. // SetField sets the value of a field with the given name. It returns an error if
  46454. // the field is not defined in the schema, or if the type mismatched the field
  46455. // type.
  46456. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46457. switch name {
  46458. case wpchatroommember.FieldCreatedAt:
  46459. v, ok := value.(time.Time)
  46460. if !ok {
  46461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46462. }
  46463. m.SetCreatedAt(v)
  46464. return nil
  46465. case wpchatroommember.FieldUpdatedAt:
  46466. v, ok := value.(time.Time)
  46467. if !ok {
  46468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46469. }
  46470. m.SetUpdatedAt(v)
  46471. return nil
  46472. case wpchatroommember.FieldStatus:
  46473. v, ok := value.(uint8)
  46474. if !ok {
  46475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46476. }
  46477. m.SetStatus(v)
  46478. return nil
  46479. case wpchatroommember.FieldWxWxid:
  46480. v, ok := value.(string)
  46481. if !ok {
  46482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46483. }
  46484. m.SetWxWxid(v)
  46485. return nil
  46486. case wpchatroommember.FieldWxid:
  46487. v, ok := value.(string)
  46488. if !ok {
  46489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46490. }
  46491. m.SetWxid(v)
  46492. return nil
  46493. case wpchatroommember.FieldNickname:
  46494. v, ok := value.(string)
  46495. if !ok {
  46496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46497. }
  46498. m.SetNickname(v)
  46499. return nil
  46500. case wpchatroommember.FieldAvatar:
  46501. v, ok := value.(string)
  46502. if !ok {
  46503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46504. }
  46505. m.SetAvatar(v)
  46506. return nil
  46507. }
  46508. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46509. }
  46510. // AddedFields returns all numeric fields that were incremented/decremented during
  46511. // this mutation.
  46512. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46513. var fields []string
  46514. if m.addstatus != nil {
  46515. fields = append(fields, wpchatroommember.FieldStatus)
  46516. }
  46517. return fields
  46518. }
  46519. // AddedField returns the numeric value that was incremented/decremented on a field
  46520. // with the given name. The second boolean return value indicates that this field
  46521. // was not set, or was not defined in the schema.
  46522. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46523. switch name {
  46524. case wpchatroommember.FieldStatus:
  46525. return m.AddedStatus()
  46526. }
  46527. return nil, false
  46528. }
  46529. // AddField adds the value to the field with the given name. It returns an error if
  46530. // the field is not defined in the schema, or if the type mismatched the field
  46531. // type.
  46532. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46533. switch name {
  46534. case wpchatroommember.FieldStatus:
  46535. v, ok := value.(int8)
  46536. if !ok {
  46537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46538. }
  46539. m.AddStatus(v)
  46540. return nil
  46541. }
  46542. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46543. }
  46544. // ClearedFields returns all nullable fields that were cleared during this
  46545. // mutation.
  46546. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46547. var fields []string
  46548. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46549. fields = append(fields, wpchatroommember.FieldStatus)
  46550. }
  46551. return fields
  46552. }
  46553. // FieldCleared returns a boolean indicating if a field with the given name was
  46554. // cleared in this mutation.
  46555. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46556. _, ok := m.clearedFields[name]
  46557. return ok
  46558. }
  46559. // ClearField clears the value of the field with the given name. It returns an
  46560. // error if the field is not defined in the schema.
  46561. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46562. switch name {
  46563. case wpchatroommember.FieldStatus:
  46564. m.ClearStatus()
  46565. return nil
  46566. }
  46567. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46568. }
  46569. // ResetField resets all changes in the mutation for the field with the given name.
  46570. // It returns an error if the field is not defined in the schema.
  46571. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46572. switch name {
  46573. case wpchatroommember.FieldCreatedAt:
  46574. m.ResetCreatedAt()
  46575. return nil
  46576. case wpchatroommember.FieldUpdatedAt:
  46577. m.ResetUpdatedAt()
  46578. return nil
  46579. case wpchatroommember.FieldStatus:
  46580. m.ResetStatus()
  46581. return nil
  46582. case wpchatroommember.FieldWxWxid:
  46583. m.ResetWxWxid()
  46584. return nil
  46585. case wpchatroommember.FieldWxid:
  46586. m.ResetWxid()
  46587. return nil
  46588. case wpchatroommember.FieldNickname:
  46589. m.ResetNickname()
  46590. return nil
  46591. case wpchatroommember.FieldAvatar:
  46592. m.ResetAvatar()
  46593. return nil
  46594. }
  46595. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46596. }
  46597. // AddedEdges returns all edge names that were set/added in this mutation.
  46598. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46599. edges := make([]string, 0, 0)
  46600. return edges
  46601. }
  46602. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46603. // name in this mutation.
  46604. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46605. return nil
  46606. }
  46607. // RemovedEdges returns all edge names that were removed in this mutation.
  46608. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46609. edges := make([]string, 0, 0)
  46610. return edges
  46611. }
  46612. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46613. // the given name in this mutation.
  46614. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46615. return nil
  46616. }
  46617. // ClearedEdges returns all edge names that were cleared in this mutation.
  46618. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46619. edges := make([]string, 0, 0)
  46620. return edges
  46621. }
  46622. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46623. // was cleared in this mutation.
  46624. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46625. return false
  46626. }
  46627. // ClearEdge clears the value of the edge with the given name. It returns an error
  46628. // if that edge is not defined in the schema.
  46629. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46630. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46631. }
  46632. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46633. // It returns an error if the edge is not defined in the schema.
  46634. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46635. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  46636. }
  46637. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  46638. type WxMutation struct {
  46639. config
  46640. op Op
  46641. typ string
  46642. id *uint64
  46643. created_at *time.Time
  46644. updated_at *time.Time
  46645. status *uint8
  46646. addstatus *int8
  46647. deleted_at *time.Time
  46648. port *string
  46649. process_id *string
  46650. callback *string
  46651. wxid *string
  46652. account *string
  46653. nickname *string
  46654. tel *string
  46655. head_big *string
  46656. organization_id *uint64
  46657. addorganization_id *int64
  46658. api_base *string
  46659. api_key *string
  46660. allow_list *[]string
  46661. appendallow_list []string
  46662. group_allow_list *[]string
  46663. appendgroup_allow_list []string
  46664. block_list *[]string
  46665. appendblock_list []string
  46666. group_block_list *[]string
  46667. appendgroup_block_list []string
  46668. ctype *uint64
  46669. addctype *int64
  46670. clearedFields map[string]struct{}
  46671. server *uint64
  46672. clearedserver bool
  46673. agent *uint64
  46674. clearedagent bool
  46675. done bool
  46676. oldValue func(context.Context) (*Wx, error)
  46677. predicates []predicate.Wx
  46678. }
  46679. var _ ent.Mutation = (*WxMutation)(nil)
  46680. // wxOption allows management of the mutation configuration using functional options.
  46681. type wxOption func(*WxMutation)
  46682. // newWxMutation creates new mutation for the Wx entity.
  46683. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  46684. m := &WxMutation{
  46685. config: c,
  46686. op: op,
  46687. typ: TypeWx,
  46688. clearedFields: make(map[string]struct{}),
  46689. }
  46690. for _, opt := range opts {
  46691. opt(m)
  46692. }
  46693. return m
  46694. }
  46695. // withWxID sets the ID field of the mutation.
  46696. func withWxID(id uint64) wxOption {
  46697. return func(m *WxMutation) {
  46698. var (
  46699. err error
  46700. once sync.Once
  46701. value *Wx
  46702. )
  46703. m.oldValue = func(ctx context.Context) (*Wx, error) {
  46704. once.Do(func() {
  46705. if m.done {
  46706. err = errors.New("querying old values post mutation is not allowed")
  46707. } else {
  46708. value, err = m.Client().Wx.Get(ctx, id)
  46709. }
  46710. })
  46711. return value, err
  46712. }
  46713. m.id = &id
  46714. }
  46715. }
  46716. // withWx sets the old Wx of the mutation.
  46717. func withWx(node *Wx) wxOption {
  46718. return func(m *WxMutation) {
  46719. m.oldValue = func(context.Context) (*Wx, error) {
  46720. return node, nil
  46721. }
  46722. m.id = &node.ID
  46723. }
  46724. }
  46725. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46726. // executed in a transaction (ent.Tx), a transactional client is returned.
  46727. func (m WxMutation) Client() *Client {
  46728. client := &Client{config: m.config}
  46729. client.init()
  46730. return client
  46731. }
  46732. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46733. // it returns an error otherwise.
  46734. func (m WxMutation) Tx() (*Tx, error) {
  46735. if _, ok := m.driver.(*txDriver); !ok {
  46736. return nil, errors.New("ent: mutation is not running in a transaction")
  46737. }
  46738. tx := &Tx{config: m.config}
  46739. tx.init()
  46740. return tx, nil
  46741. }
  46742. // SetID sets the value of the id field. Note that this
  46743. // operation is only accepted on creation of Wx entities.
  46744. func (m *WxMutation) SetID(id uint64) {
  46745. m.id = &id
  46746. }
  46747. // ID returns the ID value in the mutation. Note that the ID is only available
  46748. // if it was provided to the builder or after it was returned from the database.
  46749. func (m *WxMutation) ID() (id uint64, exists bool) {
  46750. if m.id == nil {
  46751. return
  46752. }
  46753. return *m.id, true
  46754. }
  46755. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46756. // That means, if the mutation is applied within a transaction with an isolation level such
  46757. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46758. // or updated by the mutation.
  46759. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  46760. switch {
  46761. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46762. id, exists := m.ID()
  46763. if exists {
  46764. return []uint64{id}, nil
  46765. }
  46766. fallthrough
  46767. case m.op.Is(OpUpdate | OpDelete):
  46768. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  46769. default:
  46770. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46771. }
  46772. }
  46773. // SetCreatedAt sets the "created_at" field.
  46774. func (m *WxMutation) SetCreatedAt(t time.Time) {
  46775. m.created_at = &t
  46776. }
  46777. // CreatedAt returns the value of the "created_at" field in the mutation.
  46778. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  46779. v := m.created_at
  46780. if v == nil {
  46781. return
  46782. }
  46783. return *v, true
  46784. }
  46785. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  46786. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46788. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46789. if !m.op.Is(OpUpdateOne) {
  46790. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46791. }
  46792. if m.id == nil || m.oldValue == nil {
  46793. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46794. }
  46795. oldValue, err := m.oldValue(ctx)
  46796. if err != nil {
  46797. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46798. }
  46799. return oldValue.CreatedAt, nil
  46800. }
  46801. // ResetCreatedAt resets all changes to the "created_at" field.
  46802. func (m *WxMutation) ResetCreatedAt() {
  46803. m.created_at = nil
  46804. }
  46805. // SetUpdatedAt sets the "updated_at" field.
  46806. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  46807. m.updated_at = &t
  46808. }
  46809. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46810. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  46811. v := m.updated_at
  46812. if v == nil {
  46813. return
  46814. }
  46815. return *v, true
  46816. }
  46817. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  46818. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46820. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46821. if !m.op.Is(OpUpdateOne) {
  46822. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46823. }
  46824. if m.id == nil || m.oldValue == nil {
  46825. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46826. }
  46827. oldValue, err := m.oldValue(ctx)
  46828. if err != nil {
  46829. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46830. }
  46831. return oldValue.UpdatedAt, nil
  46832. }
  46833. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46834. func (m *WxMutation) ResetUpdatedAt() {
  46835. m.updated_at = nil
  46836. }
  46837. // SetStatus sets the "status" field.
  46838. func (m *WxMutation) SetStatus(u uint8) {
  46839. m.status = &u
  46840. m.addstatus = nil
  46841. }
  46842. // Status returns the value of the "status" field in the mutation.
  46843. func (m *WxMutation) Status() (r uint8, exists bool) {
  46844. v := m.status
  46845. if v == nil {
  46846. return
  46847. }
  46848. return *v, true
  46849. }
  46850. // OldStatus returns the old "status" field's value of the Wx entity.
  46851. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46853. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46854. if !m.op.Is(OpUpdateOne) {
  46855. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46856. }
  46857. if m.id == nil || m.oldValue == nil {
  46858. return v, errors.New("OldStatus requires an ID field in the mutation")
  46859. }
  46860. oldValue, err := m.oldValue(ctx)
  46861. if err != nil {
  46862. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46863. }
  46864. return oldValue.Status, nil
  46865. }
  46866. // AddStatus adds u to the "status" field.
  46867. func (m *WxMutation) AddStatus(u int8) {
  46868. if m.addstatus != nil {
  46869. *m.addstatus += u
  46870. } else {
  46871. m.addstatus = &u
  46872. }
  46873. }
  46874. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46875. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  46876. v := m.addstatus
  46877. if v == nil {
  46878. return
  46879. }
  46880. return *v, true
  46881. }
  46882. // ClearStatus clears the value of the "status" field.
  46883. func (m *WxMutation) ClearStatus() {
  46884. m.status = nil
  46885. m.addstatus = nil
  46886. m.clearedFields[wx.FieldStatus] = struct{}{}
  46887. }
  46888. // StatusCleared returns if the "status" field was cleared in this mutation.
  46889. func (m *WxMutation) StatusCleared() bool {
  46890. _, ok := m.clearedFields[wx.FieldStatus]
  46891. return ok
  46892. }
  46893. // ResetStatus resets all changes to the "status" field.
  46894. func (m *WxMutation) ResetStatus() {
  46895. m.status = nil
  46896. m.addstatus = nil
  46897. delete(m.clearedFields, wx.FieldStatus)
  46898. }
  46899. // SetDeletedAt sets the "deleted_at" field.
  46900. func (m *WxMutation) SetDeletedAt(t time.Time) {
  46901. m.deleted_at = &t
  46902. }
  46903. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46904. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  46905. v := m.deleted_at
  46906. if v == nil {
  46907. return
  46908. }
  46909. return *v, true
  46910. }
  46911. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  46912. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46914. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46915. if !m.op.Is(OpUpdateOne) {
  46916. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46917. }
  46918. if m.id == nil || m.oldValue == nil {
  46919. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46920. }
  46921. oldValue, err := m.oldValue(ctx)
  46922. if err != nil {
  46923. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46924. }
  46925. return oldValue.DeletedAt, nil
  46926. }
  46927. // ClearDeletedAt clears the value of the "deleted_at" field.
  46928. func (m *WxMutation) ClearDeletedAt() {
  46929. m.deleted_at = nil
  46930. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  46931. }
  46932. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46933. func (m *WxMutation) DeletedAtCleared() bool {
  46934. _, ok := m.clearedFields[wx.FieldDeletedAt]
  46935. return ok
  46936. }
  46937. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46938. func (m *WxMutation) ResetDeletedAt() {
  46939. m.deleted_at = nil
  46940. delete(m.clearedFields, wx.FieldDeletedAt)
  46941. }
  46942. // SetServerID sets the "server_id" field.
  46943. func (m *WxMutation) SetServerID(u uint64) {
  46944. m.server = &u
  46945. }
  46946. // ServerID returns the value of the "server_id" field in the mutation.
  46947. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  46948. v := m.server
  46949. if v == nil {
  46950. return
  46951. }
  46952. return *v, true
  46953. }
  46954. // OldServerID returns the old "server_id" field's value of the Wx entity.
  46955. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46957. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  46958. if !m.op.Is(OpUpdateOne) {
  46959. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  46960. }
  46961. if m.id == nil || m.oldValue == nil {
  46962. return v, errors.New("OldServerID requires an ID field in the mutation")
  46963. }
  46964. oldValue, err := m.oldValue(ctx)
  46965. if err != nil {
  46966. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  46967. }
  46968. return oldValue.ServerID, nil
  46969. }
  46970. // ClearServerID clears the value of the "server_id" field.
  46971. func (m *WxMutation) ClearServerID() {
  46972. m.server = nil
  46973. m.clearedFields[wx.FieldServerID] = struct{}{}
  46974. }
  46975. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  46976. func (m *WxMutation) ServerIDCleared() bool {
  46977. _, ok := m.clearedFields[wx.FieldServerID]
  46978. return ok
  46979. }
  46980. // ResetServerID resets all changes to the "server_id" field.
  46981. func (m *WxMutation) ResetServerID() {
  46982. m.server = nil
  46983. delete(m.clearedFields, wx.FieldServerID)
  46984. }
  46985. // SetPort sets the "port" field.
  46986. func (m *WxMutation) SetPort(s string) {
  46987. m.port = &s
  46988. }
  46989. // Port returns the value of the "port" field in the mutation.
  46990. func (m *WxMutation) Port() (r string, exists bool) {
  46991. v := m.port
  46992. if v == nil {
  46993. return
  46994. }
  46995. return *v, true
  46996. }
  46997. // OldPort returns the old "port" field's value of the Wx entity.
  46998. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  46999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47000. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47001. if !m.op.Is(OpUpdateOne) {
  47002. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47003. }
  47004. if m.id == nil || m.oldValue == nil {
  47005. return v, errors.New("OldPort requires an ID field in the mutation")
  47006. }
  47007. oldValue, err := m.oldValue(ctx)
  47008. if err != nil {
  47009. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47010. }
  47011. return oldValue.Port, nil
  47012. }
  47013. // ResetPort resets all changes to the "port" field.
  47014. func (m *WxMutation) ResetPort() {
  47015. m.port = nil
  47016. }
  47017. // SetProcessID sets the "process_id" field.
  47018. func (m *WxMutation) SetProcessID(s string) {
  47019. m.process_id = &s
  47020. }
  47021. // ProcessID returns the value of the "process_id" field in the mutation.
  47022. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47023. v := m.process_id
  47024. if v == nil {
  47025. return
  47026. }
  47027. return *v, true
  47028. }
  47029. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47030. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47032. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47033. if !m.op.Is(OpUpdateOne) {
  47034. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47035. }
  47036. if m.id == nil || m.oldValue == nil {
  47037. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47038. }
  47039. oldValue, err := m.oldValue(ctx)
  47040. if err != nil {
  47041. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47042. }
  47043. return oldValue.ProcessID, nil
  47044. }
  47045. // ResetProcessID resets all changes to the "process_id" field.
  47046. func (m *WxMutation) ResetProcessID() {
  47047. m.process_id = nil
  47048. }
  47049. // SetCallback sets the "callback" field.
  47050. func (m *WxMutation) SetCallback(s string) {
  47051. m.callback = &s
  47052. }
  47053. // Callback returns the value of the "callback" field in the mutation.
  47054. func (m *WxMutation) Callback() (r string, exists bool) {
  47055. v := m.callback
  47056. if v == nil {
  47057. return
  47058. }
  47059. return *v, true
  47060. }
  47061. // OldCallback returns the old "callback" field's value of the Wx entity.
  47062. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47064. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47065. if !m.op.Is(OpUpdateOne) {
  47066. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47067. }
  47068. if m.id == nil || m.oldValue == nil {
  47069. return v, errors.New("OldCallback requires an ID field in the mutation")
  47070. }
  47071. oldValue, err := m.oldValue(ctx)
  47072. if err != nil {
  47073. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47074. }
  47075. return oldValue.Callback, nil
  47076. }
  47077. // ResetCallback resets all changes to the "callback" field.
  47078. func (m *WxMutation) ResetCallback() {
  47079. m.callback = nil
  47080. }
  47081. // SetWxid sets the "wxid" field.
  47082. func (m *WxMutation) SetWxid(s string) {
  47083. m.wxid = &s
  47084. }
  47085. // Wxid returns the value of the "wxid" field in the mutation.
  47086. func (m *WxMutation) Wxid() (r string, exists bool) {
  47087. v := m.wxid
  47088. if v == nil {
  47089. return
  47090. }
  47091. return *v, true
  47092. }
  47093. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47094. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47096. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47097. if !m.op.Is(OpUpdateOne) {
  47098. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47099. }
  47100. if m.id == nil || m.oldValue == nil {
  47101. return v, errors.New("OldWxid requires an ID field in the mutation")
  47102. }
  47103. oldValue, err := m.oldValue(ctx)
  47104. if err != nil {
  47105. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47106. }
  47107. return oldValue.Wxid, nil
  47108. }
  47109. // ResetWxid resets all changes to the "wxid" field.
  47110. func (m *WxMutation) ResetWxid() {
  47111. m.wxid = nil
  47112. }
  47113. // SetAccount sets the "account" field.
  47114. func (m *WxMutation) SetAccount(s string) {
  47115. m.account = &s
  47116. }
  47117. // Account returns the value of the "account" field in the mutation.
  47118. func (m *WxMutation) Account() (r string, exists bool) {
  47119. v := m.account
  47120. if v == nil {
  47121. return
  47122. }
  47123. return *v, true
  47124. }
  47125. // OldAccount returns the old "account" field's value of the Wx entity.
  47126. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47128. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47129. if !m.op.Is(OpUpdateOne) {
  47130. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47131. }
  47132. if m.id == nil || m.oldValue == nil {
  47133. return v, errors.New("OldAccount requires an ID field in the mutation")
  47134. }
  47135. oldValue, err := m.oldValue(ctx)
  47136. if err != nil {
  47137. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47138. }
  47139. return oldValue.Account, nil
  47140. }
  47141. // ResetAccount resets all changes to the "account" field.
  47142. func (m *WxMutation) ResetAccount() {
  47143. m.account = nil
  47144. }
  47145. // SetNickname sets the "nickname" field.
  47146. func (m *WxMutation) SetNickname(s string) {
  47147. m.nickname = &s
  47148. }
  47149. // Nickname returns the value of the "nickname" field in the mutation.
  47150. func (m *WxMutation) Nickname() (r string, exists bool) {
  47151. v := m.nickname
  47152. if v == nil {
  47153. return
  47154. }
  47155. return *v, true
  47156. }
  47157. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47158. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47160. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47161. if !m.op.Is(OpUpdateOne) {
  47162. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47163. }
  47164. if m.id == nil || m.oldValue == nil {
  47165. return v, errors.New("OldNickname requires an ID field in the mutation")
  47166. }
  47167. oldValue, err := m.oldValue(ctx)
  47168. if err != nil {
  47169. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47170. }
  47171. return oldValue.Nickname, nil
  47172. }
  47173. // ResetNickname resets all changes to the "nickname" field.
  47174. func (m *WxMutation) ResetNickname() {
  47175. m.nickname = nil
  47176. }
  47177. // SetTel sets the "tel" field.
  47178. func (m *WxMutation) SetTel(s string) {
  47179. m.tel = &s
  47180. }
  47181. // Tel returns the value of the "tel" field in the mutation.
  47182. func (m *WxMutation) Tel() (r string, exists bool) {
  47183. v := m.tel
  47184. if v == nil {
  47185. return
  47186. }
  47187. return *v, true
  47188. }
  47189. // OldTel returns the old "tel" field's value of the Wx entity.
  47190. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47192. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47193. if !m.op.Is(OpUpdateOne) {
  47194. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47195. }
  47196. if m.id == nil || m.oldValue == nil {
  47197. return v, errors.New("OldTel requires an ID field in the mutation")
  47198. }
  47199. oldValue, err := m.oldValue(ctx)
  47200. if err != nil {
  47201. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47202. }
  47203. return oldValue.Tel, nil
  47204. }
  47205. // ResetTel resets all changes to the "tel" field.
  47206. func (m *WxMutation) ResetTel() {
  47207. m.tel = nil
  47208. }
  47209. // SetHeadBig sets the "head_big" field.
  47210. func (m *WxMutation) SetHeadBig(s string) {
  47211. m.head_big = &s
  47212. }
  47213. // HeadBig returns the value of the "head_big" field in the mutation.
  47214. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47215. v := m.head_big
  47216. if v == nil {
  47217. return
  47218. }
  47219. return *v, true
  47220. }
  47221. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47222. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47224. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47225. if !m.op.Is(OpUpdateOne) {
  47226. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47227. }
  47228. if m.id == nil || m.oldValue == nil {
  47229. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47230. }
  47231. oldValue, err := m.oldValue(ctx)
  47232. if err != nil {
  47233. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47234. }
  47235. return oldValue.HeadBig, nil
  47236. }
  47237. // ResetHeadBig resets all changes to the "head_big" field.
  47238. func (m *WxMutation) ResetHeadBig() {
  47239. m.head_big = nil
  47240. }
  47241. // SetOrganizationID sets the "organization_id" field.
  47242. func (m *WxMutation) SetOrganizationID(u uint64) {
  47243. m.organization_id = &u
  47244. m.addorganization_id = nil
  47245. }
  47246. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47247. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47248. v := m.organization_id
  47249. if v == nil {
  47250. return
  47251. }
  47252. return *v, true
  47253. }
  47254. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47255. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47257. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47258. if !m.op.Is(OpUpdateOne) {
  47259. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47260. }
  47261. if m.id == nil || m.oldValue == nil {
  47262. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47263. }
  47264. oldValue, err := m.oldValue(ctx)
  47265. if err != nil {
  47266. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47267. }
  47268. return oldValue.OrganizationID, nil
  47269. }
  47270. // AddOrganizationID adds u to the "organization_id" field.
  47271. func (m *WxMutation) AddOrganizationID(u int64) {
  47272. if m.addorganization_id != nil {
  47273. *m.addorganization_id += u
  47274. } else {
  47275. m.addorganization_id = &u
  47276. }
  47277. }
  47278. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47279. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47280. v := m.addorganization_id
  47281. if v == nil {
  47282. return
  47283. }
  47284. return *v, true
  47285. }
  47286. // ClearOrganizationID clears the value of the "organization_id" field.
  47287. func (m *WxMutation) ClearOrganizationID() {
  47288. m.organization_id = nil
  47289. m.addorganization_id = nil
  47290. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47291. }
  47292. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47293. func (m *WxMutation) OrganizationIDCleared() bool {
  47294. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47295. return ok
  47296. }
  47297. // ResetOrganizationID resets all changes to the "organization_id" field.
  47298. func (m *WxMutation) ResetOrganizationID() {
  47299. m.organization_id = nil
  47300. m.addorganization_id = nil
  47301. delete(m.clearedFields, wx.FieldOrganizationID)
  47302. }
  47303. // SetAgentID sets the "agent_id" field.
  47304. func (m *WxMutation) SetAgentID(u uint64) {
  47305. m.agent = &u
  47306. }
  47307. // AgentID returns the value of the "agent_id" field in the mutation.
  47308. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47309. v := m.agent
  47310. if v == nil {
  47311. return
  47312. }
  47313. return *v, true
  47314. }
  47315. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47316. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47318. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47319. if !m.op.Is(OpUpdateOne) {
  47320. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47321. }
  47322. if m.id == nil || m.oldValue == nil {
  47323. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47324. }
  47325. oldValue, err := m.oldValue(ctx)
  47326. if err != nil {
  47327. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47328. }
  47329. return oldValue.AgentID, nil
  47330. }
  47331. // ResetAgentID resets all changes to the "agent_id" field.
  47332. func (m *WxMutation) ResetAgentID() {
  47333. m.agent = nil
  47334. }
  47335. // SetAPIBase sets the "api_base" field.
  47336. func (m *WxMutation) SetAPIBase(s string) {
  47337. m.api_base = &s
  47338. }
  47339. // APIBase returns the value of the "api_base" field in the mutation.
  47340. func (m *WxMutation) APIBase() (r string, exists bool) {
  47341. v := m.api_base
  47342. if v == nil {
  47343. return
  47344. }
  47345. return *v, true
  47346. }
  47347. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47348. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47350. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47351. if !m.op.Is(OpUpdateOne) {
  47352. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47353. }
  47354. if m.id == nil || m.oldValue == nil {
  47355. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47356. }
  47357. oldValue, err := m.oldValue(ctx)
  47358. if err != nil {
  47359. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47360. }
  47361. return oldValue.APIBase, nil
  47362. }
  47363. // ClearAPIBase clears the value of the "api_base" field.
  47364. func (m *WxMutation) ClearAPIBase() {
  47365. m.api_base = nil
  47366. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47367. }
  47368. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47369. func (m *WxMutation) APIBaseCleared() bool {
  47370. _, ok := m.clearedFields[wx.FieldAPIBase]
  47371. return ok
  47372. }
  47373. // ResetAPIBase resets all changes to the "api_base" field.
  47374. func (m *WxMutation) ResetAPIBase() {
  47375. m.api_base = nil
  47376. delete(m.clearedFields, wx.FieldAPIBase)
  47377. }
  47378. // SetAPIKey sets the "api_key" field.
  47379. func (m *WxMutation) SetAPIKey(s string) {
  47380. m.api_key = &s
  47381. }
  47382. // APIKey returns the value of the "api_key" field in the mutation.
  47383. func (m *WxMutation) APIKey() (r string, exists bool) {
  47384. v := m.api_key
  47385. if v == nil {
  47386. return
  47387. }
  47388. return *v, true
  47389. }
  47390. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47391. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47393. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47394. if !m.op.Is(OpUpdateOne) {
  47395. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47396. }
  47397. if m.id == nil || m.oldValue == nil {
  47398. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47399. }
  47400. oldValue, err := m.oldValue(ctx)
  47401. if err != nil {
  47402. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47403. }
  47404. return oldValue.APIKey, nil
  47405. }
  47406. // ClearAPIKey clears the value of the "api_key" field.
  47407. func (m *WxMutation) ClearAPIKey() {
  47408. m.api_key = nil
  47409. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47410. }
  47411. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47412. func (m *WxMutation) APIKeyCleared() bool {
  47413. _, ok := m.clearedFields[wx.FieldAPIKey]
  47414. return ok
  47415. }
  47416. // ResetAPIKey resets all changes to the "api_key" field.
  47417. func (m *WxMutation) ResetAPIKey() {
  47418. m.api_key = nil
  47419. delete(m.clearedFields, wx.FieldAPIKey)
  47420. }
  47421. // SetAllowList sets the "allow_list" field.
  47422. func (m *WxMutation) SetAllowList(s []string) {
  47423. m.allow_list = &s
  47424. m.appendallow_list = nil
  47425. }
  47426. // AllowList returns the value of the "allow_list" field in the mutation.
  47427. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47428. v := m.allow_list
  47429. if v == nil {
  47430. return
  47431. }
  47432. return *v, true
  47433. }
  47434. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47435. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47437. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47438. if !m.op.Is(OpUpdateOne) {
  47439. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47440. }
  47441. if m.id == nil || m.oldValue == nil {
  47442. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47443. }
  47444. oldValue, err := m.oldValue(ctx)
  47445. if err != nil {
  47446. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47447. }
  47448. return oldValue.AllowList, nil
  47449. }
  47450. // AppendAllowList adds s to the "allow_list" field.
  47451. func (m *WxMutation) AppendAllowList(s []string) {
  47452. m.appendallow_list = append(m.appendallow_list, s...)
  47453. }
  47454. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47455. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47456. if len(m.appendallow_list) == 0 {
  47457. return nil, false
  47458. }
  47459. return m.appendallow_list, true
  47460. }
  47461. // ResetAllowList resets all changes to the "allow_list" field.
  47462. func (m *WxMutation) ResetAllowList() {
  47463. m.allow_list = nil
  47464. m.appendallow_list = nil
  47465. }
  47466. // SetGroupAllowList sets the "group_allow_list" field.
  47467. func (m *WxMutation) SetGroupAllowList(s []string) {
  47468. m.group_allow_list = &s
  47469. m.appendgroup_allow_list = nil
  47470. }
  47471. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47472. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47473. v := m.group_allow_list
  47474. if v == nil {
  47475. return
  47476. }
  47477. return *v, true
  47478. }
  47479. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47480. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47482. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47483. if !m.op.Is(OpUpdateOne) {
  47484. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47485. }
  47486. if m.id == nil || m.oldValue == nil {
  47487. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47488. }
  47489. oldValue, err := m.oldValue(ctx)
  47490. if err != nil {
  47491. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47492. }
  47493. return oldValue.GroupAllowList, nil
  47494. }
  47495. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47496. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47497. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47498. }
  47499. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47500. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47501. if len(m.appendgroup_allow_list) == 0 {
  47502. return nil, false
  47503. }
  47504. return m.appendgroup_allow_list, true
  47505. }
  47506. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47507. func (m *WxMutation) ResetGroupAllowList() {
  47508. m.group_allow_list = nil
  47509. m.appendgroup_allow_list = nil
  47510. }
  47511. // SetBlockList sets the "block_list" field.
  47512. func (m *WxMutation) SetBlockList(s []string) {
  47513. m.block_list = &s
  47514. m.appendblock_list = nil
  47515. }
  47516. // BlockList returns the value of the "block_list" field in the mutation.
  47517. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47518. v := m.block_list
  47519. if v == nil {
  47520. return
  47521. }
  47522. return *v, true
  47523. }
  47524. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47525. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47527. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47528. if !m.op.Is(OpUpdateOne) {
  47529. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47530. }
  47531. if m.id == nil || m.oldValue == nil {
  47532. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47533. }
  47534. oldValue, err := m.oldValue(ctx)
  47535. if err != nil {
  47536. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47537. }
  47538. return oldValue.BlockList, nil
  47539. }
  47540. // AppendBlockList adds s to the "block_list" field.
  47541. func (m *WxMutation) AppendBlockList(s []string) {
  47542. m.appendblock_list = append(m.appendblock_list, s...)
  47543. }
  47544. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47545. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47546. if len(m.appendblock_list) == 0 {
  47547. return nil, false
  47548. }
  47549. return m.appendblock_list, true
  47550. }
  47551. // ResetBlockList resets all changes to the "block_list" field.
  47552. func (m *WxMutation) ResetBlockList() {
  47553. m.block_list = nil
  47554. m.appendblock_list = nil
  47555. }
  47556. // SetGroupBlockList sets the "group_block_list" field.
  47557. func (m *WxMutation) SetGroupBlockList(s []string) {
  47558. m.group_block_list = &s
  47559. m.appendgroup_block_list = nil
  47560. }
  47561. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47562. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47563. v := m.group_block_list
  47564. if v == nil {
  47565. return
  47566. }
  47567. return *v, true
  47568. }
  47569. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47570. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47572. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47573. if !m.op.Is(OpUpdateOne) {
  47574. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47575. }
  47576. if m.id == nil || m.oldValue == nil {
  47577. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47578. }
  47579. oldValue, err := m.oldValue(ctx)
  47580. if err != nil {
  47581. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47582. }
  47583. return oldValue.GroupBlockList, nil
  47584. }
  47585. // AppendGroupBlockList adds s to the "group_block_list" field.
  47586. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47587. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47588. }
  47589. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47590. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47591. if len(m.appendgroup_block_list) == 0 {
  47592. return nil, false
  47593. }
  47594. return m.appendgroup_block_list, true
  47595. }
  47596. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47597. func (m *WxMutation) ResetGroupBlockList() {
  47598. m.group_block_list = nil
  47599. m.appendgroup_block_list = nil
  47600. }
  47601. // SetCtype sets the "ctype" field.
  47602. func (m *WxMutation) SetCtype(u uint64) {
  47603. m.ctype = &u
  47604. m.addctype = nil
  47605. }
  47606. // Ctype returns the value of the "ctype" field in the mutation.
  47607. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47608. v := m.ctype
  47609. if v == nil {
  47610. return
  47611. }
  47612. return *v, true
  47613. }
  47614. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47615. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47617. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47618. if !m.op.Is(OpUpdateOne) {
  47619. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47620. }
  47621. if m.id == nil || m.oldValue == nil {
  47622. return v, errors.New("OldCtype requires an ID field in the mutation")
  47623. }
  47624. oldValue, err := m.oldValue(ctx)
  47625. if err != nil {
  47626. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47627. }
  47628. return oldValue.Ctype, nil
  47629. }
  47630. // AddCtype adds u to the "ctype" field.
  47631. func (m *WxMutation) AddCtype(u int64) {
  47632. if m.addctype != nil {
  47633. *m.addctype += u
  47634. } else {
  47635. m.addctype = &u
  47636. }
  47637. }
  47638. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  47639. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  47640. v := m.addctype
  47641. if v == nil {
  47642. return
  47643. }
  47644. return *v, true
  47645. }
  47646. // ClearCtype clears the value of the "ctype" field.
  47647. func (m *WxMutation) ClearCtype() {
  47648. m.ctype = nil
  47649. m.addctype = nil
  47650. m.clearedFields[wx.FieldCtype] = struct{}{}
  47651. }
  47652. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  47653. func (m *WxMutation) CtypeCleared() bool {
  47654. _, ok := m.clearedFields[wx.FieldCtype]
  47655. return ok
  47656. }
  47657. // ResetCtype resets all changes to the "ctype" field.
  47658. func (m *WxMutation) ResetCtype() {
  47659. m.ctype = nil
  47660. m.addctype = nil
  47661. delete(m.clearedFields, wx.FieldCtype)
  47662. }
  47663. // ClearServer clears the "server" edge to the Server entity.
  47664. func (m *WxMutation) ClearServer() {
  47665. m.clearedserver = true
  47666. m.clearedFields[wx.FieldServerID] = struct{}{}
  47667. }
  47668. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  47669. func (m *WxMutation) ServerCleared() bool {
  47670. return m.ServerIDCleared() || m.clearedserver
  47671. }
  47672. // ServerIDs returns the "server" edge IDs in the mutation.
  47673. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47674. // ServerID instead. It exists only for internal usage by the builders.
  47675. func (m *WxMutation) ServerIDs() (ids []uint64) {
  47676. if id := m.server; id != nil {
  47677. ids = append(ids, *id)
  47678. }
  47679. return
  47680. }
  47681. // ResetServer resets all changes to the "server" edge.
  47682. func (m *WxMutation) ResetServer() {
  47683. m.server = nil
  47684. m.clearedserver = false
  47685. }
  47686. // ClearAgent clears the "agent" edge to the Agent entity.
  47687. func (m *WxMutation) ClearAgent() {
  47688. m.clearedagent = true
  47689. m.clearedFields[wx.FieldAgentID] = struct{}{}
  47690. }
  47691. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47692. func (m *WxMutation) AgentCleared() bool {
  47693. return m.clearedagent
  47694. }
  47695. // AgentIDs returns the "agent" edge IDs in the mutation.
  47696. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47697. // AgentID instead. It exists only for internal usage by the builders.
  47698. func (m *WxMutation) AgentIDs() (ids []uint64) {
  47699. if id := m.agent; id != nil {
  47700. ids = append(ids, *id)
  47701. }
  47702. return
  47703. }
  47704. // ResetAgent resets all changes to the "agent" edge.
  47705. func (m *WxMutation) ResetAgent() {
  47706. m.agent = nil
  47707. m.clearedagent = false
  47708. }
  47709. // Where appends a list predicates to the WxMutation builder.
  47710. func (m *WxMutation) Where(ps ...predicate.Wx) {
  47711. m.predicates = append(m.predicates, ps...)
  47712. }
  47713. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  47714. // users can use type-assertion to append predicates that do not depend on any generated package.
  47715. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  47716. p := make([]predicate.Wx, len(ps))
  47717. for i := range ps {
  47718. p[i] = ps[i]
  47719. }
  47720. m.Where(p...)
  47721. }
  47722. // Op returns the operation name.
  47723. func (m *WxMutation) Op() Op {
  47724. return m.op
  47725. }
  47726. // SetOp allows setting the mutation operation.
  47727. func (m *WxMutation) SetOp(op Op) {
  47728. m.op = op
  47729. }
  47730. // Type returns the node type of this mutation (Wx).
  47731. func (m *WxMutation) Type() string {
  47732. return m.typ
  47733. }
  47734. // Fields returns all fields that were changed during this mutation. Note that in
  47735. // order to get all numeric fields that were incremented/decremented, call
  47736. // AddedFields().
  47737. func (m *WxMutation) Fields() []string {
  47738. fields := make([]string, 0, 22)
  47739. if m.created_at != nil {
  47740. fields = append(fields, wx.FieldCreatedAt)
  47741. }
  47742. if m.updated_at != nil {
  47743. fields = append(fields, wx.FieldUpdatedAt)
  47744. }
  47745. if m.status != nil {
  47746. fields = append(fields, wx.FieldStatus)
  47747. }
  47748. if m.deleted_at != nil {
  47749. fields = append(fields, wx.FieldDeletedAt)
  47750. }
  47751. if m.server != nil {
  47752. fields = append(fields, wx.FieldServerID)
  47753. }
  47754. if m.port != nil {
  47755. fields = append(fields, wx.FieldPort)
  47756. }
  47757. if m.process_id != nil {
  47758. fields = append(fields, wx.FieldProcessID)
  47759. }
  47760. if m.callback != nil {
  47761. fields = append(fields, wx.FieldCallback)
  47762. }
  47763. if m.wxid != nil {
  47764. fields = append(fields, wx.FieldWxid)
  47765. }
  47766. if m.account != nil {
  47767. fields = append(fields, wx.FieldAccount)
  47768. }
  47769. if m.nickname != nil {
  47770. fields = append(fields, wx.FieldNickname)
  47771. }
  47772. if m.tel != nil {
  47773. fields = append(fields, wx.FieldTel)
  47774. }
  47775. if m.head_big != nil {
  47776. fields = append(fields, wx.FieldHeadBig)
  47777. }
  47778. if m.organization_id != nil {
  47779. fields = append(fields, wx.FieldOrganizationID)
  47780. }
  47781. if m.agent != nil {
  47782. fields = append(fields, wx.FieldAgentID)
  47783. }
  47784. if m.api_base != nil {
  47785. fields = append(fields, wx.FieldAPIBase)
  47786. }
  47787. if m.api_key != nil {
  47788. fields = append(fields, wx.FieldAPIKey)
  47789. }
  47790. if m.allow_list != nil {
  47791. fields = append(fields, wx.FieldAllowList)
  47792. }
  47793. if m.group_allow_list != nil {
  47794. fields = append(fields, wx.FieldGroupAllowList)
  47795. }
  47796. if m.block_list != nil {
  47797. fields = append(fields, wx.FieldBlockList)
  47798. }
  47799. if m.group_block_list != nil {
  47800. fields = append(fields, wx.FieldGroupBlockList)
  47801. }
  47802. if m.ctype != nil {
  47803. fields = append(fields, wx.FieldCtype)
  47804. }
  47805. return fields
  47806. }
  47807. // Field returns the value of a field with the given name. The second boolean
  47808. // return value indicates that this field was not set, or was not defined in the
  47809. // schema.
  47810. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  47811. switch name {
  47812. case wx.FieldCreatedAt:
  47813. return m.CreatedAt()
  47814. case wx.FieldUpdatedAt:
  47815. return m.UpdatedAt()
  47816. case wx.FieldStatus:
  47817. return m.Status()
  47818. case wx.FieldDeletedAt:
  47819. return m.DeletedAt()
  47820. case wx.FieldServerID:
  47821. return m.ServerID()
  47822. case wx.FieldPort:
  47823. return m.Port()
  47824. case wx.FieldProcessID:
  47825. return m.ProcessID()
  47826. case wx.FieldCallback:
  47827. return m.Callback()
  47828. case wx.FieldWxid:
  47829. return m.Wxid()
  47830. case wx.FieldAccount:
  47831. return m.Account()
  47832. case wx.FieldNickname:
  47833. return m.Nickname()
  47834. case wx.FieldTel:
  47835. return m.Tel()
  47836. case wx.FieldHeadBig:
  47837. return m.HeadBig()
  47838. case wx.FieldOrganizationID:
  47839. return m.OrganizationID()
  47840. case wx.FieldAgentID:
  47841. return m.AgentID()
  47842. case wx.FieldAPIBase:
  47843. return m.APIBase()
  47844. case wx.FieldAPIKey:
  47845. return m.APIKey()
  47846. case wx.FieldAllowList:
  47847. return m.AllowList()
  47848. case wx.FieldGroupAllowList:
  47849. return m.GroupAllowList()
  47850. case wx.FieldBlockList:
  47851. return m.BlockList()
  47852. case wx.FieldGroupBlockList:
  47853. return m.GroupBlockList()
  47854. case wx.FieldCtype:
  47855. return m.Ctype()
  47856. }
  47857. return nil, false
  47858. }
  47859. // OldField returns the old value of the field from the database. An error is
  47860. // returned if the mutation operation is not UpdateOne, or the query to the
  47861. // database failed.
  47862. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47863. switch name {
  47864. case wx.FieldCreatedAt:
  47865. return m.OldCreatedAt(ctx)
  47866. case wx.FieldUpdatedAt:
  47867. return m.OldUpdatedAt(ctx)
  47868. case wx.FieldStatus:
  47869. return m.OldStatus(ctx)
  47870. case wx.FieldDeletedAt:
  47871. return m.OldDeletedAt(ctx)
  47872. case wx.FieldServerID:
  47873. return m.OldServerID(ctx)
  47874. case wx.FieldPort:
  47875. return m.OldPort(ctx)
  47876. case wx.FieldProcessID:
  47877. return m.OldProcessID(ctx)
  47878. case wx.FieldCallback:
  47879. return m.OldCallback(ctx)
  47880. case wx.FieldWxid:
  47881. return m.OldWxid(ctx)
  47882. case wx.FieldAccount:
  47883. return m.OldAccount(ctx)
  47884. case wx.FieldNickname:
  47885. return m.OldNickname(ctx)
  47886. case wx.FieldTel:
  47887. return m.OldTel(ctx)
  47888. case wx.FieldHeadBig:
  47889. return m.OldHeadBig(ctx)
  47890. case wx.FieldOrganizationID:
  47891. return m.OldOrganizationID(ctx)
  47892. case wx.FieldAgentID:
  47893. return m.OldAgentID(ctx)
  47894. case wx.FieldAPIBase:
  47895. return m.OldAPIBase(ctx)
  47896. case wx.FieldAPIKey:
  47897. return m.OldAPIKey(ctx)
  47898. case wx.FieldAllowList:
  47899. return m.OldAllowList(ctx)
  47900. case wx.FieldGroupAllowList:
  47901. return m.OldGroupAllowList(ctx)
  47902. case wx.FieldBlockList:
  47903. return m.OldBlockList(ctx)
  47904. case wx.FieldGroupBlockList:
  47905. return m.OldGroupBlockList(ctx)
  47906. case wx.FieldCtype:
  47907. return m.OldCtype(ctx)
  47908. }
  47909. return nil, fmt.Errorf("unknown Wx field %s", name)
  47910. }
  47911. // SetField sets the value of a field with the given name. It returns an error if
  47912. // the field is not defined in the schema, or if the type mismatched the field
  47913. // type.
  47914. func (m *WxMutation) SetField(name string, value ent.Value) error {
  47915. switch name {
  47916. case wx.FieldCreatedAt:
  47917. v, ok := value.(time.Time)
  47918. if !ok {
  47919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47920. }
  47921. m.SetCreatedAt(v)
  47922. return nil
  47923. case wx.FieldUpdatedAt:
  47924. v, ok := value.(time.Time)
  47925. if !ok {
  47926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47927. }
  47928. m.SetUpdatedAt(v)
  47929. return nil
  47930. case wx.FieldStatus:
  47931. v, ok := value.(uint8)
  47932. if !ok {
  47933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47934. }
  47935. m.SetStatus(v)
  47936. return nil
  47937. case wx.FieldDeletedAt:
  47938. v, ok := value.(time.Time)
  47939. if !ok {
  47940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47941. }
  47942. m.SetDeletedAt(v)
  47943. return nil
  47944. case wx.FieldServerID:
  47945. v, ok := value.(uint64)
  47946. if !ok {
  47947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47948. }
  47949. m.SetServerID(v)
  47950. return nil
  47951. case wx.FieldPort:
  47952. v, ok := value.(string)
  47953. if !ok {
  47954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47955. }
  47956. m.SetPort(v)
  47957. return nil
  47958. case wx.FieldProcessID:
  47959. v, ok := value.(string)
  47960. if !ok {
  47961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47962. }
  47963. m.SetProcessID(v)
  47964. return nil
  47965. case wx.FieldCallback:
  47966. v, ok := value.(string)
  47967. if !ok {
  47968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47969. }
  47970. m.SetCallback(v)
  47971. return nil
  47972. case wx.FieldWxid:
  47973. v, ok := value.(string)
  47974. if !ok {
  47975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47976. }
  47977. m.SetWxid(v)
  47978. return nil
  47979. case wx.FieldAccount:
  47980. v, ok := value.(string)
  47981. if !ok {
  47982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47983. }
  47984. m.SetAccount(v)
  47985. return nil
  47986. case wx.FieldNickname:
  47987. v, ok := value.(string)
  47988. if !ok {
  47989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47990. }
  47991. m.SetNickname(v)
  47992. return nil
  47993. case wx.FieldTel:
  47994. v, ok := value.(string)
  47995. if !ok {
  47996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47997. }
  47998. m.SetTel(v)
  47999. return nil
  48000. case wx.FieldHeadBig:
  48001. v, ok := value.(string)
  48002. if !ok {
  48003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48004. }
  48005. m.SetHeadBig(v)
  48006. return nil
  48007. case wx.FieldOrganizationID:
  48008. v, ok := value.(uint64)
  48009. if !ok {
  48010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48011. }
  48012. m.SetOrganizationID(v)
  48013. return nil
  48014. case wx.FieldAgentID:
  48015. v, ok := value.(uint64)
  48016. if !ok {
  48017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48018. }
  48019. m.SetAgentID(v)
  48020. return nil
  48021. case wx.FieldAPIBase:
  48022. v, ok := value.(string)
  48023. if !ok {
  48024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48025. }
  48026. m.SetAPIBase(v)
  48027. return nil
  48028. case wx.FieldAPIKey:
  48029. v, ok := value.(string)
  48030. if !ok {
  48031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48032. }
  48033. m.SetAPIKey(v)
  48034. return nil
  48035. case wx.FieldAllowList:
  48036. v, ok := value.([]string)
  48037. if !ok {
  48038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48039. }
  48040. m.SetAllowList(v)
  48041. return nil
  48042. case wx.FieldGroupAllowList:
  48043. v, ok := value.([]string)
  48044. if !ok {
  48045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48046. }
  48047. m.SetGroupAllowList(v)
  48048. return nil
  48049. case wx.FieldBlockList:
  48050. v, ok := value.([]string)
  48051. if !ok {
  48052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48053. }
  48054. m.SetBlockList(v)
  48055. return nil
  48056. case wx.FieldGroupBlockList:
  48057. v, ok := value.([]string)
  48058. if !ok {
  48059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48060. }
  48061. m.SetGroupBlockList(v)
  48062. return nil
  48063. case wx.FieldCtype:
  48064. v, ok := value.(uint64)
  48065. if !ok {
  48066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48067. }
  48068. m.SetCtype(v)
  48069. return nil
  48070. }
  48071. return fmt.Errorf("unknown Wx field %s", name)
  48072. }
  48073. // AddedFields returns all numeric fields that were incremented/decremented during
  48074. // this mutation.
  48075. func (m *WxMutation) AddedFields() []string {
  48076. var fields []string
  48077. if m.addstatus != nil {
  48078. fields = append(fields, wx.FieldStatus)
  48079. }
  48080. if m.addorganization_id != nil {
  48081. fields = append(fields, wx.FieldOrganizationID)
  48082. }
  48083. if m.addctype != nil {
  48084. fields = append(fields, wx.FieldCtype)
  48085. }
  48086. return fields
  48087. }
  48088. // AddedField returns the numeric value that was incremented/decremented on a field
  48089. // with the given name. The second boolean return value indicates that this field
  48090. // was not set, or was not defined in the schema.
  48091. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48092. switch name {
  48093. case wx.FieldStatus:
  48094. return m.AddedStatus()
  48095. case wx.FieldOrganizationID:
  48096. return m.AddedOrganizationID()
  48097. case wx.FieldCtype:
  48098. return m.AddedCtype()
  48099. }
  48100. return nil, false
  48101. }
  48102. // AddField adds the value to the field with the given name. It returns an error if
  48103. // the field is not defined in the schema, or if the type mismatched the field
  48104. // type.
  48105. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48106. switch name {
  48107. case wx.FieldStatus:
  48108. v, ok := value.(int8)
  48109. if !ok {
  48110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48111. }
  48112. m.AddStatus(v)
  48113. return nil
  48114. case wx.FieldOrganizationID:
  48115. v, ok := value.(int64)
  48116. if !ok {
  48117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48118. }
  48119. m.AddOrganizationID(v)
  48120. return nil
  48121. case wx.FieldCtype:
  48122. v, ok := value.(int64)
  48123. if !ok {
  48124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48125. }
  48126. m.AddCtype(v)
  48127. return nil
  48128. }
  48129. return fmt.Errorf("unknown Wx numeric field %s", name)
  48130. }
  48131. // ClearedFields returns all nullable fields that were cleared during this
  48132. // mutation.
  48133. func (m *WxMutation) ClearedFields() []string {
  48134. var fields []string
  48135. if m.FieldCleared(wx.FieldStatus) {
  48136. fields = append(fields, wx.FieldStatus)
  48137. }
  48138. if m.FieldCleared(wx.FieldDeletedAt) {
  48139. fields = append(fields, wx.FieldDeletedAt)
  48140. }
  48141. if m.FieldCleared(wx.FieldServerID) {
  48142. fields = append(fields, wx.FieldServerID)
  48143. }
  48144. if m.FieldCleared(wx.FieldOrganizationID) {
  48145. fields = append(fields, wx.FieldOrganizationID)
  48146. }
  48147. if m.FieldCleared(wx.FieldAPIBase) {
  48148. fields = append(fields, wx.FieldAPIBase)
  48149. }
  48150. if m.FieldCleared(wx.FieldAPIKey) {
  48151. fields = append(fields, wx.FieldAPIKey)
  48152. }
  48153. if m.FieldCleared(wx.FieldCtype) {
  48154. fields = append(fields, wx.FieldCtype)
  48155. }
  48156. return fields
  48157. }
  48158. // FieldCleared returns a boolean indicating if a field with the given name was
  48159. // cleared in this mutation.
  48160. func (m *WxMutation) FieldCleared(name string) bool {
  48161. _, ok := m.clearedFields[name]
  48162. return ok
  48163. }
  48164. // ClearField clears the value of the field with the given name. It returns an
  48165. // error if the field is not defined in the schema.
  48166. func (m *WxMutation) ClearField(name string) error {
  48167. switch name {
  48168. case wx.FieldStatus:
  48169. m.ClearStatus()
  48170. return nil
  48171. case wx.FieldDeletedAt:
  48172. m.ClearDeletedAt()
  48173. return nil
  48174. case wx.FieldServerID:
  48175. m.ClearServerID()
  48176. return nil
  48177. case wx.FieldOrganizationID:
  48178. m.ClearOrganizationID()
  48179. return nil
  48180. case wx.FieldAPIBase:
  48181. m.ClearAPIBase()
  48182. return nil
  48183. case wx.FieldAPIKey:
  48184. m.ClearAPIKey()
  48185. return nil
  48186. case wx.FieldCtype:
  48187. m.ClearCtype()
  48188. return nil
  48189. }
  48190. return fmt.Errorf("unknown Wx nullable field %s", name)
  48191. }
  48192. // ResetField resets all changes in the mutation for the field with the given name.
  48193. // It returns an error if the field is not defined in the schema.
  48194. func (m *WxMutation) ResetField(name string) error {
  48195. switch name {
  48196. case wx.FieldCreatedAt:
  48197. m.ResetCreatedAt()
  48198. return nil
  48199. case wx.FieldUpdatedAt:
  48200. m.ResetUpdatedAt()
  48201. return nil
  48202. case wx.FieldStatus:
  48203. m.ResetStatus()
  48204. return nil
  48205. case wx.FieldDeletedAt:
  48206. m.ResetDeletedAt()
  48207. return nil
  48208. case wx.FieldServerID:
  48209. m.ResetServerID()
  48210. return nil
  48211. case wx.FieldPort:
  48212. m.ResetPort()
  48213. return nil
  48214. case wx.FieldProcessID:
  48215. m.ResetProcessID()
  48216. return nil
  48217. case wx.FieldCallback:
  48218. m.ResetCallback()
  48219. return nil
  48220. case wx.FieldWxid:
  48221. m.ResetWxid()
  48222. return nil
  48223. case wx.FieldAccount:
  48224. m.ResetAccount()
  48225. return nil
  48226. case wx.FieldNickname:
  48227. m.ResetNickname()
  48228. return nil
  48229. case wx.FieldTel:
  48230. m.ResetTel()
  48231. return nil
  48232. case wx.FieldHeadBig:
  48233. m.ResetHeadBig()
  48234. return nil
  48235. case wx.FieldOrganizationID:
  48236. m.ResetOrganizationID()
  48237. return nil
  48238. case wx.FieldAgentID:
  48239. m.ResetAgentID()
  48240. return nil
  48241. case wx.FieldAPIBase:
  48242. m.ResetAPIBase()
  48243. return nil
  48244. case wx.FieldAPIKey:
  48245. m.ResetAPIKey()
  48246. return nil
  48247. case wx.FieldAllowList:
  48248. m.ResetAllowList()
  48249. return nil
  48250. case wx.FieldGroupAllowList:
  48251. m.ResetGroupAllowList()
  48252. return nil
  48253. case wx.FieldBlockList:
  48254. m.ResetBlockList()
  48255. return nil
  48256. case wx.FieldGroupBlockList:
  48257. m.ResetGroupBlockList()
  48258. return nil
  48259. case wx.FieldCtype:
  48260. m.ResetCtype()
  48261. return nil
  48262. }
  48263. return fmt.Errorf("unknown Wx field %s", name)
  48264. }
  48265. // AddedEdges returns all edge names that were set/added in this mutation.
  48266. func (m *WxMutation) AddedEdges() []string {
  48267. edges := make([]string, 0, 2)
  48268. if m.server != nil {
  48269. edges = append(edges, wx.EdgeServer)
  48270. }
  48271. if m.agent != nil {
  48272. edges = append(edges, wx.EdgeAgent)
  48273. }
  48274. return edges
  48275. }
  48276. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48277. // name in this mutation.
  48278. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48279. switch name {
  48280. case wx.EdgeServer:
  48281. if id := m.server; id != nil {
  48282. return []ent.Value{*id}
  48283. }
  48284. case wx.EdgeAgent:
  48285. if id := m.agent; id != nil {
  48286. return []ent.Value{*id}
  48287. }
  48288. }
  48289. return nil
  48290. }
  48291. // RemovedEdges returns all edge names that were removed in this mutation.
  48292. func (m *WxMutation) RemovedEdges() []string {
  48293. edges := make([]string, 0, 2)
  48294. return edges
  48295. }
  48296. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48297. // the given name in this mutation.
  48298. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48299. return nil
  48300. }
  48301. // ClearedEdges returns all edge names that were cleared in this mutation.
  48302. func (m *WxMutation) ClearedEdges() []string {
  48303. edges := make([]string, 0, 2)
  48304. if m.clearedserver {
  48305. edges = append(edges, wx.EdgeServer)
  48306. }
  48307. if m.clearedagent {
  48308. edges = append(edges, wx.EdgeAgent)
  48309. }
  48310. return edges
  48311. }
  48312. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48313. // was cleared in this mutation.
  48314. func (m *WxMutation) EdgeCleared(name string) bool {
  48315. switch name {
  48316. case wx.EdgeServer:
  48317. return m.clearedserver
  48318. case wx.EdgeAgent:
  48319. return m.clearedagent
  48320. }
  48321. return false
  48322. }
  48323. // ClearEdge clears the value of the edge with the given name. It returns an error
  48324. // if that edge is not defined in the schema.
  48325. func (m *WxMutation) ClearEdge(name string) error {
  48326. switch name {
  48327. case wx.EdgeServer:
  48328. m.ClearServer()
  48329. return nil
  48330. case wx.EdgeAgent:
  48331. m.ClearAgent()
  48332. return nil
  48333. }
  48334. return fmt.Errorf("unknown Wx unique edge %s", name)
  48335. }
  48336. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48337. // It returns an error if the edge is not defined in the schema.
  48338. func (m *WxMutation) ResetEdge(name string) error {
  48339. switch name {
  48340. case wx.EdgeServer:
  48341. m.ResetServer()
  48342. return nil
  48343. case wx.EdgeAgent:
  48344. m.ResetAgent()
  48345. return nil
  48346. }
  48347. return fmt.Errorf("unknown Wx edge %s", name)
  48348. }
  48349. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48350. type WxCardMutation struct {
  48351. config
  48352. op Op
  48353. typ string
  48354. id *uint64
  48355. created_at *time.Time
  48356. updated_at *time.Time
  48357. deleted_at *time.Time
  48358. user_id *uint64
  48359. adduser_id *int64
  48360. wx_user_id *uint64
  48361. addwx_user_id *int64
  48362. avatar *string
  48363. logo *string
  48364. name *string
  48365. company *string
  48366. address *string
  48367. phone *string
  48368. official_account *string
  48369. wechat_account *string
  48370. email *string
  48371. api_base *string
  48372. api_key *string
  48373. ai_info *string
  48374. intro *string
  48375. clearedFields map[string]struct{}
  48376. done bool
  48377. oldValue func(context.Context) (*WxCard, error)
  48378. predicates []predicate.WxCard
  48379. }
  48380. var _ ent.Mutation = (*WxCardMutation)(nil)
  48381. // wxcardOption allows management of the mutation configuration using functional options.
  48382. type wxcardOption func(*WxCardMutation)
  48383. // newWxCardMutation creates new mutation for the WxCard entity.
  48384. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48385. m := &WxCardMutation{
  48386. config: c,
  48387. op: op,
  48388. typ: TypeWxCard,
  48389. clearedFields: make(map[string]struct{}),
  48390. }
  48391. for _, opt := range opts {
  48392. opt(m)
  48393. }
  48394. return m
  48395. }
  48396. // withWxCardID sets the ID field of the mutation.
  48397. func withWxCardID(id uint64) wxcardOption {
  48398. return func(m *WxCardMutation) {
  48399. var (
  48400. err error
  48401. once sync.Once
  48402. value *WxCard
  48403. )
  48404. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48405. once.Do(func() {
  48406. if m.done {
  48407. err = errors.New("querying old values post mutation is not allowed")
  48408. } else {
  48409. value, err = m.Client().WxCard.Get(ctx, id)
  48410. }
  48411. })
  48412. return value, err
  48413. }
  48414. m.id = &id
  48415. }
  48416. }
  48417. // withWxCard sets the old WxCard of the mutation.
  48418. func withWxCard(node *WxCard) wxcardOption {
  48419. return func(m *WxCardMutation) {
  48420. m.oldValue = func(context.Context) (*WxCard, error) {
  48421. return node, nil
  48422. }
  48423. m.id = &node.ID
  48424. }
  48425. }
  48426. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48427. // executed in a transaction (ent.Tx), a transactional client is returned.
  48428. func (m WxCardMutation) Client() *Client {
  48429. client := &Client{config: m.config}
  48430. client.init()
  48431. return client
  48432. }
  48433. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48434. // it returns an error otherwise.
  48435. func (m WxCardMutation) Tx() (*Tx, error) {
  48436. if _, ok := m.driver.(*txDriver); !ok {
  48437. return nil, errors.New("ent: mutation is not running in a transaction")
  48438. }
  48439. tx := &Tx{config: m.config}
  48440. tx.init()
  48441. return tx, nil
  48442. }
  48443. // SetID sets the value of the id field. Note that this
  48444. // operation is only accepted on creation of WxCard entities.
  48445. func (m *WxCardMutation) SetID(id uint64) {
  48446. m.id = &id
  48447. }
  48448. // ID returns the ID value in the mutation. Note that the ID is only available
  48449. // if it was provided to the builder or after it was returned from the database.
  48450. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48451. if m.id == nil {
  48452. return
  48453. }
  48454. return *m.id, true
  48455. }
  48456. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48457. // That means, if the mutation is applied within a transaction with an isolation level such
  48458. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48459. // or updated by the mutation.
  48460. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48461. switch {
  48462. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48463. id, exists := m.ID()
  48464. if exists {
  48465. return []uint64{id}, nil
  48466. }
  48467. fallthrough
  48468. case m.op.Is(OpUpdate | OpDelete):
  48469. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48470. default:
  48471. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48472. }
  48473. }
  48474. // SetCreatedAt sets the "created_at" field.
  48475. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48476. m.created_at = &t
  48477. }
  48478. // CreatedAt returns the value of the "created_at" field in the mutation.
  48479. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48480. v := m.created_at
  48481. if v == nil {
  48482. return
  48483. }
  48484. return *v, true
  48485. }
  48486. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48487. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48489. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48490. if !m.op.Is(OpUpdateOne) {
  48491. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48492. }
  48493. if m.id == nil || m.oldValue == nil {
  48494. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48495. }
  48496. oldValue, err := m.oldValue(ctx)
  48497. if err != nil {
  48498. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48499. }
  48500. return oldValue.CreatedAt, nil
  48501. }
  48502. // ResetCreatedAt resets all changes to the "created_at" field.
  48503. func (m *WxCardMutation) ResetCreatedAt() {
  48504. m.created_at = nil
  48505. }
  48506. // SetUpdatedAt sets the "updated_at" field.
  48507. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48508. m.updated_at = &t
  48509. }
  48510. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48511. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48512. v := m.updated_at
  48513. if v == nil {
  48514. return
  48515. }
  48516. return *v, true
  48517. }
  48518. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48519. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48521. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48522. if !m.op.Is(OpUpdateOne) {
  48523. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48524. }
  48525. if m.id == nil || m.oldValue == nil {
  48526. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48527. }
  48528. oldValue, err := m.oldValue(ctx)
  48529. if err != nil {
  48530. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48531. }
  48532. return oldValue.UpdatedAt, nil
  48533. }
  48534. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48535. func (m *WxCardMutation) ResetUpdatedAt() {
  48536. m.updated_at = nil
  48537. }
  48538. // SetDeletedAt sets the "deleted_at" field.
  48539. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48540. m.deleted_at = &t
  48541. }
  48542. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48543. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48544. v := m.deleted_at
  48545. if v == nil {
  48546. return
  48547. }
  48548. return *v, true
  48549. }
  48550. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48551. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48553. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48554. if !m.op.Is(OpUpdateOne) {
  48555. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48556. }
  48557. if m.id == nil || m.oldValue == nil {
  48558. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48559. }
  48560. oldValue, err := m.oldValue(ctx)
  48561. if err != nil {
  48562. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48563. }
  48564. return oldValue.DeletedAt, nil
  48565. }
  48566. // ClearDeletedAt clears the value of the "deleted_at" field.
  48567. func (m *WxCardMutation) ClearDeletedAt() {
  48568. m.deleted_at = nil
  48569. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48570. }
  48571. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48572. func (m *WxCardMutation) DeletedAtCleared() bool {
  48573. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48574. return ok
  48575. }
  48576. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48577. func (m *WxCardMutation) ResetDeletedAt() {
  48578. m.deleted_at = nil
  48579. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48580. }
  48581. // SetUserID sets the "user_id" field.
  48582. func (m *WxCardMutation) SetUserID(u uint64) {
  48583. m.user_id = &u
  48584. m.adduser_id = nil
  48585. }
  48586. // UserID returns the value of the "user_id" field in the mutation.
  48587. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48588. v := m.user_id
  48589. if v == nil {
  48590. return
  48591. }
  48592. return *v, true
  48593. }
  48594. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48595. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48597. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48598. if !m.op.Is(OpUpdateOne) {
  48599. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48600. }
  48601. if m.id == nil || m.oldValue == nil {
  48602. return v, errors.New("OldUserID requires an ID field in the mutation")
  48603. }
  48604. oldValue, err := m.oldValue(ctx)
  48605. if err != nil {
  48606. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48607. }
  48608. return oldValue.UserID, nil
  48609. }
  48610. // AddUserID adds u to the "user_id" field.
  48611. func (m *WxCardMutation) AddUserID(u int64) {
  48612. if m.adduser_id != nil {
  48613. *m.adduser_id += u
  48614. } else {
  48615. m.adduser_id = &u
  48616. }
  48617. }
  48618. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48619. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48620. v := m.adduser_id
  48621. if v == nil {
  48622. return
  48623. }
  48624. return *v, true
  48625. }
  48626. // ClearUserID clears the value of the "user_id" field.
  48627. func (m *WxCardMutation) ClearUserID() {
  48628. m.user_id = nil
  48629. m.adduser_id = nil
  48630. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48631. }
  48632. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48633. func (m *WxCardMutation) UserIDCleared() bool {
  48634. _, ok := m.clearedFields[wxcard.FieldUserID]
  48635. return ok
  48636. }
  48637. // ResetUserID resets all changes to the "user_id" field.
  48638. func (m *WxCardMutation) ResetUserID() {
  48639. m.user_id = nil
  48640. m.adduser_id = nil
  48641. delete(m.clearedFields, wxcard.FieldUserID)
  48642. }
  48643. // SetWxUserID sets the "wx_user_id" field.
  48644. func (m *WxCardMutation) SetWxUserID(u uint64) {
  48645. m.wx_user_id = &u
  48646. m.addwx_user_id = nil
  48647. }
  48648. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  48649. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  48650. v := m.wx_user_id
  48651. if v == nil {
  48652. return
  48653. }
  48654. return *v, true
  48655. }
  48656. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  48657. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48659. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  48660. if !m.op.Is(OpUpdateOne) {
  48661. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  48662. }
  48663. if m.id == nil || m.oldValue == nil {
  48664. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  48665. }
  48666. oldValue, err := m.oldValue(ctx)
  48667. if err != nil {
  48668. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  48669. }
  48670. return oldValue.WxUserID, nil
  48671. }
  48672. // AddWxUserID adds u to the "wx_user_id" field.
  48673. func (m *WxCardMutation) AddWxUserID(u int64) {
  48674. if m.addwx_user_id != nil {
  48675. *m.addwx_user_id += u
  48676. } else {
  48677. m.addwx_user_id = &u
  48678. }
  48679. }
  48680. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  48681. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  48682. v := m.addwx_user_id
  48683. if v == nil {
  48684. return
  48685. }
  48686. return *v, true
  48687. }
  48688. // ClearWxUserID clears the value of the "wx_user_id" field.
  48689. func (m *WxCardMutation) ClearWxUserID() {
  48690. m.wx_user_id = nil
  48691. m.addwx_user_id = nil
  48692. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  48693. }
  48694. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  48695. func (m *WxCardMutation) WxUserIDCleared() bool {
  48696. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  48697. return ok
  48698. }
  48699. // ResetWxUserID resets all changes to the "wx_user_id" field.
  48700. func (m *WxCardMutation) ResetWxUserID() {
  48701. m.wx_user_id = nil
  48702. m.addwx_user_id = nil
  48703. delete(m.clearedFields, wxcard.FieldWxUserID)
  48704. }
  48705. // SetAvatar sets the "avatar" field.
  48706. func (m *WxCardMutation) SetAvatar(s string) {
  48707. m.avatar = &s
  48708. }
  48709. // Avatar returns the value of the "avatar" field in the mutation.
  48710. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  48711. v := m.avatar
  48712. if v == nil {
  48713. return
  48714. }
  48715. return *v, true
  48716. }
  48717. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  48718. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48720. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48721. if !m.op.Is(OpUpdateOne) {
  48722. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48723. }
  48724. if m.id == nil || m.oldValue == nil {
  48725. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48726. }
  48727. oldValue, err := m.oldValue(ctx)
  48728. if err != nil {
  48729. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48730. }
  48731. return oldValue.Avatar, nil
  48732. }
  48733. // ResetAvatar resets all changes to the "avatar" field.
  48734. func (m *WxCardMutation) ResetAvatar() {
  48735. m.avatar = nil
  48736. }
  48737. // SetLogo sets the "logo" field.
  48738. func (m *WxCardMutation) SetLogo(s string) {
  48739. m.logo = &s
  48740. }
  48741. // Logo returns the value of the "logo" field in the mutation.
  48742. func (m *WxCardMutation) Logo() (r string, exists bool) {
  48743. v := m.logo
  48744. if v == nil {
  48745. return
  48746. }
  48747. return *v, true
  48748. }
  48749. // OldLogo returns the old "logo" field's value of the WxCard entity.
  48750. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48752. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  48753. if !m.op.Is(OpUpdateOne) {
  48754. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  48755. }
  48756. if m.id == nil || m.oldValue == nil {
  48757. return v, errors.New("OldLogo requires an ID field in the mutation")
  48758. }
  48759. oldValue, err := m.oldValue(ctx)
  48760. if err != nil {
  48761. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  48762. }
  48763. return oldValue.Logo, nil
  48764. }
  48765. // ResetLogo resets all changes to the "logo" field.
  48766. func (m *WxCardMutation) ResetLogo() {
  48767. m.logo = nil
  48768. }
  48769. // SetName sets the "name" field.
  48770. func (m *WxCardMutation) SetName(s string) {
  48771. m.name = &s
  48772. }
  48773. // Name returns the value of the "name" field in the mutation.
  48774. func (m *WxCardMutation) Name() (r string, exists bool) {
  48775. v := m.name
  48776. if v == nil {
  48777. return
  48778. }
  48779. return *v, true
  48780. }
  48781. // OldName returns the old "name" field's value of the WxCard entity.
  48782. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48784. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  48785. if !m.op.Is(OpUpdateOne) {
  48786. return v, errors.New("OldName is only allowed on UpdateOne operations")
  48787. }
  48788. if m.id == nil || m.oldValue == nil {
  48789. return v, errors.New("OldName requires an ID field in the mutation")
  48790. }
  48791. oldValue, err := m.oldValue(ctx)
  48792. if err != nil {
  48793. return v, fmt.Errorf("querying old value for OldName: %w", err)
  48794. }
  48795. return oldValue.Name, nil
  48796. }
  48797. // ResetName resets all changes to the "name" field.
  48798. func (m *WxCardMutation) ResetName() {
  48799. m.name = nil
  48800. }
  48801. // SetCompany sets the "company" field.
  48802. func (m *WxCardMutation) SetCompany(s string) {
  48803. m.company = &s
  48804. }
  48805. // Company returns the value of the "company" field in the mutation.
  48806. func (m *WxCardMutation) Company() (r string, exists bool) {
  48807. v := m.company
  48808. if v == nil {
  48809. return
  48810. }
  48811. return *v, true
  48812. }
  48813. // OldCompany returns the old "company" field's value of the WxCard entity.
  48814. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48816. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  48817. if !m.op.Is(OpUpdateOne) {
  48818. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  48819. }
  48820. if m.id == nil || m.oldValue == nil {
  48821. return v, errors.New("OldCompany requires an ID field in the mutation")
  48822. }
  48823. oldValue, err := m.oldValue(ctx)
  48824. if err != nil {
  48825. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  48826. }
  48827. return oldValue.Company, nil
  48828. }
  48829. // ResetCompany resets all changes to the "company" field.
  48830. func (m *WxCardMutation) ResetCompany() {
  48831. m.company = nil
  48832. }
  48833. // SetAddress sets the "address" field.
  48834. func (m *WxCardMutation) SetAddress(s string) {
  48835. m.address = &s
  48836. }
  48837. // Address returns the value of the "address" field in the mutation.
  48838. func (m *WxCardMutation) Address() (r string, exists bool) {
  48839. v := m.address
  48840. if v == nil {
  48841. return
  48842. }
  48843. return *v, true
  48844. }
  48845. // OldAddress returns the old "address" field's value of the WxCard entity.
  48846. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48848. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  48849. if !m.op.Is(OpUpdateOne) {
  48850. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  48851. }
  48852. if m.id == nil || m.oldValue == nil {
  48853. return v, errors.New("OldAddress requires an ID field in the mutation")
  48854. }
  48855. oldValue, err := m.oldValue(ctx)
  48856. if err != nil {
  48857. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  48858. }
  48859. return oldValue.Address, nil
  48860. }
  48861. // ResetAddress resets all changes to the "address" field.
  48862. func (m *WxCardMutation) ResetAddress() {
  48863. m.address = nil
  48864. }
  48865. // SetPhone sets the "phone" field.
  48866. func (m *WxCardMutation) SetPhone(s string) {
  48867. m.phone = &s
  48868. }
  48869. // Phone returns the value of the "phone" field in the mutation.
  48870. func (m *WxCardMutation) Phone() (r string, exists bool) {
  48871. v := m.phone
  48872. if v == nil {
  48873. return
  48874. }
  48875. return *v, true
  48876. }
  48877. // OldPhone returns the old "phone" field's value of the WxCard entity.
  48878. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48880. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  48881. if !m.op.Is(OpUpdateOne) {
  48882. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  48883. }
  48884. if m.id == nil || m.oldValue == nil {
  48885. return v, errors.New("OldPhone requires an ID field in the mutation")
  48886. }
  48887. oldValue, err := m.oldValue(ctx)
  48888. if err != nil {
  48889. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  48890. }
  48891. return oldValue.Phone, nil
  48892. }
  48893. // ResetPhone resets all changes to the "phone" field.
  48894. func (m *WxCardMutation) ResetPhone() {
  48895. m.phone = nil
  48896. }
  48897. // SetOfficialAccount sets the "official_account" field.
  48898. func (m *WxCardMutation) SetOfficialAccount(s string) {
  48899. m.official_account = &s
  48900. }
  48901. // OfficialAccount returns the value of the "official_account" field in the mutation.
  48902. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  48903. v := m.official_account
  48904. if v == nil {
  48905. return
  48906. }
  48907. return *v, true
  48908. }
  48909. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  48910. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48912. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  48913. if !m.op.Is(OpUpdateOne) {
  48914. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  48915. }
  48916. if m.id == nil || m.oldValue == nil {
  48917. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  48918. }
  48919. oldValue, err := m.oldValue(ctx)
  48920. if err != nil {
  48921. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  48922. }
  48923. return oldValue.OfficialAccount, nil
  48924. }
  48925. // ResetOfficialAccount resets all changes to the "official_account" field.
  48926. func (m *WxCardMutation) ResetOfficialAccount() {
  48927. m.official_account = nil
  48928. }
  48929. // SetWechatAccount sets the "wechat_account" field.
  48930. func (m *WxCardMutation) SetWechatAccount(s string) {
  48931. m.wechat_account = &s
  48932. }
  48933. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  48934. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  48935. v := m.wechat_account
  48936. if v == nil {
  48937. return
  48938. }
  48939. return *v, true
  48940. }
  48941. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  48942. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48944. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  48945. if !m.op.Is(OpUpdateOne) {
  48946. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  48947. }
  48948. if m.id == nil || m.oldValue == nil {
  48949. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  48950. }
  48951. oldValue, err := m.oldValue(ctx)
  48952. if err != nil {
  48953. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  48954. }
  48955. return oldValue.WechatAccount, nil
  48956. }
  48957. // ResetWechatAccount resets all changes to the "wechat_account" field.
  48958. func (m *WxCardMutation) ResetWechatAccount() {
  48959. m.wechat_account = nil
  48960. }
  48961. // SetEmail sets the "email" field.
  48962. func (m *WxCardMutation) SetEmail(s string) {
  48963. m.email = &s
  48964. }
  48965. // Email returns the value of the "email" field in the mutation.
  48966. func (m *WxCardMutation) Email() (r string, exists bool) {
  48967. v := m.email
  48968. if v == nil {
  48969. return
  48970. }
  48971. return *v, true
  48972. }
  48973. // OldEmail returns the old "email" field's value of the WxCard entity.
  48974. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48976. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  48977. if !m.op.Is(OpUpdateOne) {
  48978. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  48979. }
  48980. if m.id == nil || m.oldValue == nil {
  48981. return v, errors.New("OldEmail requires an ID field in the mutation")
  48982. }
  48983. oldValue, err := m.oldValue(ctx)
  48984. if err != nil {
  48985. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  48986. }
  48987. return oldValue.Email, nil
  48988. }
  48989. // ClearEmail clears the value of the "email" field.
  48990. func (m *WxCardMutation) ClearEmail() {
  48991. m.email = nil
  48992. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  48993. }
  48994. // EmailCleared returns if the "email" field was cleared in this mutation.
  48995. func (m *WxCardMutation) EmailCleared() bool {
  48996. _, ok := m.clearedFields[wxcard.FieldEmail]
  48997. return ok
  48998. }
  48999. // ResetEmail resets all changes to the "email" field.
  49000. func (m *WxCardMutation) ResetEmail() {
  49001. m.email = nil
  49002. delete(m.clearedFields, wxcard.FieldEmail)
  49003. }
  49004. // SetAPIBase sets the "api_base" field.
  49005. func (m *WxCardMutation) SetAPIBase(s string) {
  49006. m.api_base = &s
  49007. }
  49008. // APIBase returns the value of the "api_base" field in the mutation.
  49009. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49010. v := m.api_base
  49011. if v == nil {
  49012. return
  49013. }
  49014. return *v, true
  49015. }
  49016. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49017. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49019. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49020. if !m.op.Is(OpUpdateOne) {
  49021. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49022. }
  49023. if m.id == nil || m.oldValue == nil {
  49024. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49025. }
  49026. oldValue, err := m.oldValue(ctx)
  49027. if err != nil {
  49028. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49029. }
  49030. return oldValue.APIBase, nil
  49031. }
  49032. // ClearAPIBase clears the value of the "api_base" field.
  49033. func (m *WxCardMutation) ClearAPIBase() {
  49034. m.api_base = nil
  49035. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49036. }
  49037. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49038. func (m *WxCardMutation) APIBaseCleared() bool {
  49039. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49040. return ok
  49041. }
  49042. // ResetAPIBase resets all changes to the "api_base" field.
  49043. func (m *WxCardMutation) ResetAPIBase() {
  49044. m.api_base = nil
  49045. delete(m.clearedFields, wxcard.FieldAPIBase)
  49046. }
  49047. // SetAPIKey sets the "api_key" field.
  49048. func (m *WxCardMutation) SetAPIKey(s string) {
  49049. m.api_key = &s
  49050. }
  49051. // APIKey returns the value of the "api_key" field in the mutation.
  49052. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49053. v := m.api_key
  49054. if v == nil {
  49055. return
  49056. }
  49057. return *v, true
  49058. }
  49059. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49060. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49062. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49063. if !m.op.Is(OpUpdateOne) {
  49064. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49065. }
  49066. if m.id == nil || m.oldValue == nil {
  49067. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49068. }
  49069. oldValue, err := m.oldValue(ctx)
  49070. if err != nil {
  49071. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49072. }
  49073. return oldValue.APIKey, nil
  49074. }
  49075. // ClearAPIKey clears the value of the "api_key" field.
  49076. func (m *WxCardMutation) ClearAPIKey() {
  49077. m.api_key = nil
  49078. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49079. }
  49080. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49081. func (m *WxCardMutation) APIKeyCleared() bool {
  49082. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49083. return ok
  49084. }
  49085. // ResetAPIKey resets all changes to the "api_key" field.
  49086. func (m *WxCardMutation) ResetAPIKey() {
  49087. m.api_key = nil
  49088. delete(m.clearedFields, wxcard.FieldAPIKey)
  49089. }
  49090. // SetAiInfo sets the "ai_info" field.
  49091. func (m *WxCardMutation) SetAiInfo(s string) {
  49092. m.ai_info = &s
  49093. }
  49094. // AiInfo returns the value of the "ai_info" field in the mutation.
  49095. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49096. v := m.ai_info
  49097. if v == nil {
  49098. return
  49099. }
  49100. return *v, true
  49101. }
  49102. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49103. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49105. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49106. if !m.op.Is(OpUpdateOne) {
  49107. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49108. }
  49109. if m.id == nil || m.oldValue == nil {
  49110. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49111. }
  49112. oldValue, err := m.oldValue(ctx)
  49113. if err != nil {
  49114. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49115. }
  49116. return oldValue.AiInfo, nil
  49117. }
  49118. // ClearAiInfo clears the value of the "ai_info" field.
  49119. func (m *WxCardMutation) ClearAiInfo() {
  49120. m.ai_info = nil
  49121. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49122. }
  49123. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49124. func (m *WxCardMutation) AiInfoCleared() bool {
  49125. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49126. return ok
  49127. }
  49128. // ResetAiInfo resets all changes to the "ai_info" field.
  49129. func (m *WxCardMutation) ResetAiInfo() {
  49130. m.ai_info = nil
  49131. delete(m.clearedFields, wxcard.FieldAiInfo)
  49132. }
  49133. // SetIntro sets the "intro" field.
  49134. func (m *WxCardMutation) SetIntro(s string) {
  49135. m.intro = &s
  49136. }
  49137. // Intro returns the value of the "intro" field in the mutation.
  49138. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49139. v := m.intro
  49140. if v == nil {
  49141. return
  49142. }
  49143. return *v, true
  49144. }
  49145. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49146. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49148. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49149. if !m.op.Is(OpUpdateOne) {
  49150. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49151. }
  49152. if m.id == nil || m.oldValue == nil {
  49153. return v, errors.New("OldIntro requires an ID field in the mutation")
  49154. }
  49155. oldValue, err := m.oldValue(ctx)
  49156. if err != nil {
  49157. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49158. }
  49159. return oldValue.Intro, nil
  49160. }
  49161. // ClearIntro clears the value of the "intro" field.
  49162. func (m *WxCardMutation) ClearIntro() {
  49163. m.intro = nil
  49164. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49165. }
  49166. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49167. func (m *WxCardMutation) IntroCleared() bool {
  49168. _, ok := m.clearedFields[wxcard.FieldIntro]
  49169. return ok
  49170. }
  49171. // ResetIntro resets all changes to the "intro" field.
  49172. func (m *WxCardMutation) ResetIntro() {
  49173. m.intro = nil
  49174. delete(m.clearedFields, wxcard.FieldIntro)
  49175. }
  49176. // Where appends a list predicates to the WxCardMutation builder.
  49177. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49178. m.predicates = append(m.predicates, ps...)
  49179. }
  49180. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49181. // users can use type-assertion to append predicates that do not depend on any generated package.
  49182. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49183. p := make([]predicate.WxCard, len(ps))
  49184. for i := range ps {
  49185. p[i] = ps[i]
  49186. }
  49187. m.Where(p...)
  49188. }
  49189. // Op returns the operation name.
  49190. func (m *WxCardMutation) Op() Op {
  49191. return m.op
  49192. }
  49193. // SetOp allows setting the mutation operation.
  49194. func (m *WxCardMutation) SetOp(op Op) {
  49195. m.op = op
  49196. }
  49197. // Type returns the node type of this mutation (WxCard).
  49198. func (m *WxCardMutation) Type() string {
  49199. return m.typ
  49200. }
  49201. // Fields returns all fields that were changed during this mutation. Note that in
  49202. // order to get all numeric fields that were incremented/decremented, call
  49203. // AddedFields().
  49204. func (m *WxCardMutation) Fields() []string {
  49205. fields := make([]string, 0, 18)
  49206. if m.created_at != nil {
  49207. fields = append(fields, wxcard.FieldCreatedAt)
  49208. }
  49209. if m.updated_at != nil {
  49210. fields = append(fields, wxcard.FieldUpdatedAt)
  49211. }
  49212. if m.deleted_at != nil {
  49213. fields = append(fields, wxcard.FieldDeletedAt)
  49214. }
  49215. if m.user_id != nil {
  49216. fields = append(fields, wxcard.FieldUserID)
  49217. }
  49218. if m.wx_user_id != nil {
  49219. fields = append(fields, wxcard.FieldWxUserID)
  49220. }
  49221. if m.avatar != nil {
  49222. fields = append(fields, wxcard.FieldAvatar)
  49223. }
  49224. if m.logo != nil {
  49225. fields = append(fields, wxcard.FieldLogo)
  49226. }
  49227. if m.name != nil {
  49228. fields = append(fields, wxcard.FieldName)
  49229. }
  49230. if m.company != nil {
  49231. fields = append(fields, wxcard.FieldCompany)
  49232. }
  49233. if m.address != nil {
  49234. fields = append(fields, wxcard.FieldAddress)
  49235. }
  49236. if m.phone != nil {
  49237. fields = append(fields, wxcard.FieldPhone)
  49238. }
  49239. if m.official_account != nil {
  49240. fields = append(fields, wxcard.FieldOfficialAccount)
  49241. }
  49242. if m.wechat_account != nil {
  49243. fields = append(fields, wxcard.FieldWechatAccount)
  49244. }
  49245. if m.email != nil {
  49246. fields = append(fields, wxcard.FieldEmail)
  49247. }
  49248. if m.api_base != nil {
  49249. fields = append(fields, wxcard.FieldAPIBase)
  49250. }
  49251. if m.api_key != nil {
  49252. fields = append(fields, wxcard.FieldAPIKey)
  49253. }
  49254. if m.ai_info != nil {
  49255. fields = append(fields, wxcard.FieldAiInfo)
  49256. }
  49257. if m.intro != nil {
  49258. fields = append(fields, wxcard.FieldIntro)
  49259. }
  49260. return fields
  49261. }
  49262. // Field returns the value of a field with the given name. The second boolean
  49263. // return value indicates that this field was not set, or was not defined in the
  49264. // schema.
  49265. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49266. switch name {
  49267. case wxcard.FieldCreatedAt:
  49268. return m.CreatedAt()
  49269. case wxcard.FieldUpdatedAt:
  49270. return m.UpdatedAt()
  49271. case wxcard.FieldDeletedAt:
  49272. return m.DeletedAt()
  49273. case wxcard.FieldUserID:
  49274. return m.UserID()
  49275. case wxcard.FieldWxUserID:
  49276. return m.WxUserID()
  49277. case wxcard.FieldAvatar:
  49278. return m.Avatar()
  49279. case wxcard.FieldLogo:
  49280. return m.Logo()
  49281. case wxcard.FieldName:
  49282. return m.Name()
  49283. case wxcard.FieldCompany:
  49284. return m.Company()
  49285. case wxcard.FieldAddress:
  49286. return m.Address()
  49287. case wxcard.FieldPhone:
  49288. return m.Phone()
  49289. case wxcard.FieldOfficialAccount:
  49290. return m.OfficialAccount()
  49291. case wxcard.FieldWechatAccount:
  49292. return m.WechatAccount()
  49293. case wxcard.FieldEmail:
  49294. return m.Email()
  49295. case wxcard.FieldAPIBase:
  49296. return m.APIBase()
  49297. case wxcard.FieldAPIKey:
  49298. return m.APIKey()
  49299. case wxcard.FieldAiInfo:
  49300. return m.AiInfo()
  49301. case wxcard.FieldIntro:
  49302. return m.Intro()
  49303. }
  49304. return nil, false
  49305. }
  49306. // OldField returns the old value of the field from the database. An error is
  49307. // returned if the mutation operation is not UpdateOne, or the query to the
  49308. // database failed.
  49309. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49310. switch name {
  49311. case wxcard.FieldCreatedAt:
  49312. return m.OldCreatedAt(ctx)
  49313. case wxcard.FieldUpdatedAt:
  49314. return m.OldUpdatedAt(ctx)
  49315. case wxcard.FieldDeletedAt:
  49316. return m.OldDeletedAt(ctx)
  49317. case wxcard.FieldUserID:
  49318. return m.OldUserID(ctx)
  49319. case wxcard.FieldWxUserID:
  49320. return m.OldWxUserID(ctx)
  49321. case wxcard.FieldAvatar:
  49322. return m.OldAvatar(ctx)
  49323. case wxcard.FieldLogo:
  49324. return m.OldLogo(ctx)
  49325. case wxcard.FieldName:
  49326. return m.OldName(ctx)
  49327. case wxcard.FieldCompany:
  49328. return m.OldCompany(ctx)
  49329. case wxcard.FieldAddress:
  49330. return m.OldAddress(ctx)
  49331. case wxcard.FieldPhone:
  49332. return m.OldPhone(ctx)
  49333. case wxcard.FieldOfficialAccount:
  49334. return m.OldOfficialAccount(ctx)
  49335. case wxcard.FieldWechatAccount:
  49336. return m.OldWechatAccount(ctx)
  49337. case wxcard.FieldEmail:
  49338. return m.OldEmail(ctx)
  49339. case wxcard.FieldAPIBase:
  49340. return m.OldAPIBase(ctx)
  49341. case wxcard.FieldAPIKey:
  49342. return m.OldAPIKey(ctx)
  49343. case wxcard.FieldAiInfo:
  49344. return m.OldAiInfo(ctx)
  49345. case wxcard.FieldIntro:
  49346. return m.OldIntro(ctx)
  49347. }
  49348. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49349. }
  49350. // SetField sets the value of a field with the given name. It returns an error if
  49351. // the field is not defined in the schema, or if the type mismatched the field
  49352. // type.
  49353. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49354. switch name {
  49355. case wxcard.FieldCreatedAt:
  49356. v, ok := value.(time.Time)
  49357. if !ok {
  49358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49359. }
  49360. m.SetCreatedAt(v)
  49361. return nil
  49362. case wxcard.FieldUpdatedAt:
  49363. v, ok := value.(time.Time)
  49364. if !ok {
  49365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49366. }
  49367. m.SetUpdatedAt(v)
  49368. return nil
  49369. case wxcard.FieldDeletedAt:
  49370. v, ok := value.(time.Time)
  49371. if !ok {
  49372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49373. }
  49374. m.SetDeletedAt(v)
  49375. return nil
  49376. case wxcard.FieldUserID:
  49377. v, ok := value.(uint64)
  49378. if !ok {
  49379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49380. }
  49381. m.SetUserID(v)
  49382. return nil
  49383. case wxcard.FieldWxUserID:
  49384. v, ok := value.(uint64)
  49385. if !ok {
  49386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49387. }
  49388. m.SetWxUserID(v)
  49389. return nil
  49390. case wxcard.FieldAvatar:
  49391. v, ok := value.(string)
  49392. if !ok {
  49393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49394. }
  49395. m.SetAvatar(v)
  49396. return nil
  49397. case wxcard.FieldLogo:
  49398. v, ok := value.(string)
  49399. if !ok {
  49400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49401. }
  49402. m.SetLogo(v)
  49403. return nil
  49404. case wxcard.FieldName:
  49405. v, ok := value.(string)
  49406. if !ok {
  49407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49408. }
  49409. m.SetName(v)
  49410. return nil
  49411. case wxcard.FieldCompany:
  49412. v, ok := value.(string)
  49413. if !ok {
  49414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49415. }
  49416. m.SetCompany(v)
  49417. return nil
  49418. case wxcard.FieldAddress:
  49419. v, ok := value.(string)
  49420. if !ok {
  49421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49422. }
  49423. m.SetAddress(v)
  49424. return nil
  49425. case wxcard.FieldPhone:
  49426. v, ok := value.(string)
  49427. if !ok {
  49428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49429. }
  49430. m.SetPhone(v)
  49431. return nil
  49432. case wxcard.FieldOfficialAccount:
  49433. v, ok := value.(string)
  49434. if !ok {
  49435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49436. }
  49437. m.SetOfficialAccount(v)
  49438. return nil
  49439. case wxcard.FieldWechatAccount:
  49440. v, ok := value.(string)
  49441. if !ok {
  49442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49443. }
  49444. m.SetWechatAccount(v)
  49445. return nil
  49446. case wxcard.FieldEmail:
  49447. v, ok := value.(string)
  49448. if !ok {
  49449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49450. }
  49451. m.SetEmail(v)
  49452. return nil
  49453. case wxcard.FieldAPIBase:
  49454. v, ok := value.(string)
  49455. if !ok {
  49456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49457. }
  49458. m.SetAPIBase(v)
  49459. return nil
  49460. case wxcard.FieldAPIKey:
  49461. v, ok := value.(string)
  49462. if !ok {
  49463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49464. }
  49465. m.SetAPIKey(v)
  49466. return nil
  49467. case wxcard.FieldAiInfo:
  49468. v, ok := value.(string)
  49469. if !ok {
  49470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49471. }
  49472. m.SetAiInfo(v)
  49473. return nil
  49474. case wxcard.FieldIntro:
  49475. v, ok := value.(string)
  49476. if !ok {
  49477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49478. }
  49479. m.SetIntro(v)
  49480. return nil
  49481. }
  49482. return fmt.Errorf("unknown WxCard field %s", name)
  49483. }
  49484. // AddedFields returns all numeric fields that were incremented/decremented during
  49485. // this mutation.
  49486. func (m *WxCardMutation) AddedFields() []string {
  49487. var fields []string
  49488. if m.adduser_id != nil {
  49489. fields = append(fields, wxcard.FieldUserID)
  49490. }
  49491. if m.addwx_user_id != nil {
  49492. fields = append(fields, wxcard.FieldWxUserID)
  49493. }
  49494. return fields
  49495. }
  49496. // AddedField returns the numeric value that was incremented/decremented on a field
  49497. // with the given name. The second boolean return value indicates that this field
  49498. // was not set, or was not defined in the schema.
  49499. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49500. switch name {
  49501. case wxcard.FieldUserID:
  49502. return m.AddedUserID()
  49503. case wxcard.FieldWxUserID:
  49504. return m.AddedWxUserID()
  49505. }
  49506. return nil, false
  49507. }
  49508. // AddField adds the value to the field with the given name. It returns an error if
  49509. // the field is not defined in the schema, or if the type mismatched the field
  49510. // type.
  49511. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49512. switch name {
  49513. case wxcard.FieldUserID:
  49514. v, ok := value.(int64)
  49515. if !ok {
  49516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49517. }
  49518. m.AddUserID(v)
  49519. return nil
  49520. case wxcard.FieldWxUserID:
  49521. v, ok := value.(int64)
  49522. if !ok {
  49523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49524. }
  49525. m.AddWxUserID(v)
  49526. return nil
  49527. }
  49528. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49529. }
  49530. // ClearedFields returns all nullable fields that were cleared during this
  49531. // mutation.
  49532. func (m *WxCardMutation) ClearedFields() []string {
  49533. var fields []string
  49534. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49535. fields = append(fields, wxcard.FieldDeletedAt)
  49536. }
  49537. if m.FieldCleared(wxcard.FieldUserID) {
  49538. fields = append(fields, wxcard.FieldUserID)
  49539. }
  49540. if m.FieldCleared(wxcard.FieldWxUserID) {
  49541. fields = append(fields, wxcard.FieldWxUserID)
  49542. }
  49543. if m.FieldCleared(wxcard.FieldEmail) {
  49544. fields = append(fields, wxcard.FieldEmail)
  49545. }
  49546. if m.FieldCleared(wxcard.FieldAPIBase) {
  49547. fields = append(fields, wxcard.FieldAPIBase)
  49548. }
  49549. if m.FieldCleared(wxcard.FieldAPIKey) {
  49550. fields = append(fields, wxcard.FieldAPIKey)
  49551. }
  49552. if m.FieldCleared(wxcard.FieldAiInfo) {
  49553. fields = append(fields, wxcard.FieldAiInfo)
  49554. }
  49555. if m.FieldCleared(wxcard.FieldIntro) {
  49556. fields = append(fields, wxcard.FieldIntro)
  49557. }
  49558. return fields
  49559. }
  49560. // FieldCleared returns a boolean indicating if a field with the given name was
  49561. // cleared in this mutation.
  49562. func (m *WxCardMutation) FieldCleared(name string) bool {
  49563. _, ok := m.clearedFields[name]
  49564. return ok
  49565. }
  49566. // ClearField clears the value of the field with the given name. It returns an
  49567. // error if the field is not defined in the schema.
  49568. func (m *WxCardMutation) ClearField(name string) error {
  49569. switch name {
  49570. case wxcard.FieldDeletedAt:
  49571. m.ClearDeletedAt()
  49572. return nil
  49573. case wxcard.FieldUserID:
  49574. m.ClearUserID()
  49575. return nil
  49576. case wxcard.FieldWxUserID:
  49577. m.ClearWxUserID()
  49578. return nil
  49579. case wxcard.FieldEmail:
  49580. m.ClearEmail()
  49581. return nil
  49582. case wxcard.FieldAPIBase:
  49583. m.ClearAPIBase()
  49584. return nil
  49585. case wxcard.FieldAPIKey:
  49586. m.ClearAPIKey()
  49587. return nil
  49588. case wxcard.FieldAiInfo:
  49589. m.ClearAiInfo()
  49590. return nil
  49591. case wxcard.FieldIntro:
  49592. m.ClearIntro()
  49593. return nil
  49594. }
  49595. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49596. }
  49597. // ResetField resets all changes in the mutation for the field with the given name.
  49598. // It returns an error if the field is not defined in the schema.
  49599. func (m *WxCardMutation) ResetField(name string) error {
  49600. switch name {
  49601. case wxcard.FieldCreatedAt:
  49602. m.ResetCreatedAt()
  49603. return nil
  49604. case wxcard.FieldUpdatedAt:
  49605. m.ResetUpdatedAt()
  49606. return nil
  49607. case wxcard.FieldDeletedAt:
  49608. m.ResetDeletedAt()
  49609. return nil
  49610. case wxcard.FieldUserID:
  49611. m.ResetUserID()
  49612. return nil
  49613. case wxcard.FieldWxUserID:
  49614. m.ResetWxUserID()
  49615. return nil
  49616. case wxcard.FieldAvatar:
  49617. m.ResetAvatar()
  49618. return nil
  49619. case wxcard.FieldLogo:
  49620. m.ResetLogo()
  49621. return nil
  49622. case wxcard.FieldName:
  49623. m.ResetName()
  49624. return nil
  49625. case wxcard.FieldCompany:
  49626. m.ResetCompany()
  49627. return nil
  49628. case wxcard.FieldAddress:
  49629. m.ResetAddress()
  49630. return nil
  49631. case wxcard.FieldPhone:
  49632. m.ResetPhone()
  49633. return nil
  49634. case wxcard.FieldOfficialAccount:
  49635. m.ResetOfficialAccount()
  49636. return nil
  49637. case wxcard.FieldWechatAccount:
  49638. m.ResetWechatAccount()
  49639. return nil
  49640. case wxcard.FieldEmail:
  49641. m.ResetEmail()
  49642. return nil
  49643. case wxcard.FieldAPIBase:
  49644. m.ResetAPIBase()
  49645. return nil
  49646. case wxcard.FieldAPIKey:
  49647. m.ResetAPIKey()
  49648. return nil
  49649. case wxcard.FieldAiInfo:
  49650. m.ResetAiInfo()
  49651. return nil
  49652. case wxcard.FieldIntro:
  49653. m.ResetIntro()
  49654. return nil
  49655. }
  49656. return fmt.Errorf("unknown WxCard field %s", name)
  49657. }
  49658. // AddedEdges returns all edge names that were set/added in this mutation.
  49659. func (m *WxCardMutation) AddedEdges() []string {
  49660. edges := make([]string, 0, 0)
  49661. return edges
  49662. }
  49663. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49664. // name in this mutation.
  49665. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  49666. return nil
  49667. }
  49668. // RemovedEdges returns all edge names that were removed in this mutation.
  49669. func (m *WxCardMutation) RemovedEdges() []string {
  49670. edges := make([]string, 0, 0)
  49671. return edges
  49672. }
  49673. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49674. // the given name in this mutation.
  49675. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  49676. return nil
  49677. }
  49678. // ClearedEdges returns all edge names that were cleared in this mutation.
  49679. func (m *WxCardMutation) ClearedEdges() []string {
  49680. edges := make([]string, 0, 0)
  49681. return edges
  49682. }
  49683. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49684. // was cleared in this mutation.
  49685. func (m *WxCardMutation) EdgeCleared(name string) bool {
  49686. return false
  49687. }
  49688. // ClearEdge clears the value of the edge with the given name. It returns an error
  49689. // if that edge is not defined in the schema.
  49690. func (m *WxCardMutation) ClearEdge(name string) error {
  49691. return fmt.Errorf("unknown WxCard unique edge %s", name)
  49692. }
  49693. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49694. // It returns an error if the edge is not defined in the schema.
  49695. func (m *WxCardMutation) ResetEdge(name string) error {
  49696. return fmt.Errorf("unknown WxCard edge %s", name)
  49697. }
  49698. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  49699. type WxCardUserMutation struct {
  49700. config
  49701. op Op
  49702. typ string
  49703. id *uint64
  49704. created_at *time.Time
  49705. updated_at *time.Time
  49706. deleted_at *time.Time
  49707. wxid *string
  49708. account *string
  49709. avatar *string
  49710. nickname *string
  49711. remark *string
  49712. phone *string
  49713. open_id *string
  49714. union_id *string
  49715. session_key *string
  49716. is_vip *int
  49717. addis_vip *int
  49718. clearedFields map[string]struct{}
  49719. done bool
  49720. oldValue func(context.Context) (*WxCardUser, error)
  49721. predicates []predicate.WxCardUser
  49722. }
  49723. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  49724. // wxcarduserOption allows management of the mutation configuration using functional options.
  49725. type wxcarduserOption func(*WxCardUserMutation)
  49726. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  49727. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  49728. m := &WxCardUserMutation{
  49729. config: c,
  49730. op: op,
  49731. typ: TypeWxCardUser,
  49732. clearedFields: make(map[string]struct{}),
  49733. }
  49734. for _, opt := range opts {
  49735. opt(m)
  49736. }
  49737. return m
  49738. }
  49739. // withWxCardUserID sets the ID field of the mutation.
  49740. func withWxCardUserID(id uint64) wxcarduserOption {
  49741. return func(m *WxCardUserMutation) {
  49742. var (
  49743. err error
  49744. once sync.Once
  49745. value *WxCardUser
  49746. )
  49747. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  49748. once.Do(func() {
  49749. if m.done {
  49750. err = errors.New("querying old values post mutation is not allowed")
  49751. } else {
  49752. value, err = m.Client().WxCardUser.Get(ctx, id)
  49753. }
  49754. })
  49755. return value, err
  49756. }
  49757. m.id = &id
  49758. }
  49759. }
  49760. // withWxCardUser sets the old WxCardUser of the mutation.
  49761. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  49762. return func(m *WxCardUserMutation) {
  49763. m.oldValue = func(context.Context) (*WxCardUser, error) {
  49764. return node, nil
  49765. }
  49766. m.id = &node.ID
  49767. }
  49768. }
  49769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49770. // executed in a transaction (ent.Tx), a transactional client is returned.
  49771. func (m WxCardUserMutation) Client() *Client {
  49772. client := &Client{config: m.config}
  49773. client.init()
  49774. return client
  49775. }
  49776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49777. // it returns an error otherwise.
  49778. func (m WxCardUserMutation) Tx() (*Tx, error) {
  49779. if _, ok := m.driver.(*txDriver); !ok {
  49780. return nil, errors.New("ent: mutation is not running in a transaction")
  49781. }
  49782. tx := &Tx{config: m.config}
  49783. tx.init()
  49784. return tx, nil
  49785. }
  49786. // SetID sets the value of the id field. Note that this
  49787. // operation is only accepted on creation of WxCardUser entities.
  49788. func (m *WxCardUserMutation) SetID(id uint64) {
  49789. m.id = &id
  49790. }
  49791. // ID returns the ID value in the mutation. Note that the ID is only available
  49792. // if it was provided to the builder or after it was returned from the database.
  49793. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  49794. if m.id == nil {
  49795. return
  49796. }
  49797. return *m.id, true
  49798. }
  49799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49800. // That means, if the mutation is applied within a transaction with an isolation level such
  49801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49802. // or updated by the mutation.
  49803. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  49804. switch {
  49805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49806. id, exists := m.ID()
  49807. if exists {
  49808. return []uint64{id}, nil
  49809. }
  49810. fallthrough
  49811. case m.op.Is(OpUpdate | OpDelete):
  49812. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  49813. default:
  49814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49815. }
  49816. }
  49817. // SetCreatedAt sets the "created_at" field.
  49818. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  49819. m.created_at = &t
  49820. }
  49821. // CreatedAt returns the value of the "created_at" field in the mutation.
  49822. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  49823. v := m.created_at
  49824. if v == nil {
  49825. return
  49826. }
  49827. return *v, true
  49828. }
  49829. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  49830. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49832. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49833. if !m.op.Is(OpUpdateOne) {
  49834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49835. }
  49836. if m.id == nil || m.oldValue == nil {
  49837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49838. }
  49839. oldValue, err := m.oldValue(ctx)
  49840. if err != nil {
  49841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49842. }
  49843. return oldValue.CreatedAt, nil
  49844. }
  49845. // ResetCreatedAt resets all changes to the "created_at" field.
  49846. func (m *WxCardUserMutation) ResetCreatedAt() {
  49847. m.created_at = nil
  49848. }
  49849. // SetUpdatedAt sets the "updated_at" field.
  49850. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  49851. m.updated_at = &t
  49852. }
  49853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49854. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  49855. v := m.updated_at
  49856. if v == nil {
  49857. return
  49858. }
  49859. return *v, true
  49860. }
  49861. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  49862. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49864. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49865. if !m.op.Is(OpUpdateOne) {
  49866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49867. }
  49868. if m.id == nil || m.oldValue == nil {
  49869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49870. }
  49871. oldValue, err := m.oldValue(ctx)
  49872. if err != nil {
  49873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49874. }
  49875. return oldValue.UpdatedAt, nil
  49876. }
  49877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49878. func (m *WxCardUserMutation) ResetUpdatedAt() {
  49879. m.updated_at = nil
  49880. }
  49881. // SetDeletedAt sets the "deleted_at" field.
  49882. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  49883. m.deleted_at = &t
  49884. }
  49885. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49886. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  49887. v := m.deleted_at
  49888. if v == nil {
  49889. return
  49890. }
  49891. return *v, true
  49892. }
  49893. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  49894. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49896. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49897. if !m.op.Is(OpUpdateOne) {
  49898. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49899. }
  49900. if m.id == nil || m.oldValue == nil {
  49901. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49902. }
  49903. oldValue, err := m.oldValue(ctx)
  49904. if err != nil {
  49905. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49906. }
  49907. return oldValue.DeletedAt, nil
  49908. }
  49909. // ClearDeletedAt clears the value of the "deleted_at" field.
  49910. func (m *WxCardUserMutation) ClearDeletedAt() {
  49911. m.deleted_at = nil
  49912. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  49913. }
  49914. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49915. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  49916. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  49917. return ok
  49918. }
  49919. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49920. func (m *WxCardUserMutation) ResetDeletedAt() {
  49921. m.deleted_at = nil
  49922. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  49923. }
  49924. // SetWxid sets the "wxid" field.
  49925. func (m *WxCardUserMutation) SetWxid(s string) {
  49926. m.wxid = &s
  49927. }
  49928. // Wxid returns the value of the "wxid" field in the mutation.
  49929. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  49930. v := m.wxid
  49931. if v == nil {
  49932. return
  49933. }
  49934. return *v, true
  49935. }
  49936. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  49937. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49939. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  49940. if !m.op.Is(OpUpdateOne) {
  49941. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49942. }
  49943. if m.id == nil || m.oldValue == nil {
  49944. return v, errors.New("OldWxid requires an ID field in the mutation")
  49945. }
  49946. oldValue, err := m.oldValue(ctx)
  49947. if err != nil {
  49948. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49949. }
  49950. return oldValue.Wxid, nil
  49951. }
  49952. // ResetWxid resets all changes to the "wxid" field.
  49953. func (m *WxCardUserMutation) ResetWxid() {
  49954. m.wxid = nil
  49955. }
  49956. // SetAccount sets the "account" field.
  49957. func (m *WxCardUserMutation) SetAccount(s string) {
  49958. m.account = &s
  49959. }
  49960. // Account returns the value of the "account" field in the mutation.
  49961. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  49962. v := m.account
  49963. if v == nil {
  49964. return
  49965. }
  49966. return *v, true
  49967. }
  49968. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  49969. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  49970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49971. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  49972. if !m.op.Is(OpUpdateOne) {
  49973. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  49974. }
  49975. if m.id == nil || m.oldValue == nil {
  49976. return v, errors.New("OldAccount requires an ID field in the mutation")
  49977. }
  49978. oldValue, err := m.oldValue(ctx)
  49979. if err != nil {
  49980. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  49981. }
  49982. return oldValue.Account, nil
  49983. }
  49984. // ResetAccount resets all changes to the "account" field.
  49985. func (m *WxCardUserMutation) ResetAccount() {
  49986. m.account = nil
  49987. }
  49988. // SetAvatar sets the "avatar" field.
  49989. func (m *WxCardUserMutation) SetAvatar(s string) {
  49990. m.avatar = &s
  49991. }
  49992. // Avatar returns the value of the "avatar" field in the mutation.
  49993. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  49994. v := m.avatar
  49995. if v == nil {
  49996. return
  49997. }
  49998. return *v, true
  49999. }
  50000. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50001. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50003. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50004. if !m.op.Is(OpUpdateOne) {
  50005. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50006. }
  50007. if m.id == nil || m.oldValue == nil {
  50008. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50009. }
  50010. oldValue, err := m.oldValue(ctx)
  50011. if err != nil {
  50012. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50013. }
  50014. return oldValue.Avatar, nil
  50015. }
  50016. // ResetAvatar resets all changes to the "avatar" field.
  50017. func (m *WxCardUserMutation) ResetAvatar() {
  50018. m.avatar = nil
  50019. }
  50020. // SetNickname sets the "nickname" field.
  50021. func (m *WxCardUserMutation) SetNickname(s string) {
  50022. m.nickname = &s
  50023. }
  50024. // Nickname returns the value of the "nickname" field in the mutation.
  50025. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50026. v := m.nickname
  50027. if v == nil {
  50028. return
  50029. }
  50030. return *v, true
  50031. }
  50032. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50033. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50035. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50036. if !m.op.Is(OpUpdateOne) {
  50037. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50038. }
  50039. if m.id == nil || m.oldValue == nil {
  50040. return v, errors.New("OldNickname requires an ID field in the mutation")
  50041. }
  50042. oldValue, err := m.oldValue(ctx)
  50043. if err != nil {
  50044. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50045. }
  50046. return oldValue.Nickname, nil
  50047. }
  50048. // ResetNickname resets all changes to the "nickname" field.
  50049. func (m *WxCardUserMutation) ResetNickname() {
  50050. m.nickname = nil
  50051. }
  50052. // SetRemark sets the "remark" field.
  50053. func (m *WxCardUserMutation) SetRemark(s string) {
  50054. m.remark = &s
  50055. }
  50056. // Remark returns the value of the "remark" field in the mutation.
  50057. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50058. v := m.remark
  50059. if v == nil {
  50060. return
  50061. }
  50062. return *v, true
  50063. }
  50064. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50065. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50067. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50068. if !m.op.Is(OpUpdateOne) {
  50069. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50070. }
  50071. if m.id == nil || m.oldValue == nil {
  50072. return v, errors.New("OldRemark requires an ID field in the mutation")
  50073. }
  50074. oldValue, err := m.oldValue(ctx)
  50075. if err != nil {
  50076. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50077. }
  50078. return oldValue.Remark, nil
  50079. }
  50080. // ResetRemark resets all changes to the "remark" field.
  50081. func (m *WxCardUserMutation) ResetRemark() {
  50082. m.remark = nil
  50083. }
  50084. // SetPhone sets the "phone" field.
  50085. func (m *WxCardUserMutation) SetPhone(s string) {
  50086. m.phone = &s
  50087. }
  50088. // Phone returns the value of the "phone" field in the mutation.
  50089. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50090. v := m.phone
  50091. if v == nil {
  50092. return
  50093. }
  50094. return *v, true
  50095. }
  50096. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50097. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50099. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50100. if !m.op.Is(OpUpdateOne) {
  50101. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50102. }
  50103. if m.id == nil || m.oldValue == nil {
  50104. return v, errors.New("OldPhone requires an ID field in the mutation")
  50105. }
  50106. oldValue, err := m.oldValue(ctx)
  50107. if err != nil {
  50108. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50109. }
  50110. return oldValue.Phone, nil
  50111. }
  50112. // ResetPhone resets all changes to the "phone" field.
  50113. func (m *WxCardUserMutation) ResetPhone() {
  50114. m.phone = nil
  50115. }
  50116. // SetOpenID sets the "open_id" field.
  50117. func (m *WxCardUserMutation) SetOpenID(s string) {
  50118. m.open_id = &s
  50119. }
  50120. // OpenID returns the value of the "open_id" field in the mutation.
  50121. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50122. v := m.open_id
  50123. if v == nil {
  50124. return
  50125. }
  50126. return *v, true
  50127. }
  50128. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50129. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50131. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50132. if !m.op.Is(OpUpdateOne) {
  50133. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50134. }
  50135. if m.id == nil || m.oldValue == nil {
  50136. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50137. }
  50138. oldValue, err := m.oldValue(ctx)
  50139. if err != nil {
  50140. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50141. }
  50142. return oldValue.OpenID, nil
  50143. }
  50144. // ResetOpenID resets all changes to the "open_id" field.
  50145. func (m *WxCardUserMutation) ResetOpenID() {
  50146. m.open_id = nil
  50147. }
  50148. // SetUnionID sets the "union_id" field.
  50149. func (m *WxCardUserMutation) SetUnionID(s string) {
  50150. m.union_id = &s
  50151. }
  50152. // UnionID returns the value of the "union_id" field in the mutation.
  50153. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50154. v := m.union_id
  50155. if v == nil {
  50156. return
  50157. }
  50158. return *v, true
  50159. }
  50160. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50161. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50163. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50164. if !m.op.Is(OpUpdateOne) {
  50165. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50166. }
  50167. if m.id == nil || m.oldValue == nil {
  50168. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50169. }
  50170. oldValue, err := m.oldValue(ctx)
  50171. if err != nil {
  50172. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50173. }
  50174. return oldValue.UnionID, nil
  50175. }
  50176. // ResetUnionID resets all changes to the "union_id" field.
  50177. func (m *WxCardUserMutation) ResetUnionID() {
  50178. m.union_id = nil
  50179. }
  50180. // SetSessionKey sets the "session_key" field.
  50181. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50182. m.session_key = &s
  50183. }
  50184. // SessionKey returns the value of the "session_key" field in the mutation.
  50185. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50186. v := m.session_key
  50187. if v == nil {
  50188. return
  50189. }
  50190. return *v, true
  50191. }
  50192. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50193. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50195. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50196. if !m.op.Is(OpUpdateOne) {
  50197. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50198. }
  50199. if m.id == nil || m.oldValue == nil {
  50200. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50201. }
  50202. oldValue, err := m.oldValue(ctx)
  50203. if err != nil {
  50204. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50205. }
  50206. return oldValue.SessionKey, nil
  50207. }
  50208. // ResetSessionKey resets all changes to the "session_key" field.
  50209. func (m *WxCardUserMutation) ResetSessionKey() {
  50210. m.session_key = nil
  50211. }
  50212. // SetIsVip sets the "is_vip" field.
  50213. func (m *WxCardUserMutation) SetIsVip(i int) {
  50214. m.is_vip = &i
  50215. m.addis_vip = nil
  50216. }
  50217. // IsVip returns the value of the "is_vip" field in the mutation.
  50218. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50219. v := m.is_vip
  50220. if v == nil {
  50221. return
  50222. }
  50223. return *v, true
  50224. }
  50225. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50226. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50228. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50229. if !m.op.Is(OpUpdateOne) {
  50230. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50231. }
  50232. if m.id == nil || m.oldValue == nil {
  50233. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50234. }
  50235. oldValue, err := m.oldValue(ctx)
  50236. if err != nil {
  50237. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50238. }
  50239. return oldValue.IsVip, nil
  50240. }
  50241. // AddIsVip adds i to the "is_vip" field.
  50242. func (m *WxCardUserMutation) AddIsVip(i int) {
  50243. if m.addis_vip != nil {
  50244. *m.addis_vip += i
  50245. } else {
  50246. m.addis_vip = &i
  50247. }
  50248. }
  50249. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50250. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50251. v := m.addis_vip
  50252. if v == nil {
  50253. return
  50254. }
  50255. return *v, true
  50256. }
  50257. // ResetIsVip resets all changes to the "is_vip" field.
  50258. func (m *WxCardUserMutation) ResetIsVip() {
  50259. m.is_vip = nil
  50260. m.addis_vip = nil
  50261. }
  50262. // Where appends a list predicates to the WxCardUserMutation builder.
  50263. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50264. m.predicates = append(m.predicates, ps...)
  50265. }
  50266. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50267. // users can use type-assertion to append predicates that do not depend on any generated package.
  50268. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50269. p := make([]predicate.WxCardUser, len(ps))
  50270. for i := range ps {
  50271. p[i] = ps[i]
  50272. }
  50273. m.Where(p...)
  50274. }
  50275. // Op returns the operation name.
  50276. func (m *WxCardUserMutation) Op() Op {
  50277. return m.op
  50278. }
  50279. // SetOp allows setting the mutation operation.
  50280. func (m *WxCardUserMutation) SetOp(op Op) {
  50281. m.op = op
  50282. }
  50283. // Type returns the node type of this mutation (WxCardUser).
  50284. func (m *WxCardUserMutation) Type() string {
  50285. return m.typ
  50286. }
  50287. // Fields returns all fields that were changed during this mutation. Note that in
  50288. // order to get all numeric fields that were incremented/decremented, call
  50289. // AddedFields().
  50290. func (m *WxCardUserMutation) Fields() []string {
  50291. fields := make([]string, 0, 13)
  50292. if m.created_at != nil {
  50293. fields = append(fields, wxcarduser.FieldCreatedAt)
  50294. }
  50295. if m.updated_at != nil {
  50296. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50297. }
  50298. if m.deleted_at != nil {
  50299. fields = append(fields, wxcarduser.FieldDeletedAt)
  50300. }
  50301. if m.wxid != nil {
  50302. fields = append(fields, wxcarduser.FieldWxid)
  50303. }
  50304. if m.account != nil {
  50305. fields = append(fields, wxcarduser.FieldAccount)
  50306. }
  50307. if m.avatar != nil {
  50308. fields = append(fields, wxcarduser.FieldAvatar)
  50309. }
  50310. if m.nickname != nil {
  50311. fields = append(fields, wxcarduser.FieldNickname)
  50312. }
  50313. if m.remark != nil {
  50314. fields = append(fields, wxcarduser.FieldRemark)
  50315. }
  50316. if m.phone != nil {
  50317. fields = append(fields, wxcarduser.FieldPhone)
  50318. }
  50319. if m.open_id != nil {
  50320. fields = append(fields, wxcarduser.FieldOpenID)
  50321. }
  50322. if m.union_id != nil {
  50323. fields = append(fields, wxcarduser.FieldUnionID)
  50324. }
  50325. if m.session_key != nil {
  50326. fields = append(fields, wxcarduser.FieldSessionKey)
  50327. }
  50328. if m.is_vip != nil {
  50329. fields = append(fields, wxcarduser.FieldIsVip)
  50330. }
  50331. return fields
  50332. }
  50333. // Field returns the value of a field with the given name. The second boolean
  50334. // return value indicates that this field was not set, or was not defined in the
  50335. // schema.
  50336. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50337. switch name {
  50338. case wxcarduser.FieldCreatedAt:
  50339. return m.CreatedAt()
  50340. case wxcarduser.FieldUpdatedAt:
  50341. return m.UpdatedAt()
  50342. case wxcarduser.FieldDeletedAt:
  50343. return m.DeletedAt()
  50344. case wxcarduser.FieldWxid:
  50345. return m.Wxid()
  50346. case wxcarduser.FieldAccount:
  50347. return m.Account()
  50348. case wxcarduser.FieldAvatar:
  50349. return m.Avatar()
  50350. case wxcarduser.FieldNickname:
  50351. return m.Nickname()
  50352. case wxcarduser.FieldRemark:
  50353. return m.Remark()
  50354. case wxcarduser.FieldPhone:
  50355. return m.Phone()
  50356. case wxcarduser.FieldOpenID:
  50357. return m.OpenID()
  50358. case wxcarduser.FieldUnionID:
  50359. return m.UnionID()
  50360. case wxcarduser.FieldSessionKey:
  50361. return m.SessionKey()
  50362. case wxcarduser.FieldIsVip:
  50363. return m.IsVip()
  50364. }
  50365. return nil, false
  50366. }
  50367. // OldField returns the old value of the field from the database. An error is
  50368. // returned if the mutation operation is not UpdateOne, or the query to the
  50369. // database failed.
  50370. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50371. switch name {
  50372. case wxcarduser.FieldCreatedAt:
  50373. return m.OldCreatedAt(ctx)
  50374. case wxcarduser.FieldUpdatedAt:
  50375. return m.OldUpdatedAt(ctx)
  50376. case wxcarduser.FieldDeletedAt:
  50377. return m.OldDeletedAt(ctx)
  50378. case wxcarduser.FieldWxid:
  50379. return m.OldWxid(ctx)
  50380. case wxcarduser.FieldAccount:
  50381. return m.OldAccount(ctx)
  50382. case wxcarduser.FieldAvatar:
  50383. return m.OldAvatar(ctx)
  50384. case wxcarduser.FieldNickname:
  50385. return m.OldNickname(ctx)
  50386. case wxcarduser.FieldRemark:
  50387. return m.OldRemark(ctx)
  50388. case wxcarduser.FieldPhone:
  50389. return m.OldPhone(ctx)
  50390. case wxcarduser.FieldOpenID:
  50391. return m.OldOpenID(ctx)
  50392. case wxcarduser.FieldUnionID:
  50393. return m.OldUnionID(ctx)
  50394. case wxcarduser.FieldSessionKey:
  50395. return m.OldSessionKey(ctx)
  50396. case wxcarduser.FieldIsVip:
  50397. return m.OldIsVip(ctx)
  50398. }
  50399. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50400. }
  50401. // SetField sets the value of a field with the given name. It returns an error if
  50402. // the field is not defined in the schema, or if the type mismatched the field
  50403. // type.
  50404. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50405. switch name {
  50406. case wxcarduser.FieldCreatedAt:
  50407. v, ok := value.(time.Time)
  50408. if !ok {
  50409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50410. }
  50411. m.SetCreatedAt(v)
  50412. return nil
  50413. case wxcarduser.FieldUpdatedAt:
  50414. v, ok := value.(time.Time)
  50415. if !ok {
  50416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50417. }
  50418. m.SetUpdatedAt(v)
  50419. return nil
  50420. case wxcarduser.FieldDeletedAt:
  50421. v, ok := value.(time.Time)
  50422. if !ok {
  50423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50424. }
  50425. m.SetDeletedAt(v)
  50426. return nil
  50427. case wxcarduser.FieldWxid:
  50428. v, ok := value.(string)
  50429. if !ok {
  50430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50431. }
  50432. m.SetWxid(v)
  50433. return nil
  50434. case wxcarduser.FieldAccount:
  50435. v, ok := value.(string)
  50436. if !ok {
  50437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50438. }
  50439. m.SetAccount(v)
  50440. return nil
  50441. case wxcarduser.FieldAvatar:
  50442. v, ok := value.(string)
  50443. if !ok {
  50444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50445. }
  50446. m.SetAvatar(v)
  50447. return nil
  50448. case wxcarduser.FieldNickname:
  50449. v, ok := value.(string)
  50450. if !ok {
  50451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50452. }
  50453. m.SetNickname(v)
  50454. return nil
  50455. case wxcarduser.FieldRemark:
  50456. v, ok := value.(string)
  50457. if !ok {
  50458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50459. }
  50460. m.SetRemark(v)
  50461. return nil
  50462. case wxcarduser.FieldPhone:
  50463. v, ok := value.(string)
  50464. if !ok {
  50465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50466. }
  50467. m.SetPhone(v)
  50468. return nil
  50469. case wxcarduser.FieldOpenID:
  50470. v, ok := value.(string)
  50471. if !ok {
  50472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50473. }
  50474. m.SetOpenID(v)
  50475. return nil
  50476. case wxcarduser.FieldUnionID:
  50477. v, ok := value.(string)
  50478. if !ok {
  50479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50480. }
  50481. m.SetUnionID(v)
  50482. return nil
  50483. case wxcarduser.FieldSessionKey:
  50484. v, ok := value.(string)
  50485. if !ok {
  50486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50487. }
  50488. m.SetSessionKey(v)
  50489. return nil
  50490. case wxcarduser.FieldIsVip:
  50491. v, ok := value.(int)
  50492. if !ok {
  50493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50494. }
  50495. m.SetIsVip(v)
  50496. return nil
  50497. }
  50498. return fmt.Errorf("unknown WxCardUser field %s", name)
  50499. }
  50500. // AddedFields returns all numeric fields that were incremented/decremented during
  50501. // this mutation.
  50502. func (m *WxCardUserMutation) AddedFields() []string {
  50503. var fields []string
  50504. if m.addis_vip != nil {
  50505. fields = append(fields, wxcarduser.FieldIsVip)
  50506. }
  50507. return fields
  50508. }
  50509. // AddedField returns the numeric value that was incremented/decremented on a field
  50510. // with the given name. The second boolean return value indicates that this field
  50511. // was not set, or was not defined in the schema.
  50512. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50513. switch name {
  50514. case wxcarduser.FieldIsVip:
  50515. return m.AddedIsVip()
  50516. }
  50517. return nil, false
  50518. }
  50519. // AddField adds the value to the field with the given name. It returns an error if
  50520. // the field is not defined in the schema, or if the type mismatched the field
  50521. // type.
  50522. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50523. switch name {
  50524. case wxcarduser.FieldIsVip:
  50525. v, ok := value.(int)
  50526. if !ok {
  50527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50528. }
  50529. m.AddIsVip(v)
  50530. return nil
  50531. }
  50532. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50533. }
  50534. // ClearedFields returns all nullable fields that were cleared during this
  50535. // mutation.
  50536. func (m *WxCardUserMutation) ClearedFields() []string {
  50537. var fields []string
  50538. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50539. fields = append(fields, wxcarduser.FieldDeletedAt)
  50540. }
  50541. return fields
  50542. }
  50543. // FieldCleared returns a boolean indicating if a field with the given name was
  50544. // cleared in this mutation.
  50545. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50546. _, ok := m.clearedFields[name]
  50547. return ok
  50548. }
  50549. // ClearField clears the value of the field with the given name. It returns an
  50550. // error if the field is not defined in the schema.
  50551. func (m *WxCardUserMutation) ClearField(name string) error {
  50552. switch name {
  50553. case wxcarduser.FieldDeletedAt:
  50554. m.ClearDeletedAt()
  50555. return nil
  50556. }
  50557. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50558. }
  50559. // ResetField resets all changes in the mutation for the field with the given name.
  50560. // It returns an error if the field is not defined in the schema.
  50561. func (m *WxCardUserMutation) ResetField(name string) error {
  50562. switch name {
  50563. case wxcarduser.FieldCreatedAt:
  50564. m.ResetCreatedAt()
  50565. return nil
  50566. case wxcarduser.FieldUpdatedAt:
  50567. m.ResetUpdatedAt()
  50568. return nil
  50569. case wxcarduser.FieldDeletedAt:
  50570. m.ResetDeletedAt()
  50571. return nil
  50572. case wxcarduser.FieldWxid:
  50573. m.ResetWxid()
  50574. return nil
  50575. case wxcarduser.FieldAccount:
  50576. m.ResetAccount()
  50577. return nil
  50578. case wxcarduser.FieldAvatar:
  50579. m.ResetAvatar()
  50580. return nil
  50581. case wxcarduser.FieldNickname:
  50582. m.ResetNickname()
  50583. return nil
  50584. case wxcarduser.FieldRemark:
  50585. m.ResetRemark()
  50586. return nil
  50587. case wxcarduser.FieldPhone:
  50588. m.ResetPhone()
  50589. return nil
  50590. case wxcarduser.FieldOpenID:
  50591. m.ResetOpenID()
  50592. return nil
  50593. case wxcarduser.FieldUnionID:
  50594. m.ResetUnionID()
  50595. return nil
  50596. case wxcarduser.FieldSessionKey:
  50597. m.ResetSessionKey()
  50598. return nil
  50599. case wxcarduser.FieldIsVip:
  50600. m.ResetIsVip()
  50601. return nil
  50602. }
  50603. return fmt.Errorf("unknown WxCardUser field %s", name)
  50604. }
  50605. // AddedEdges returns all edge names that were set/added in this mutation.
  50606. func (m *WxCardUserMutation) AddedEdges() []string {
  50607. edges := make([]string, 0, 0)
  50608. return edges
  50609. }
  50610. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50611. // name in this mutation.
  50612. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50613. return nil
  50614. }
  50615. // RemovedEdges returns all edge names that were removed in this mutation.
  50616. func (m *WxCardUserMutation) RemovedEdges() []string {
  50617. edges := make([]string, 0, 0)
  50618. return edges
  50619. }
  50620. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50621. // the given name in this mutation.
  50622. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50623. return nil
  50624. }
  50625. // ClearedEdges returns all edge names that were cleared in this mutation.
  50626. func (m *WxCardUserMutation) ClearedEdges() []string {
  50627. edges := make([]string, 0, 0)
  50628. return edges
  50629. }
  50630. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50631. // was cleared in this mutation.
  50632. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50633. return false
  50634. }
  50635. // ClearEdge clears the value of the edge with the given name. It returns an error
  50636. // if that edge is not defined in the schema.
  50637. func (m *WxCardUserMutation) ClearEdge(name string) error {
  50638. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  50639. }
  50640. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50641. // It returns an error if the edge is not defined in the schema.
  50642. func (m *WxCardUserMutation) ResetEdge(name string) error {
  50643. return fmt.Errorf("unknown WxCardUser edge %s", name)
  50644. }
  50645. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  50646. type WxCardVisitMutation struct {
  50647. config
  50648. op Op
  50649. typ string
  50650. id *uint64
  50651. created_at *time.Time
  50652. updated_at *time.Time
  50653. deleted_at *time.Time
  50654. user_id *uint64
  50655. adduser_id *int64
  50656. bot_id *uint64
  50657. addbot_id *int64
  50658. bot_type *uint8
  50659. addbot_type *int8
  50660. clearedFields map[string]struct{}
  50661. done bool
  50662. oldValue func(context.Context) (*WxCardVisit, error)
  50663. predicates []predicate.WxCardVisit
  50664. }
  50665. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  50666. // wxcardvisitOption allows management of the mutation configuration using functional options.
  50667. type wxcardvisitOption func(*WxCardVisitMutation)
  50668. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  50669. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  50670. m := &WxCardVisitMutation{
  50671. config: c,
  50672. op: op,
  50673. typ: TypeWxCardVisit,
  50674. clearedFields: make(map[string]struct{}),
  50675. }
  50676. for _, opt := range opts {
  50677. opt(m)
  50678. }
  50679. return m
  50680. }
  50681. // withWxCardVisitID sets the ID field of the mutation.
  50682. func withWxCardVisitID(id uint64) wxcardvisitOption {
  50683. return func(m *WxCardVisitMutation) {
  50684. var (
  50685. err error
  50686. once sync.Once
  50687. value *WxCardVisit
  50688. )
  50689. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  50690. once.Do(func() {
  50691. if m.done {
  50692. err = errors.New("querying old values post mutation is not allowed")
  50693. } else {
  50694. value, err = m.Client().WxCardVisit.Get(ctx, id)
  50695. }
  50696. })
  50697. return value, err
  50698. }
  50699. m.id = &id
  50700. }
  50701. }
  50702. // withWxCardVisit sets the old WxCardVisit of the mutation.
  50703. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  50704. return func(m *WxCardVisitMutation) {
  50705. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  50706. return node, nil
  50707. }
  50708. m.id = &node.ID
  50709. }
  50710. }
  50711. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50712. // executed in a transaction (ent.Tx), a transactional client is returned.
  50713. func (m WxCardVisitMutation) Client() *Client {
  50714. client := &Client{config: m.config}
  50715. client.init()
  50716. return client
  50717. }
  50718. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50719. // it returns an error otherwise.
  50720. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  50721. if _, ok := m.driver.(*txDriver); !ok {
  50722. return nil, errors.New("ent: mutation is not running in a transaction")
  50723. }
  50724. tx := &Tx{config: m.config}
  50725. tx.init()
  50726. return tx, nil
  50727. }
  50728. // SetID sets the value of the id field. Note that this
  50729. // operation is only accepted on creation of WxCardVisit entities.
  50730. func (m *WxCardVisitMutation) SetID(id uint64) {
  50731. m.id = &id
  50732. }
  50733. // ID returns the ID value in the mutation. Note that the ID is only available
  50734. // if it was provided to the builder or after it was returned from the database.
  50735. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  50736. if m.id == nil {
  50737. return
  50738. }
  50739. return *m.id, true
  50740. }
  50741. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50742. // That means, if the mutation is applied within a transaction with an isolation level such
  50743. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50744. // or updated by the mutation.
  50745. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  50746. switch {
  50747. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50748. id, exists := m.ID()
  50749. if exists {
  50750. return []uint64{id}, nil
  50751. }
  50752. fallthrough
  50753. case m.op.Is(OpUpdate | OpDelete):
  50754. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  50755. default:
  50756. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50757. }
  50758. }
  50759. // SetCreatedAt sets the "created_at" field.
  50760. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  50761. m.created_at = &t
  50762. }
  50763. // CreatedAt returns the value of the "created_at" field in the mutation.
  50764. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  50765. v := m.created_at
  50766. if v == nil {
  50767. return
  50768. }
  50769. return *v, true
  50770. }
  50771. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  50772. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50774. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50775. if !m.op.Is(OpUpdateOne) {
  50776. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50777. }
  50778. if m.id == nil || m.oldValue == nil {
  50779. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50780. }
  50781. oldValue, err := m.oldValue(ctx)
  50782. if err != nil {
  50783. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50784. }
  50785. return oldValue.CreatedAt, nil
  50786. }
  50787. // ResetCreatedAt resets all changes to the "created_at" field.
  50788. func (m *WxCardVisitMutation) ResetCreatedAt() {
  50789. m.created_at = nil
  50790. }
  50791. // SetUpdatedAt sets the "updated_at" field.
  50792. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  50793. m.updated_at = &t
  50794. }
  50795. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50796. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  50797. v := m.updated_at
  50798. if v == nil {
  50799. return
  50800. }
  50801. return *v, true
  50802. }
  50803. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  50804. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50806. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50807. if !m.op.Is(OpUpdateOne) {
  50808. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50809. }
  50810. if m.id == nil || m.oldValue == nil {
  50811. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50812. }
  50813. oldValue, err := m.oldValue(ctx)
  50814. if err != nil {
  50815. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50816. }
  50817. return oldValue.UpdatedAt, nil
  50818. }
  50819. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50820. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  50821. m.updated_at = nil
  50822. }
  50823. // SetDeletedAt sets the "deleted_at" field.
  50824. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  50825. m.deleted_at = &t
  50826. }
  50827. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50828. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  50829. v := m.deleted_at
  50830. if v == nil {
  50831. return
  50832. }
  50833. return *v, true
  50834. }
  50835. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  50836. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50838. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50839. if !m.op.Is(OpUpdateOne) {
  50840. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50841. }
  50842. if m.id == nil || m.oldValue == nil {
  50843. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50844. }
  50845. oldValue, err := m.oldValue(ctx)
  50846. if err != nil {
  50847. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50848. }
  50849. return oldValue.DeletedAt, nil
  50850. }
  50851. // ClearDeletedAt clears the value of the "deleted_at" field.
  50852. func (m *WxCardVisitMutation) ClearDeletedAt() {
  50853. m.deleted_at = nil
  50854. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  50855. }
  50856. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50857. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  50858. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  50859. return ok
  50860. }
  50861. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50862. func (m *WxCardVisitMutation) ResetDeletedAt() {
  50863. m.deleted_at = nil
  50864. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  50865. }
  50866. // SetUserID sets the "user_id" field.
  50867. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  50868. m.user_id = &u
  50869. m.adduser_id = nil
  50870. }
  50871. // UserID returns the value of the "user_id" field in the mutation.
  50872. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  50873. v := m.user_id
  50874. if v == nil {
  50875. return
  50876. }
  50877. return *v, true
  50878. }
  50879. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  50880. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50882. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  50883. if !m.op.Is(OpUpdateOne) {
  50884. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  50885. }
  50886. if m.id == nil || m.oldValue == nil {
  50887. return v, errors.New("OldUserID requires an ID field in the mutation")
  50888. }
  50889. oldValue, err := m.oldValue(ctx)
  50890. if err != nil {
  50891. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  50892. }
  50893. return oldValue.UserID, nil
  50894. }
  50895. // AddUserID adds u to the "user_id" field.
  50896. func (m *WxCardVisitMutation) AddUserID(u int64) {
  50897. if m.adduser_id != nil {
  50898. *m.adduser_id += u
  50899. } else {
  50900. m.adduser_id = &u
  50901. }
  50902. }
  50903. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  50904. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  50905. v := m.adduser_id
  50906. if v == nil {
  50907. return
  50908. }
  50909. return *v, true
  50910. }
  50911. // ClearUserID clears the value of the "user_id" field.
  50912. func (m *WxCardVisitMutation) ClearUserID() {
  50913. m.user_id = nil
  50914. m.adduser_id = nil
  50915. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  50916. }
  50917. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  50918. func (m *WxCardVisitMutation) UserIDCleared() bool {
  50919. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  50920. return ok
  50921. }
  50922. // ResetUserID resets all changes to the "user_id" field.
  50923. func (m *WxCardVisitMutation) ResetUserID() {
  50924. m.user_id = nil
  50925. m.adduser_id = nil
  50926. delete(m.clearedFields, wxcardvisit.FieldUserID)
  50927. }
  50928. // SetBotID sets the "bot_id" field.
  50929. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  50930. m.bot_id = &u
  50931. m.addbot_id = nil
  50932. }
  50933. // BotID returns the value of the "bot_id" field in the mutation.
  50934. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  50935. v := m.bot_id
  50936. if v == nil {
  50937. return
  50938. }
  50939. return *v, true
  50940. }
  50941. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  50942. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50944. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  50945. if !m.op.Is(OpUpdateOne) {
  50946. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  50947. }
  50948. if m.id == nil || m.oldValue == nil {
  50949. return v, errors.New("OldBotID requires an ID field in the mutation")
  50950. }
  50951. oldValue, err := m.oldValue(ctx)
  50952. if err != nil {
  50953. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  50954. }
  50955. return oldValue.BotID, nil
  50956. }
  50957. // AddBotID adds u to the "bot_id" field.
  50958. func (m *WxCardVisitMutation) AddBotID(u int64) {
  50959. if m.addbot_id != nil {
  50960. *m.addbot_id += u
  50961. } else {
  50962. m.addbot_id = &u
  50963. }
  50964. }
  50965. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  50966. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  50967. v := m.addbot_id
  50968. if v == nil {
  50969. return
  50970. }
  50971. return *v, true
  50972. }
  50973. // ResetBotID resets all changes to the "bot_id" field.
  50974. func (m *WxCardVisitMutation) ResetBotID() {
  50975. m.bot_id = nil
  50976. m.addbot_id = nil
  50977. }
  50978. // SetBotType sets the "bot_type" field.
  50979. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  50980. m.bot_type = &u
  50981. m.addbot_type = nil
  50982. }
  50983. // BotType returns the value of the "bot_type" field in the mutation.
  50984. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  50985. v := m.bot_type
  50986. if v == nil {
  50987. return
  50988. }
  50989. return *v, true
  50990. }
  50991. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  50992. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  50993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50994. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  50995. if !m.op.Is(OpUpdateOne) {
  50996. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  50997. }
  50998. if m.id == nil || m.oldValue == nil {
  50999. return v, errors.New("OldBotType requires an ID field in the mutation")
  51000. }
  51001. oldValue, err := m.oldValue(ctx)
  51002. if err != nil {
  51003. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51004. }
  51005. return oldValue.BotType, nil
  51006. }
  51007. // AddBotType adds u to the "bot_type" field.
  51008. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51009. if m.addbot_type != nil {
  51010. *m.addbot_type += u
  51011. } else {
  51012. m.addbot_type = &u
  51013. }
  51014. }
  51015. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51016. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51017. v := m.addbot_type
  51018. if v == nil {
  51019. return
  51020. }
  51021. return *v, true
  51022. }
  51023. // ResetBotType resets all changes to the "bot_type" field.
  51024. func (m *WxCardVisitMutation) ResetBotType() {
  51025. m.bot_type = nil
  51026. m.addbot_type = nil
  51027. }
  51028. // Where appends a list predicates to the WxCardVisitMutation builder.
  51029. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51030. m.predicates = append(m.predicates, ps...)
  51031. }
  51032. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51033. // users can use type-assertion to append predicates that do not depend on any generated package.
  51034. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51035. p := make([]predicate.WxCardVisit, len(ps))
  51036. for i := range ps {
  51037. p[i] = ps[i]
  51038. }
  51039. m.Where(p...)
  51040. }
  51041. // Op returns the operation name.
  51042. func (m *WxCardVisitMutation) Op() Op {
  51043. return m.op
  51044. }
  51045. // SetOp allows setting the mutation operation.
  51046. func (m *WxCardVisitMutation) SetOp(op Op) {
  51047. m.op = op
  51048. }
  51049. // Type returns the node type of this mutation (WxCardVisit).
  51050. func (m *WxCardVisitMutation) Type() string {
  51051. return m.typ
  51052. }
  51053. // Fields returns all fields that were changed during this mutation. Note that in
  51054. // order to get all numeric fields that were incremented/decremented, call
  51055. // AddedFields().
  51056. func (m *WxCardVisitMutation) Fields() []string {
  51057. fields := make([]string, 0, 6)
  51058. if m.created_at != nil {
  51059. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51060. }
  51061. if m.updated_at != nil {
  51062. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51063. }
  51064. if m.deleted_at != nil {
  51065. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51066. }
  51067. if m.user_id != nil {
  51068. fields = append(fields, wxcardvisit.FieldUserID)
  51069. }
  51070. if m.bot_id != nil {
  51071. fields = append(fields, wxcardvisit.FieldBotID)
  51072. }
  51073. if m.bot_type != nil {
  51074. fields = append(fields, wxcardvisit.FieldBotType)
  51075. }
  51076. return fields
  51077. }
  51078. // Field returns the value of a field with the given name. The second boolean
  51079. // return value indicates that this field was not set, or was not defined in the
  51080. // schema.
  51081. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51082. switch name {
  51083. case wxcardvisit.FieldCreatedAt:
  51084. return m.CreatedAt()
  51085. case wxcardvisit.FieldUpdatedAt:
  51086. return m.UpdatedAt()
  51087. case wxcardvisit.FieldDeletedAt:
  51088. return m.DeletedAt()
  51089. case wxcardvisit.FieldUserID:
  51090. return m.UserID()
  51091. case wxcardvisit.FieldBotID:
  51092. return m.BotID()
  51093. case wxcardvisit.FieldBotType:
  51094. return m.BotType()
  51095. }
  51096. return nil, false
  51097. }
  51098. // OldField returns the old value of the field from the database. An error is
  51099. // returned if the mutation operation is not UpdateOne, or the query to the
  51100. // database failed.
  51101. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51102. switch name {
  51103. case wxcardvisit.FieldCreatedAt:
  51104. return m.OldCreatedAt(ctx)
  51105. case wxcardvisit.FieldUpdatedAt:
  51106. return m.OldUpdatedAt(ctx)
  51107. case wxcardvisit.FieldDeletedAt:
  51108. return m.OldDeletedAt(ctx)
  51109. case wxcardvisit.FieldUserID:
  51110. return m.OldUserID(ctx)
  51111. case wxcardvisit.FieldBotID:
  51112. return m.OldBotID(ctx)
  51113. case wxcardvisit.FieldBotType:
  51114. return m.OldBotType(ctx)
  51115. }
  51116. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51117. }
  51118. // SetField sets the value of a field with the given name. It returns an error if
  51119. // the field is not defined in the schema, or if the type mismatched the field
  51120. // type.
  51121. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51122. switch name {
  51123. case wxcardvisit.FieldCreatedAt:
  51124. v, ok := value.(time.Time)
  51125. if !ok {
  51126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51127. }
  51128. m.SetCreatedAt(v)
  51129. return nil
  51130. case wxcardvisit.FieldUpdatedAt:
  51131. v, ok := value.(time.Time)
  51132. if !ok {
  51133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51134. }
  51135. m.SetUpdatedAt(v)
  51136. return nil
  51137. case wxcardvisit.FieldDeletedAt:
  51138. v, ok := value.(time.Time)
  51139. if !ok {
  51140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51141. }
  51142. m.SetDeletedAt(v)
  51143. return nil
  51144. case wxcardvisit.FieldUserID:
  51145. v, ok := value.(uint64)
  51146. if !ok {
  51147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51148. }
  51149. m.SetUserID(v)
  51150. return nil
  51151. case wxcardvisit.FieldBotID:
  51152. v, ok := value.(uint64)
  51153. if !ok {
  51154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51155. }
  51156. m.SetBotID(v)
  51157. return nil
  51158. case wxcardvisit.FieldBotType:
  51159. v, ok := value.(uint8)
  51160. if !ok {
  51161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51162. }
  51163. m.SetBotType(v)
  51164. return nil
  51165. }
  51166. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51167. }
  51168. // AddedFields returns all numeric fields that were incremented/decremented during
  51169. // this mutation.
  51170. func (m *WxCardVisitMutation) AddedFields() []string {
  51171. var fields []string
  51172. if m.adduser_id != nil {
  51173. fields = append(fields, wxcardvisit.FieldUserID)
  51174. }
  51175. if m.addbot_id != nil {
  51176. fields = append(fields, wxcardvisit.FieldBotID)
  51177. }
  51178. if m.addbot_type != nil {
  51179. fields = append(fields, wxcardvisit.FieldBotType)
  51180. }
  51181. return fields
  51182. }
  51183. // AddedField returns the numeric value that was incremented/decremented on a field
  51184. // with the given name. The second boolean return value indicates that this field
  51185. // was not set, or was not defined in the schema.
  51186. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51187. switch name {
  51188. case wxcardvisit.FieldUserID:
  51189. return m.AddedUserID()
  51190. case wxcardvisit.FieldBotID:
  51191. return m.AddedBotID()
  51192. case wxcardvisit.FieldBotType:
  51193. return m.AddedBotType()
  51194. }
  51195. return nil, false
  51196. }
  51197. // AddField adds the value to the field with the given name. It returns an error if
  51198. // the field is not defined in the schema, or if the type mismatched the field
  51199. // type.
  51200. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51201. switch name {
  51202. case wxcardvisit.FieldUserID:
  51203. v, ok := value.(int64)
  51204. if !ok {
  51205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51206. }
  51207. m.AddUserID(v)
  51208. return nil
  51209. case wxcardvisit.FieldBotID:
  51210. v, ok := value.(int64)
  51211. if !ok {
  51212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51213. }
  51214. m.AddBotID(v)
  51215. return nil
  51216. case wxcardvisit.FieldBotType:
  51217. v, ok := value.(int8)
  51218. if !ok {
  51219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51220. }
  51221. m.AddBotType(v)
  51222. return nil
  51223. }
  51224. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51225. }
  51226. // ClearedFields returns all nullable fields that were cleared during this
  51227. // mutation.
  51228. func (m *WxCardVisitMutation) ClearedFields() []string {
  51229. var fields []string
  51230. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51231. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51232. }
  51233. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51234. fields = append(fields, wxcardvisit.FieldUserID)
  51235. }
  51236. return fields
  51237. }
  51238. // FieldCleared returns a boolean indicating if a field with the given name was
  51239. // cleared in this mutation.
  51240. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51241. _, ok := m.clearedFields[name]
  51242. return ok
  51243. }
  51244. // ClearField clears the value of the field with the given name. It returns an
  51245. // error if the field is not defined in the schema.
  51246. func (m *WxCardVisitMutation) ClearField(name string) error {
  51247. switch name {
  51248. case wxcardvisit.FieldDeletedAt:
  51249. m.ClearDeletedAt()
  51250. return nil
  51251. case wxcardvisit.FieldUserID:
  51252. m.ClearUserID()
  51253. return nil
  51254. }
  51255. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51256. }
  51257. // ResetField resets all changes in the mutation for the field with the given name.
  51258. // It returns an error if the field is not defined in the schema.
  51259. func (m *WxCardVisitMutation) ResetField(name string) error {
  51260. switch name {
  51261. case wxcardvisit.FieldCreatedAt:
  51262. m.ResetCreatedAt()
  51263. return nil
  51264. case wxcardvisit.FieldUpdatedAt:
  51265. m.ResetUpdatedAt()
  51266. return nil
  51267. case wxcardvisit.FieldDeletedAt:
  51268. m.ResetDeletedAt()
  51269. return nil
  51270. case wxcardvisit.FieldUserID:
  51271. m.ResetUserID()
  51272. return nil
  51273. case wxcardvisit.FieldBotID:
  51274. m.ResetBotID()
  51275. return nil
  51276. case wxcardvisit.FieldBotType:
  51277. m.ResetBotType()
  51278. return nil
  51279. }
  51280. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51281. }
  51282. // AddedEdges returns all edge names that were set/added in this mutation.
  51283. func (m *WxCardVisitMutation) AddedEdges() []string {
  51284. edges := make([]string, 0, 0)
  51285. return edges
  51286. }
  51287. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51288. // name in this mutation.
  51289. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51290. return nil
  51291. }
  51292. // RemovedEdges returns all edge names that were removed in this mutation.
  51293. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51294. edges := make([]string, 0, 0)
  51295. return edges
  51296. }
  51297. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51298. // the given name in this mutation.
  51299. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51300. return nil
  51301. }
  51302. // ClearedEdges returns all edge names that were cleared in this mutation.
  51303. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51304. edges := make([]string, 0, 0)
  51305. return edges
  51306. }
  51307. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51308. // was cleared in this mutation.
  51309. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51310. return false
  51311. }
  51312. // ClearEdge clears the value of the edge with the given name. It returns an error
  51313. // if that edge is not defined in the schema.
  51314. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51315. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51316. }
  51317. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51318. // It returns an error if the edge is not defined in the schema.
  51319. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51320. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51321. }
  51322. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51323. type XunjiMutation struct {
  51324. config
  51325. op Op
  51326. typ string
  51327. id *uint64
  51328. created_at *time.Time
  51329. updated_at *time.Time
  51330. status *uint8
  51331. addstatus *int8
  51332. deleted_at *time.Time
  51333. app_key *string
  51334. app_secret *string
  51335. token *string
  51336. encoding_key *string
  51337. organization_id *uint64
  51338. addorganization_id *int64
  51339. clearedFields map[string]struct{}
  51340. done bool
  51341. oldValue func(context.Context) (*Xunji, error)
  51342. predicates []predicate.Xunji
  51343. }
  51344. var _ ent.Mutation = (*XunjiMutation)(nil)
  51345. // xunjiOption allows management of the mutation configuration using functional options.
  51346. type xunjiOption func(*XunjiMutation)
  51347. // newXunjiMutation creates new mutation for the Xunji entity.
  51348. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51349. m := &XunjiMutation{
  51350. config: c,
  51351. op: op,
  51352. typ: TypeXunji,
  51353. clearedFields: make(map[string]struct{}),
  51354. }
  51355. for _, opt := range opts {
  51356. opt(m)
  51357. }
  51358. return m
  51359. }
  51360. // withXunjiID sets the ID field of the mutation.
  51361. func withXunjiID(id uint64) xunjiOption {
  51362. return func(m *XunjiMutation) {
  51363. var (
  51364. err error
  51365. once sync.Once
  51366. value *Xunji
  51367. )
  51368. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51369. once.Do(func() {
  51370. if m.done {
  51371. err = errors.New("querying old values post mutation is not allowed")
  51372. } else {
  51373. value, err = m.Client().Xunji.Get(ctx, id)
  51374. }
  51375. })
  51376. return value, err
  51377. }
  51378. m.id = &id
  51379. }
  51380. }
  51381. // withXunji sets the old Xunji of the mutation.
  51382. func withXunji(node *Xunji) xunjiOption {
  51383. return func(m *XunjiMutation) {
  51384. m.oldValue = func(context.Context) (*Xunji, error) {
  51385. return node, nil
  51386. }
  51387. m.id = &node.ID
  51388. }
  51389. }
  51390. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51391. // executed in a transaction (ent.Tx), a transactional client is returned.
  51392. func (m XunjiMutation) Client() *Client {
  51393. client := &Client{config: m.config}
  51394. client.init()
  51395. return client
  51396. }
  51397. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51398. // it returns an error otherwise.
  51399. func (m XunjiMutation) Tx() (*Tx, error) {
  51400. if _, ok := m.driver.(*txDriver); !ok {
  51401. return nil, errors.New("ent: mutation is not running in a transaction")
  51402. }
  51403. tx := &Tx{config: m.config}
  51404. tx.init()
  51405. return tx, nil
  51406. }
  51407. // SetID sets the value of the id field. Note that this
  51408. // operation is only accepted on creation of Xunji entities.
  51409. func (m *XunjiMutation) SetID(id uint64) {
  51410. m.id = &id
  51411. }
  51412. // ID returns the ID value in the mutation. Note that the ID is only available
  51413. // if it was provided to the builder or after it was returned from the database.
  51414. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51415. if m.id == nil {
  51416. return
  51417. }
  51418. return *m.id, true
  51419. }
  51420. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51421. // That means, if the mutation is applied within a transaction with an isolation level such
  51422. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51423. // or updated by the mutation.
  51424. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51425. switch {
  51426. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51427. id, exists := m.ID()
  51428. if exists {
  51429. return []uint64{id}, nil
  51430. }
  51431. fallthrough
  51432. case m.op.Is(OpUpdate | OpDelete):
  51433. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51434. default:
  51435. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51436. }
  51437. }
  51438. // SetCreatedAt sets the "created_at" field.
  51439. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51440. m.created_at = &t
  51441. }
  51442. // CreatedAt returns the value of the "created_at" field in the mutation.
  51443. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51444. v := m.created_at
  51445. if v == nil {
  51446. return
  51447. }
  51448. return *v, true
  51449. }
  51450. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51451. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51453. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51454. if !m.op.Is(OpUpdateOne) {
  51455. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51456. }
  51457. if m.id == nil || m.oldValue == nil {
  51458. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51459. }
  51460. oldValue, err := m.oldValue(ctx)
  51461. if err != nil {
  51462. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51463. }
  51464. return oldValue.CreatedAt, nil
  51465. }
  51466. // ResetCreatedAt resets all changes to the "created_at" field.
  51467. func (m *XunjiMutation) ResetCreatedAt() {
  51468. m.created_at = nil
  51469. }
  51470. // SetUpdatedAt sets the "updated_at" field.
  51471. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51472. m.updated_at = &t
  51473. }
  51474. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51475. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51476. v := m.updated_at
  51477. if v == nil {
  51478. return
  51479. }
  51480. return *v, true
  51481. }
  51482. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51483. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51485. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51486. if !m.op.Is(OpUpdateOne) {
  51487. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51488. }
  51489. if m.id == nil || m.oldValue == nil {
  51490. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51491. }
  51492. oldValue, err := m.oldValue(ctx)
  51493. if err != nil {
  51494. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51495. }
  51496. return oldValue.UpdatedAt, nil
  51497. }
  51498. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51499. func (m *XunjiMutation) ResetUpdatedAt() {
  51500. m.updated_at = nil
  51501. }
  51502. // SetStatus sets the "status" field.
  51503. func (m *XunjiMutation) SetStatus(u uint8) {
  51504. m.status = &u
  51505. m.addstatus = nil
  51506. }
  51507. // Status returns the value of the "status" field in the mutation.
  51508. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51509. v := m.status
  51510. if v == nil {
  51511. return
  51512. }
  51513. return *v, true
  51514. }
  51515. // OldStatus returns the old "status" field's value of the Xunji entity.
  51516. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51518. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51519. if !m.op.Is(OpUpdateOne) {
  51520. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51521. }
  51522. if m.id == nil || m.oldValue == nil {
  51523. return v, errors.New("OldStatus requires an ID field in the mutation")
  51524. }
  51525. oldValue, err := m.oldValue(ctx)
  51526. if err != nil {
  51527. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51528. }
  51529. return oldValue.Status, nil
  51530. }
  51531. // AddStatus adds u to the "status" field.
  51532. func (m *XunjiMutation) AddStatus(u int8) {
  51533. if m.addstatus != nil {
  51534. *m.addstatus += u
  51535. } else {
  51536. m.addstatus = &u
  51537. }
  51538. }
  51539. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51540. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51541. v := m.addstatus
  51542. if v == nil {
  51543. return
  51544. }
  51545. return *v, true
  51546. }
  51547. // ClearStatus clears the value of the "status" field.
  51548. func (m *XunjiMutation) ClearStatus() {
  51549. m.status = nil
  51550. m.addstatus = nil
  51551. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51552. }
  51553. // StatusCleared returns if the "status" field was cleared in this mutation.
  51554. func (m *XunjiMutation) StatusCleared() bool {
  51555. _, ok := m.clearedFields[xunji.FieldStatus]
  51556. return ok
  51557. }
  51558. // ResetStatus resets all changes to the "status" field.
  51559. func (m *XunjiMutation) ResetStatus() {
  51560. m.status = nil
  51561. m.addstatus = nil
  51562. delete(m.clearedFields, xunji.FieldStatus)
  51563. }
  51564. // SetDeletedAt sets the "deleted_at" field.
  51565. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51566. m.deleted_at = &t
  51567. }
  51568. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51569. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51570. v := m.deleted_at
  51571. if v == nil {
  51572. return
  51573. }
  51574. return *v, true
  51575. }
  51576. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51577. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51579. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51580. if !m.op.Is(OpUpdateOne) {
  51581. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51582. }
  51583. if m.id == nil || m.oldValue == nil {
  51584. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51585. }
  51586. oldValue, err := m.oldValue(ctx)
  51587. if err != nil {
  51588. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51589. }
  51590. return oldValue.DeletedAt, nil
  51591. }
  51592. // ClearDeletedAt clears the value of the "deleted_at" field.
  51593. func (m *XunjiMutation) ClearDeletedAt() {
  51594. m.deleted_at = nil
  51595. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51596. }
  51597. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51598. func (m *XunjiMutation) DeletedAtCleared() bool {
  51599. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51600. return ok
  51601. }
  51602. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51603. func (m *XunjiMutation) ResetDeletedAt() {
  51604. m.deleted_at = nil
  51605. delete(m.clearedFields, xunji.FieldDeletedAt)
  51606. }
  51607. // SetAppKey sets the "app_key" field.
  51608. func (m *XunjiMutation) SetAppKey(s string) {
  51609. m.app_key = &s
  51610. }
  51611. // AppKey returns the value of the "app_key" field in the mutation.
  51612. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51613. v := m.app_key
  51614. if v == nil {
  51615. return
  51616. }
  51617. return *v, true
  51618. }
  51619. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51620. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51622. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51623. if !m.op.Is(OpUpdateOne) {
  51624. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51625. }
  51626. if m.id == nil || m.oldValue == nil {
  51627. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51628. }
  51629. oldValue, err := m.oldValue(ctx)
  51630. if err != nil {
  51631. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51632. }
  51633. return oldValue.AppKey, nil
  51634. }
  51635. // ClearAppKey clears the value of the "app_key" field.
  51636. func (m *XunjiMutation) ClearAppKey() {
  51637. m.app_key = nil
  51638. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  51639. }
  51640. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  51641. func (m *XunjiMutation) AppKeyCleared() bool {
  51642. _, ok := m.clearedFields[xunji.FieldAppKey]
  51643. return ok
  51644. }
  51645. // ResetAppKey resets all changes to the "app_key" field.
  51646. func (m *XunjiMutation) ResetAppKey() {
  51647. m.app_key = nil
  51648. delete(m.clearedFields, xunji.FieldAppKey)
  51649. }
  51650. // SetAppSecret sets the "app_secret" field.
  51651. func (m *XunjiMutation) SetAppSecret(s string) {
  51652. m.app_secret = &s
  51653. }
  51654. // AppSecret returns the value of the "app_secret" field in the mutation.
  51655. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  51656. v := m.app_secret
  51657. if v == nil {
  51658. return
  51659. }
  51660. return *v, true
  51661. }
  51662. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  51663. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51665. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  51666. if !m.op.Is(OpUpdateOne) {
  51667. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  51668. }
  51669. if m.id == nil || m.oldValue == nil {
  51670. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  51671. }
  51672. oldValue, err := m.oldValue(ctx)
  51673. if err != nil {
  51674. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  51675. }
  51676. return oldValue.AppSecret, nil
  51677. }
  51678. // ClearAppSecret clears the value of the "app_secret" field.
  51679. func (m *XunjiMutation) ClearAppSecret() {
  51680. m.app_secret = nil
  51681. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  51682. }
  51683. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  51684. func (m *XunjiMutation) AppSecretCleared() bool {
  51685. _, ok := m.clearedFields[xunji.FieldAppSecret]
  51686. return ok
  51687. }
  51688. // ResetAppSecret resets all changes to the "app_secret" field.
  51689. func (m *XunjiMutation) ResetAppSecret() {
  51690. m.app_secret = nil
  51691. delete(m.clearedFields, xunji.FieldAppSecret)
  51692. }
  51693. // SetToken sets the "token" field.
  51694. func (m *XunjiMutation) SetToken(s string) {
  51695. m.token = &s
  51696. }
  51697. // Token returns the value of the "token" field in the mutation.
  51698. func (m *XunjiMutation) Token() (r string, exists bool) {
  51699. v := m.token
  51700. if v == nil {
  51701. return
  51702. }
  51703. return *v, true
  51704. }
  51705. // OldToken returns the old "token" field's value of the Xunji entity.
  51706. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51708. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  51709. if !m.op.Is(OpUpdateOne) {
  51710. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  51711. }
  51712. if m.id == nil || m.oldValue == nil {
  51713. return v, errors.New("OldToken requires an ID field in the mutation")
  51714. }
  51715. oldValue, err := m.oldValue(ctx)
  51716. if err != nil {
  51717. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  51718. }
  51719. return oldValue.Token, nil
  51720. }
  51721. // ClearToken clears the value of the "token" field.
  51722. func (m *XunjiMutation) ClearToken() {
  51723. m.token = nil
  51724. m.clearedFields[xunji.FieldToken] = struct{}{}
  51725. }
  51726. // TokenCleared returns if the "token" field was cleared in this mutation.
  51727. func (m *XunjiMutation) TokenCleared() bool {
  51728. _, ok := m.clearedFields[xunji.FieldToken]
  51729. return ok
  51730. }
  51731. // ResetToken resets all changes to the "token" field.
  51732. func (m *XunjiMutation) ResetToken() {
  51733. m.token = nil
  51734. delete(m.clearedFields, xunji.FieldToken)
  51735. }
  51736. // SetEncodingKey sets the "encoding_key" field.
  51737. func (m *XunjiMutation) SetEncodingKey(s string) {
  51738. m.encoding_key = &s
  51739. }
  51740. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  51741. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  51742. v := m.encoding_key
  51743. if v == nil {
  51744. return
  51745. }
  51746. return *v, true
  51747. }
  51748. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  51749. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51751. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  51752. if !m.op.Is(OpUpdateOne) {
  51753. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  51754. }
  51755. if m.id == nil || m.oldValue == nil {
  51756. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  51757. }
  51758. oldValue, err := m.oldValue(ctx)
  51759. if err != nil {
  51760. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  51761. }
  51762. return oldValue.EncodingKey, nil
  51763. }
  51764. // ClearEncodingKey clears the value of the "encoding_key" field.
  51765. func (m *XunjiMutation) ClearEncodingKey() {
  51766. m.encoding_key = nil
  51767. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  51768. }
  51769. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  51770. func (m *XunjiMutation) EncodingKeyCleared() bool {
  51771. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  51772. return ok
  51773. }
  51774. // ResetEncodingKey resets all changes to the "encoding_key" field.
  51775. func (m *XunjiMutation) ResetEncodingKey() {
  51776. m.encoding_key = nil
  51777. delete(m.clearedFields, xunji.FieldEncodingKey)
  51778. }
  51779. // SetOrganizationID sets the "organization_id" field.
  51780. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  51781. m.organization_id = &u
  51782. m.addorganization_id = nil
  51783. }
  51784. // OrganizationID returns the value of the "organization_id" field in the mutation.
  51785. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  51786. v := m.organization_id
  51787. if v == nil {
  51788. return
  51789. }
  51790. return *v, true
  51791. }
  51792. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  51793. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51795. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  51796. if !m.op.Is(OpUpdateOne) {
  51797. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  51798. }
  51799. if m.id == nil || m.oldValue == nil {
  51800. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  51801. }
  51802. oldValue, err := m.oldValue(ctx)
  51803. if err != nil {
  51804. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  51805. }
  51806. return oldValue.OrganizationID, nil
  51807. }
  51808. // AddOrganizationID adds u to the "organization_id" field.
  51809. func (m *XunjiMutation) AddOrganizationID(u int64) {
  51810. if m.addorganization_id != nil {
  51811. *m.addorganization_id += u
  51812. } else {
  51813. m.addorganization_id = &u
  51814. }
  51815. }
  51816. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  51817. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  51818. v := m.addorganization_id
  51819. if v == nil {
  51820. return
  51821. }
  51822. return *v, true
  51823. }
  51824. // ResetOrganizationID resets all changes to the "organization_id" field.
  51825. func (m *XunjiMutation) ResetOrganizationID() {
  51826. m.organization_id = nil
  51827. m.addorganization_id = nil
  51828. }
  51829. // Where appends a list predicates to the XunjiMutation builder.
  51830. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  51831. m.predicates = append(m.predicates, ps...)
  51832. }
  51833. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  51834. // users can use type-assertion to append predicates that do not depend on any generated package.
  51835. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  51836. p := make([]predicate.Xunji, len(ps))
  51837. for i := range ps {
  51838. p[i] = ps[i]
  51839. }
  51840. m.Where(p...)
  51841. }
  51842. // Op returns the operation name.
  51843. func (m *XunjiMutation) Op() Op {
  51844. return m.op
  51845. }
  51846. // SetOp allows setting the mutation operation.
  51847. func (m *XunjiMutation) SetOp(op Op) {
  51848. m.op = op
  51849. }
  51850. // Type returns the node type of this mutation (Xunji).
  51851. func (m *XunjiMutation) Type() string {
  51852. return m.typ
  51853. }
  51854. // Fields returns all fields that were changed during this mutation. Note that in
  51855. // order to get all numeric fields that were incremented/decremented, call
  51856. // AddedFields().
  51857. func (m *XunjiMutation) Fields() []string {
  51858. fields := make([]string, 0, 9)
  51859. if m.created_at != nil {
  51860. fields = append(fields, xunji.FieldCreatedAt)
  51861. }
  51862. if m.updated_at != nil {
  51863. fields = append(fields, xunji.FieldUpdatedAt)
  51864. }
  51865. if m.status != nil {
  51866. fields = append(fields, xunji.FieldStatus)
  51867. }
  51868. if m.deleted_at != nil {
  51869. fields = append(fields, xunji.FieldDeletedAt)
  51870. }
  51871. if m.app_key != nil {
  51872. fields = append(fields, xunji.FieldAppKey)
  51873. }
  51874. if m.app_secret != nil {
  51875. fields = append(fields, xunji.FieldAppSecret)
  51876. }
  51877. if m.token != nil {
  51878. fields = append(fields, xunji.FieldToken)
  51879. }
  51880. if m.encoding_key != nil {
  51881. fields = append(fields, xunji.FieldEncodingKey)
  51882. }
  51883. if m.organization_id != nil {
  51884. fields = append(fields, xunji.FieldOrganizationID)
  51885. }
  51886. return fields
  51887. }
  51888. // Field returns the value of a field with the given name. The second boolean
  51889. // return value indicates that this field was not set, or was not defined in the
  51890. // schema.
  51891. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  51892. switch name {
  51893. case xunji.FieldCreatedAt:
  51894. return m.CreatedAt()
  51895. case xunji.FieldUpdatedAt:
  51896. return m.UpdatedAt()
  51897. case xunji.FieldStatus:
  51898. return m.Status()
  51899. case xunji.FieldDeletedAt:
  51900. return m.DeletedAt()
  51901. case xunji.FieldAppKey:
  51902. return m.AppKey()
  51903. case xunji.FieldAppSecret:
  51904. return m.AppSecret()
  51905. case xunji.FieldToken:
  51906. return m.Token()
  51907. case xunji.FieldEncodingKey:
  51908. return m.EncodingKey()
  51909. case xunji.FieldOrganizationID:
  51910. return m.OrganizationID()
  51911. }
  51912. return nil, false
  51913. }
  51914. // OldField returns the old value of the field from the database. An error is
  51915. // returned if the mutation operation is not UpdateOne, or the query to the
  51916. // database failed.
  51917. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51918. switch name {
  51919. case xunji.FieldCreatedAt:
  51920. return m.OldCreatedAt(ctx)
  51921. case xunji.FieldUpdatedAt:
  51922. return m.OldUpdatedAt(ctx)
  51923. case xunji.FieldStatus:
  51924. return m.OldStatus(ctx)
  51925. case xunji.FieldDeletedAt:
  51926. return m.OldDeletedAt(ctx)
  51927. case xunji.FieldAppKey:
  51928. return m.OldAppKey(ctx)
  51929. case xunji.FieldAppSecret:
  51930. return m.OldAppSecret(ctx)
  51931. case xunji.FieldToken:
  51932. return m.OldToken(ctx)
  51933. case xunji.FieldEncodingKey:
  51934. return m.OldEncodingKey(ctx)
  51935. case xunji.FieldOrganizationID:
  51936. return m.OldOrganizationID(ctx)
  51937. }
  51938. return nil, fmt.Errorf("unknown Xunji field %s", name)
  51939. }
  51940. // SetField sets the value of a field with the given name. It returns an error if
  51941. // the field is not defined in the schema, or if the type mismatched the field
  51942. // type.
  51943. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  51944. switch name {
  51945. case xunji.FieldCreatedAt:
  51946. v, ok := value.(time.Time)
  51947. if !ok {
  51948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51949. }
  51950. m.SetCreatedAt(v)
  51951. return nil
  51952. case xunji.FieldUpdatedAt:
  51953. v, ok := value.(time.Time)
  51954. if !ok {
  51955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51956. }
  51957. m.SetUpdatedAt(v)
  51958. return nil
  51959. case xunji.FieldStatus:
  51960. v, ok := value.(uint8)
  51961. if !ok {
  51962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51963. }
  51964. m.SetStatus(v)
  51965. return nil
  51966. case xunji.FieldDeletedAt:
  51967. v, ok := value.(time.Time)
  51968. if !ok {
  51969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51970. }
  51971. m.SetDeletedAt(v)
  51972. return nil
  51973. case xunji.FieldAppKey:
  51974. v, ok := value.(string)
  51975. if !ok {
  51976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51977. }
  51978. m.SetAppKey(v)
  51979. return nil
  51980. case xunji.FieldAppSecret:
  51981. v, ok := value.(string)
  51982. if !ok {
  51983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51984. }
  51985. m.SetAppSecret(v)
  51986. return nil
  51987. case xunji.FieldToken:
  51988. v, ok := value.(string)
  51989. if !ok {
  51990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51991. }
  51992. m.SetToken(v)
  51993. return nil
  51994. case xunji.FieldEncodingKey:
  51995. v, ok := value.(string)
  51996. if !ok {
  51997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51998. }
  51999. m.SetEncodingKey(v)
  52000. return nil
  52001. case xunji.FieldOrganizationID:
  52002. v, ok := value.(uint64)
  52003. if !ok {
  52004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52005. }
  52006. m.SetOrganizationID(v)
  52007. return nil
  52008. }
  52009. return fmt.Errorf("unknown Xunji field %s", name)
  52010. }
  52011. // AddedFields returns all numeric fields that were incremented/decremented during
  52012. // this mutation.
  52013. func (m *XunjiMutation) AddedFields() []string {
  52014. var fields []string
  52015. if m.addstatus != nil {
  52016. fields = append(fields, xunji.FieldStatus)
  52017. }
  52018. if m.addorganization_id != nil {
  52019. fields = append(fields, xunji.FieldOrganizationID)
  52020. }
  52021. return fields
  52022. }
  52023. // AddedField returns the numeric value that was incremented/decremented on a field
  52024. // with the given name. The second boolean return value indicates that this field
  52025. // was not set, or was not defined in the schema.
  52026. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52027. switch name {
  52028. case xunji.FieldStatus:
  52029. return m.AddedStatus()
  52030. case xunji.FieldOrganizationID:
  52031. return m.AddedOrganizationID()
  52032. }
  52033. return nil, false
  52034. }
  52035. // AddField adds the value to the field with the given name. It returns an error if
  52036. // the field is not defined in the schema, or if the type mismatched the field
  52037. // type.
  52038. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52039. switch name {
  52040. case xunji.FieldStatus:
  52041. v, ok := value.(int8)
  52042. if !ok {
  52043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52044. }
  52045. m.AddStatus(v)
  52046. return nil
  52047. case xunji.FieldOrganizationID:
  52048. v, ok := value.(int64)
  52049. if !ok {
  52050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52051. }
  52052. m.AddOrganizationID(v)
  52053. return nil
  52054. }
  52055. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52056. }
  52057. // ClearedFields returns all nullable fields that were cleared during this
  52058. // mutation.
  52059. func (m *XunjiMutation) ClearedFields() []string {
  52060. var fields []string
  52061. if m.FieldCleared(xunji.FieldStatus) {
  52062. fields = append(fields, xunji.FieldStatus)
  52063. }
  52064. if m.FieldCleared(xunji.FieldDeletedAt) {
  52065. fields = append(fields, xunji.FieldDeletedAt)
  52066. }
  52067. if m.FieldCleared(xunji.FieldAppKey) {
  52068. fields = append(fields, xunji.FieldAppKey)
  52069. }
  52070. if m.FieldCleared(xunji.FieldAppSecret) {
  52071. fields = append(fields, xunji.FieldAppSecret)
  52072. }
  52073. if m.FieldCleared(xunji.FieldToken) {
  52074. fields = append(fields, xunji.FieldToken)
  52075. }
  52076. if m.FieldCleared(xunji.FieldEncodingKey) {
  52077. fields = append(fields, xunji.FieldEncodingKey)
  52078. }
  52079. return fields
  52080. }
  52081. // FieldCleared returns a boolean indicating if a field with the given name was
  52082. // cleared in this mutation.
  52083. func (m *XunjiMutation) FieldCleared(name string) bool {
  52084. _, ok := m.clearedFields[name]
  52085. return ok
  52086. }
  52087. // ClearField clears the value of the field with the given name. It returns an
  52088. // error if the field is not defined in the schema.
  52089. func (m *XunjiMutation) ClearField(name string) error {
  52090. switch name {
  52091. case xunji.FieldStatus:
  52092. m.ClearStatus()
  52093. return nil
  52094. case xunji.FieldDeletedAt:
  52095. m.ClearDeletedAt()
  52096. return nil
  52097. case xunji.FieldAppKey:
  52098. m.ClearAppKey()
  52099. return nil
  52100. case xunji.FieldAppSecret:
  52101. m.ClearAppSecret()
  52102. return nil
  52103. case xunji.FieldToken:
  52104. m.ClearToken()
  52105. return nil
  52106. case xunji.FieldEncodingKey:
  52107. m.ClearEncodingKey()
  52108. return nil
  52109. }
  52110. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52111. }
  52112. // ResetField resets all changes in the mutation for the field with the given name.
  52113. // It returns an error if the field is not defined in the schema.
  52114. func (m *XunjiMutation) ResetField(name string) error {
  52115. switch name {
  52116. case xunji.FieldCreatedAt:
  52117. m.ResetCreatedAt()
  52118. return nil
  52119. case xunji.FieldUpdatedAt:
  52120. m.ResetUpdatedAt()
  52121. return nil
  52122. case xunji.FieldStatus:
  52123. m.ResetStatus()
  52124. return nil
  52125. case xunji.FieldDeletedAt:
  52126. m.ResetDeletedAt()
  52127. return nil
  52128. case xunji.FieldAppKey:
  52129. m.ResetAppKey()
  52130. return nil
  52131. case xunji.FieldAppSecret:
  52132. m.ResetAppSecret()
  52133. return nil
  52134. case xunji.FieldToken:
  52135. m.ResetToken()
  52136. return nil
  52137. case xunji.FieldEncodingKey:
  52138. m.ResetEncodingKey()
  52139. return nil
  52140. case xunji.FieldOrganizationID:
  52141. m.ResetOrganizationID()
  52142. return nil
  52143. }
  52144. return fmt.Errorf("unknown Xunji field %s", name)
  52145. }
  52146. // AddedEdges returns all edge names that were set/added in this mutation.
  52147. func (m *XunjiMutation) AddedEdges() []string {
  52148. edges := make([]string, 0, 0)
  52149. return edges
  52150. }
  52151. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52152. // name in this mutation.
  52153. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52154. return nil
  52155. }
  52156. // RemovedEdges returns all edge names that were removed in this mutation.
  52157. func (m *XunjiMutation) RemovedEdges() []string {
  52158. edges := make([]string, 0, 0)
  52159. return edges
  52160. }
  52161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52162. // the given name in this mutation.
  52163. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52164. return nil
  52165. }
  52166. // ClearedEdges returns all edge names that were cleared in this mutation.
  52167. func (m *XunjiMutation) ClearedEdges() []string {
  52168. edges := make([]string, 0, 0)
  52169. return edges
  52170. }
  52171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52172. // was cleared in this mutation.
  52173. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52174. return false
  52175. }
  52176. // ClearEdge clears the value of the edge with the given name. It returns an error
  52177. // if that edge is not defined in the schema.
  52178. func (m *XunjiMutation) ClearEdge(name string) error {
  52179. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52180. }
  52181. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52182. // It returns an error if the edge is not defined in the schema.
  52183. func (m *XunjiMutation) ResetEdge(name string) error {
  52184. return fmt.Errorf("unknown Xunji edge %s", name)
  52185. }
  52186. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52187. type XunjiServiceMutation struct {
  52188. config
  52189. op Op
  52190. typ string
  52191. id *uint64
  52192. created_at *time.Time
  52193. updated_at *time.Time
  52194. status *uint8
  52195. addstatus *int8
  52196. deleted_at *time.Time
  52197. xunji_id *uint64
  52198. addxunji_id *int64
  52199. organization_id *uint64
  52200. addorganization_id *int64
  52201. wxid *string
  52202. api_base *string
  52203. api_key *string
  52204. clearedFields map[string]struct{}
  52205. agent *uint64
  52206. clearedagent bool
  52207. done bool
  52208. oldValue func(context.Context) (*XunjiService, error)
  52209. predicates []predicate.XunjiService
  52210. }
  52211. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52212. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52213. type xunjiserviceOption func(*XunjiServiceMutation)
  52214. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52215. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52216. m := &XunjiServiceMutation{
  52217. config: c,
  52218. op: op,
  52219. typ: TypeXunjiService,
  52220. clearedFields: make(map[string]struct{}),
  52221. }
  52222. for _, opt := range opts {
  52223. opt(m)
  52224. }
  52225. return m
  52226. }
  52227. // withXunjiServiceID sets the ID field of the mutation.
  52228. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52229. return func(m *XunjiServiceMutation) {
  52230. var (
  52231. err error
  52232. once sync.Once
  52233. value *XunjiService
  52234. )
  52235. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52236. once.Do(func() {
  52237. if m.done {
  52238. err = errors.New("querying old values post mutation is not allowed")
  52239. } else {
  52240. value, err = m.Client().XunjiService.Get(ctx, id)
  52241. }
  52242. })
  52243. return value, err
  52244. }
  52245. m.id = &id
  52246. }
  52247. }
  52248. // withXunjiService sets the old XunjiService of the mutation.
  52249. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52250. return func(m *XunjiServiceMutation) {
  52251. m.oldValue = func(context.Context) (*XunjiService, error) {
  52252. return node, nil
  52253. }
  52254. m.id = &node.ID
  52255. }
  52256. }
  52257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52258. // executed in a transaction (ent.Tx), a transactional client is returned.
  52259. func (m XunjiServiceMutation) Client() *Client {
  52260. client := &Client{config: m.config}
  52261. client.init()
  52262. return client
  52263. }
  52264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52265. // it returns an error otherwise.
  52266. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52267. if _, ok := m.driver.(*txDriver); !ok {
  52268. return nil, errors.New("ent: mutation is not running in a transaction")
  52269. }
  52270. tx := &Tx{config: m.config}
  52271. tx.init()
  52272. return tx, nil
  52273. }
  52274. // SetID sets the value of the id field. Note that this
  52275. // operation is only accepted on creation of XunjiService entities.
  52276. func (m *XunjiServiceMutation) SetID(id uint64) {
  52277. m.id = &id
  52278. }
  52279. // ID returns the ID value in the mutation. Note that the ID is only available
  52280. // if it was provided to the builder or after it was returned from the database.
  52281. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52282. if m.id == nil {
  52283. return
  52284. }
  52285. return *m.id, true
  52286. }
  52287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52288. // That means, if the mutation is applied within a transaction with an isolation level such
  52289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52290. // or updated by the mutation.
  52291. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52292. switch {
  52293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52294. id, exists := m.ID()
  52295. if exists {
  52296. return []uint64{id}, nil
  52297. }
  52298. fallthrough
  52299. case m.op.Is(OpUpdate | OpDelete):
  52300. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52301. default:
  52302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52303. }
  52304. }
  52305. // SetCreatedAt sets the "created_at" field.
  52306. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52307. m.created_at = &t
  52308. }
  52309. // CreatedAt returns the value of the "created_at" field in the mutation.
  52310. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52311. v := m.created_at
  52312. if v == nil {
  52313. return
  52314. }
  52315. return *v, true
  52316. }
  52317. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52318. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52320. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52321. if !m.op.Is(OpUpdateOne) {
  52322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52323. }
  52324. if m.id == nil || m.oldValue == nil {
  52325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52326. }
  52327. oldValue, err := m.oldValue(ctx)
  52328. if err != nil {
  52329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52330. }
  52331. return oldValue.CreatedAt, nil
  52332. }
  52333. // ResetCreatedAt resets all changes to the "created_at" field.
  52334. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52335. m.created_at = nil
  52336. }
  52337. // SetUpdatedAt sets the "updated_at" field.
  52338. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52339. m.updated_at = &t
  52340. }
  52341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52342. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52343. v := m.updated_at
  52344. if v == nil {
  52345. return
  52346. }
  52347. return *v, true
  52348. }
  52349. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52350. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52352. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52353. if !m.op.Is(OpUpdateOne) {
  52354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52355. }
  52356. if m.id == nil || m.oldValue == nil {
  52357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52358. }
  52359. oldValue, err := m.oldValue(ctx)
  52360. if err != nil {
  52361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52362. }
  52363. return oldValue.UpdatedAt, nil
  52364. }
  52365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52366. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52367. m.updated_at = nil
  52368. }
  52369. // SetStatus sets the "status" field.
  52370. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52371. m.status = &u
  52372. m.addstatus = nil
  52373. }
  52374. // Status returns the value of the "status" field in the mutation.
  52375. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52376. v := m.status
  52377. if v == nil {
  52378. return
  52379. }
  52380. return *v, true
  52381. }
  52382. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52383. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52385. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52386. if !m.op.Is(OpUpdateOne) {
  52387. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52388. }
  52389. if m.id == nil || m.oldValue == nil {
  52390. return v, errors.New("OldStatus requires an ID field in the mutation")
  52391. }
  52392. oldValue, err := m.oldValue(ctx)
  52393. if err != nil {
  52394. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52395. }
  52396. return oldValue.Status, nil
  52397. }
  52398. // AddStatus adds u to the "status" field.
  52399. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52400. if m.addstatus != nil {
  52401. *m.addstatus += u
  52402. } else {
  52403. m.addstatus = &u
  52404. }
  52405. }
  52406. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52407. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52408. v := m.addstatus
  52409. if v == nil {
  52410. return
  52411. }
  52412. return *v, true
  52413. }
  52414. // ClearStatus clears the value of the "status" field.
  52415. func (m *XunjiServiceMutation) ClearStatus() {
  52416. m.status = nil
  52417. m.addstatus = nil
  52418. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52419. }
  52420. // StatusCleared returns if the "status" field was cleared in this mutation.
  52421. func (m *XunjiServiceMutation) StatusCleared() bool {
  52422. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52423. return ok
  52424. }
  52425. // ResetStatus resets all changes to the "status" field.
  52426. func (m *XunjiServiceMutation) ResetStatus() {
  52427. m.status = nil
  52428. m.addstatus = nil
  52429. delete(m.clearedFields, xunjiservice.FieldStatus)
  52430. }
  52431. // SetDeletedAt sets the "deleted_at" field.
  52432. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52433. m.deleted_at = &t
  52434. }
  52435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52436. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52437. v := m.deleted_at
  52438. if v == nil {
  52439. return
  52440. }
  52441. return *v, true
  52442. }
  52443. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52444. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52446. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52447. if !m.op.Is(OpUpdateOne) {
  52448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52449. }
  52450. if m.id == nil || m.oldValue == nil {
  52451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52452. }
  52453. oldValue, err := m.oldValue(ctx)
  52454. if err != nil {
  52455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52456. }
  52457. return oldValue.DeletedAt, nil
  52458. }
  52459. // ClearDeletedAt clears the value of the "deleted_at" field.
  52460. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52461. m.deleted_at = nil
  52462. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52463. }
  52464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52465. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52466. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52467. return ok
  52468. }
  52469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52470. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52471. m.deleted_at = nil
  52472. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52473. }
  52474. // SetXunjiID sets the "xunji_id" field.
  52475. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52476. m.xunji_id = &u
  52477. m.addxunji_id = nil
  52478. }
  52479. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52480. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52481. v := m.xunji_id
  52482. if v == nil {
  52483. return
  52484. }
  52485. return *v, true
  52486. }
  52487. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52488. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52490. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52491. if !m.op.Is(OpUpdateOne) {
  52492. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52493. }
  52494. if m.id == nil || m.oldValue == nil {
  52495. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52496. }
  52497. oldValue, err := m.oldValue(ctx)
  52498. if err != nil {
  52499. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52500. }
  52501. return oldValue.XunjiID, nil
  52502. }
  52503. // AddXunjiID adds u to the "xunji_id" field.
  52504. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52505. if m.addxunji_id != nil {
  52506. *m.addxunji_id += u
  52507. } else {
  52508. m.addxunji_id = &u
  52509. }
  52510. }
  52511. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52512. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52513. v := m.addxunji_id
  52514. if v == nil {
  52515. return
  52516. }
  52517. return *v, true
  52518. }
  52519. // ResetXunjiID resets all changes to the "xunji_id" field.
  52520. func (m *XunjiServiceMutation) ResetXunjiID() {
  52521. m.xunji_id = nil
  52522. m.addxunji_id = nil
  52523. }
  52524. // SetAgentID sets the "agent_id" field.
  52525. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52526. m.agent = &u
  52527. }
  52528. // AgentID returns the value of the "agent_id" field in the mutation.
  52529. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52530. v := m.agent
  52531. if v == nil {
  52532. return
  52533. }
  52534. return *v, true
  52535. }
  52536. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52537. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52539. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52540. if !m.op.Is(OpUpdateOne) {
  52541. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52542. }
  52543. if m.id == nil || m.oldValue == nil {
  52544. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52545. }
  52546. oldValue, err := m.oldValue(ctx)
  52547. if err != nil {
  52548. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52549. }
  52550. return oldValue.AgentID, nil
  52551. }
  52552. // ResetAgentID resets all changes to the "agent_id" field.
  52553. func (m *XunjiServiceMutation) ResetAgentID() {
  52554. m.agent = nil
  52555. }
  52556. // SetOrganizationID sets the "organization_id" field.
  52557. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52558. m.organization_id = &u
  52559. m.addorganization_id = nil
  52560. }
  52561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52562. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52563. v := m.organization_id
  52564. if v == nil {
  52565. return
  52566. }
  52567. return *v, true
  52568. }
  52569. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52570. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52572. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52573. if !m.op.Is(OpUpdateOne) {
  52574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52575. }
  52576. if m.id == nil || m.oldValue == nil {
  52577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52578. }
  52579. oldValue, err := m.oldValue(ctx)
  52580. if err != nil {
  52581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52582. }
  52583. return oldValue.OrganizationID, nil
  52584. }
  52585. // AddOrganizationID adds u to the "organization_id" field.
  52586. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52587. if m.addorganization_id != nil {
  52588. *m.addorganization_id += u
  52589. } else {
  52590. m.addorganization_id = &u
  52591. }
  52592. }
  52593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52594. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52595. v := m.addorganization_id
  52596. if v == nil {
  52597. return
  52598. }
  52599. return *v, true
  52600. }
  52601. // ResetOrganizationID resets all changes to the "organization_id" field.
  52602. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52603. m.organization_id = nil
  52604. m.addorganization_id = nil
  52605. }
  52606. // SetWxid sets the "wxid" field.
  52607. func (m *XunjiServiceMutation) SetWxid(s string) {
  52608. m.wxid = &s
  52609. }
  52610. // Wxid returns the value of the "wxid" field in the mutation.
  52611. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52612. v := m.wxid
  52613. if v == nil {
  52614. return
  52615. }
  52616. return *v, true
  52617. }
  52618. // OldWxid returns the old "wxid" 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) OldWxid(ctx context.Context) (v string, err error) {
  52622. if !m.op.Is(OpUpdateOne) {
  52623. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52624. }
  52625. if m.id == nil || m.oldValue == nil {
  52626. return v, errors.New("OldWxid 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 OldWxid: %w", err)
  52631. }
  52632. return oldValue.Wxid, nil
  52633. }
  52634. // ResetWxid resets all changes to the "wxid" field.
  52635. func (m *XunjiServiceMutation) ResetWxid() {
  52636. m.wxid = nil
  52637. }
  52638. // SetAPIBase sets the "api_base" field.
  52639. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  52640. m.api_base = &s
  52641. }
  52642. // APIBase returns the value of the "api_base" field in the mutation.
  52643. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  52644. v := m.api_base
  52645. if v == nil {
  52646. return
  52647. }
  52648. return *v, true
  52649. }
  52650. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  52651. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52653. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  52654. if !m.op.Is(OpUpdateOne) {
  52655. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  52656. }
  52657. if m.id == nil || m.oldValue == nil {
  52658. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  52659. }
  52660. oldValue, err := m.oldValue(ctx)
  52661. if err != nil {
  52662. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  52663. }
  52664. return oldValue.APIBase, nil
  52665. }
  52666. // ClearAPIBase clears the value of the "api_base" field.
  52667. func (m *XunjiServiceMutation) ClearAPIBase() {
  52668. m.api_base = nil
  52669. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  52670. }
  52671. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  52672. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  52673. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  52674. return ok
  52675. }
  52676. // ResetAPIBase resets all changes to the "api_base" field.
  52677. func (m *XunjiServiceMutation) ResetAPIBase() {
  52678. m.api_base = nil
  52679. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  52680. }
  52681. // SetAPIKey sets the "api_key" field.
  52682. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  52683. m.api_key = &s
  52684. }
  52685. // APIKey returns the value of the "api_key" field in the mutation.
  52686. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  52687. v := m.api_key
  52688. if v == nil {
  52689. return
  52690. }
  52691. return *v, true
  52692. }
  52693. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  52694. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52696. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  52697. if !m.op.Is(OpUpdateOne) {
  52698. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  52699. }
  52700. if m.id == nil || m.oldValue == nil {
  52701. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  52702. }
  52703. oldValue, err := m.oldValue(ctx)
  52704. if err != nil {
  52705. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  52706. }
  52707. return oldValue.APIKey, nil
  52708. }
  52709. // ClearAPIKey clears the value of the "api_key" field.
  52710. func (m *XunjiServiceMutation) ClearAPIKey() {
  52711. m.api_key = nil
  52712. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  52713. }
  52714. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  52715. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  52716. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  52717. return ok
  52718. }
  52719. // ResetAPIKey resets all changes to the "api_key" field.
  52720. func (m *XunjiServiceMutation) ResetAPIKey() {
  52721. m.api_key = nil
  52722. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  52723. }
  52724. // ClearAgent clears the "agent" edge to the Agent entity.
  52725. func (m *XunjiServiceMutation) ClearAgent() {
  52726. m.clearedagent = true
  52727. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  52728. }
  52729. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  52730. func (m *XunjiServiceMutation) AgentCleared() bool {
  52731. return m.clearedagent
  52732. }
  52733. // AgentIDs returns the "agent" edge IDs in the mutation.
  52734. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52735. // AgentID instead. It exists only for internal usage by the builders.
  52736. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  52737. if id := m.agent; id != nil {
  52738. ids = append(ids, *id)
  52739. }
  52740. return
  52741. }
  52742. // ResetAgent resets all changes to the "agent" edge.
  52743. func (m *XunjiServiceMutation) ResetAgent() {
  52744. m.agent = nil
  52745. m.clearedagent = false
  52746. }
  52747. // Where appends a list predicates to the XunjiServiceMutation builder.
  52748. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  52749. m.predicates = append(m.predicates, ps...)
  52750. }
  52751. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  52752. // users can use type-assertion to append predicates that do not depend on any generated package.
  52753. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  52754. p := make([]predicate.XunjiService, len(ps))
  52755. for i := range ps {
  52756. p[i] = ps[i]
  52757. }
  52758. m.Where(p...)
  52759. }
  52760. // Op returns the operation name.
  52761. func (m *XunjiServiceMutation) Op() Op {
  52762. return m.op
  52763. }
  52764. // SetOp allows setting the mutation operation.
  52765. func (m *XunjiServiceMutation) SetOp(op Op) {
  52766. m.op = op
  52767. }
  52768. // Type returns the node type of this mutation (XunjiService).
  52769. func (m *XunjiServiceMutation) Type() string {
  52770. return m.typ
  52771. }
  52772. // Fields returns all fields that were changed during this mutation. Note that in
  52773. // order to get all numeric fields that were incremented/decremented, call
  52774. // AddedFields().
  52775. func (m *XunjiServiceMutation) Fields() []string {
  52776. fields := make([]string, 0, 10)
  52777. if m.created_at != nil {
  52778. fields = append(fields, xunjiservice.FieldCreatedAt)
  52779. }
  52780. if m.updated_at != nil {
  52781. fields = append(fields, xunjiservice.FieldUpdatedAt)
  52782. }
  52783. if m.status != nil {
  52784. fields = append(fields, xunjiservice.FieldStatus)
  52785. }
  52786. if m.deleted_at != nil {
  52787. fields = append(fields, xunjiservice.FieldDeletedAt)
  52788. }
  52789. if m.xunji_id != nil {
  52790. fields = append(fields, xunjiservice.FieldXunjiID)
  52791. }
  52792. if m.agent != nil {
  52793. fields = append(fields, xunjiservice.FieldAgentID)
  52794. }
  52795. if m.organization_id != nil {
  52796. fields = append(fields, xunjiservice.FieldOrganizationID)
  52797. }
  52798. if m.wxid != nil {
  52799. fields = append(fields, xunjiservice.FieldWxid)
  52800. }
  52801. if m.api_base != nil {
  52802. fields = append(fields, xunjiservice.FieldAPIBase)
  52803. }
  52804. if m.api_key != nil {
  52805. fields = append(fields, xunjiservice.FieldAPIKey)
  52806. }
  52807. return fields
  52808. }
  52809. // Field returns the value of a field with the given name. The second boolean
  52810. // return value indicates that this field was not set, or was not defined in the
  52811. // schema.
  52812. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  52813. switch name {
  52814. case xunjiservice.FieldCreatedAt:
  52815. return m.CreatedAt()
  52816. case xunjiservice.FieldUpdatedAt:
  52817. return m.UpdatedAt()
  52818. case xunjiservice.FieldStatus:
  52819. return m.Status()
  52820. case xunjiservice.FieldDeletedAt:
  52821. return m.DeletedAt()
  52822. case xunjiservice.FieldXunjiID:
  52823. return m.XunjiID()
  52824. case xunjiservice.FieldAgentID:
  52825. return m.AgentID()
  52826. case xunjiservice.FieldOrganizationID:
  52827. return m.OrganizationID()
  52828. case xunjiservice.FieldWxid:
  52829. return m.Wxid()
  52830. case xunjiservice.FieldAPIBase:
  52831. return m.APIBase()
  52832. case xunjiservice.FieldAPIKey:
  52833. return m.APIKey()
  52834. }
  52835. return nil, false
  52836. }
  52837. // OldField returns the old value of the field from the database. An error is
  52838. // returned if the mutation operation is not UpdateOne, or the query to the
  52839. // database failed.
  52840. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52841. switch name {
  52842. case xunjiservice.FieldCreatedAt:
  52843. return m.OldCreatedAt(ctx)
  52844. case xunjiservice.FieldUpdatedAt:
  52845. return m.OldUpdatedAt(ctx)
  52846. case xunjiservice.FieldStatus:
  52847. return m.OldStatus(ctx)
  52848. case xunjiservice.FieldDeletedAt:
  52849. return m.OldDeletedAt(ctx)
  52850. case xunjiservice.FieldXunjiID:
  52851. return m.OldXunjiID(ctx)
  52852. case xunjiservice.FieldAgentID:
  52853. return m.OldAgentID(ctx)
  52854. case xunjiservice.FieldOrganizationID:
  52855. return m.OldOrganizationID(ctx)
  52856. case xunjiservice.FieldWxid:
  52857. return m.OldWxid(ctx)
  52858. case xunjiservice.FieldAPIBase:
  52859. return m.OldAPIBase(ctx)
  52860. case xunjiservice.FieldAPIKey:
  52861. return m.OldAPIKey(ctx)
  52862. }
  52863. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  52864. }
  52865. // SetField sets the value of a field with the given name. It returns an error if
  52866. // the field is not defined in the schema, or if the type mismatched the field
  52867. // type.
  52868. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  52869. switch name {
  52870. case xunjiservice.FieldCreatedAt:
  52871. v, ok := value.(time.Time)
  52872. if !ok {
  52873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52874. }
  52875. m.SetCreatedAt(v)
  52876. return nil
  52877. case xunjiservice.FieldUpdatedAt:
  52878. v, ok := value.(time.Time)
  52879. if !ok {
  52880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52881. }
  52882. m.SetUpdatedAt(v)
  52883. return nil
  52884. case xunjiservice.FieldStatus:
  52885. v, ok := value.(uint8)
  52886. if !ok {
  52887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52888. }
  52889. m.SetStatus(v)
  52890. return nil
  52891. case xunjiservice.FieldDeletedAt:
  52892. v, ok := value.(time.Time)
  52893. if !ok {
  52894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52895. }
  52896. m.SetDeletedAt(v)
  52897. return nil
  52898. case xunjiservice.FieldXunjiID:
  52899. v, ok := value.(uint64)
  52900. if !ok {
  52901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52902. }
  52903. m.SetXunjiID(v)
  52904. return nil
  52905. case xunjiservice.FieldAgentID:
  52906. v, ok := value.(uint64)
  52907. if !ok {
  52908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52909. }
  52910. m.SetAgentID(v)
  52911. return nil
  52912. case xunjiservice.FieldOrganizationID:
  52913. v, ok := value.(uint64)
  52914. if !ok {
  52915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52916. }
  52917. m.SetOrganizationID(v)
  52918. return nil
  52919. case xunjiservice.FieldWxid:
  52920. v, ok := value.(string)
  52921. if !ok {
  52922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52923. }
  52924. m.SetWxid(v)
  52925. return nil
  52926. case xunjiservice.FieldAPIBase:
  52927. v, ok := value.(string)
  52928. if !ok {
  52929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52930. }
  52931. m.SetAPIBase(v)
  52932. return nil
  52933. case xunjiservice.FieldAPIKey:
  52934. v, ok := value.(string)
  52935. if !ok {
  52936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52937. }
  52938. m.SetAPIKey(v)
  52939. return nil
  52940. }
  52941. return fmt.Errorf("unknown XunjiService field %s", name)
  52942. }
  52943. // AddedFields returns all numeric fields that were incremented/decremented during
  52944. // this mutation.
  52945. func (m *XunjiServiceMutation) AddedFields() []string {
  52946. var fields []string
  52947. if m.addstatus != nil {
  52948. fields = append(fields, xunjiservice.FieldStatus)
  52949. }
  52950. if m.addxunji_id != nil {
  52951. fields = append(fields, xunjiservice.FieldXunjiID)
  52952. }
  52953. if m.addorganization_id != nil {
  52954. fields = append(fields, xunjiservice.FieldOrganizationID)
  52955. }
  52956. return fields
  52957. }
  52958. // AddedField returns the numeric value that was incremented/decremented on a field
  52959. // with the given name. The second boolean return value indicates that this field
  52960. // was not set, or was not defined in the schema.
  52961. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  52962. switch name {
  52963. case xunjiservice.FieldStatus:
  52964. return m.AddedStatus()
  52965. case xunjiservice.FieldXunjiID:
  52966. return m.AddedXunjiID()
  52967. case xunjiservice.FieldOrganizationID:
  52968. return m.AddedOrganizationID()
  52969. }
  52970. return nil, false
  52971. }
  52972. // AddField adds the value to the field with the given name. It returns an error if
  52973. // the field is not defined in the schema, or if the type mismatched the field
  52974. // type.
  52975. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  52976. switch name {
  52977. case xunjiservice.FieldStatus:
  52978. v, ok := value.(int8)
  52979. if !ok {
  52980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52981. }
  52982. m.AddStatus(v)
  52983. return nil
  52984. case xunjiservice.FieldXunjiID:
  52985. v, ok := value.(int64)
  52986. if !ok {
  52987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52988. }
  52989. m.AddXunjiID(v)
  52990. return nil
  52991. case xunjiservice.FieldOrganizationID:
  52992. v, ok := value.(int64)
  52993. if !ok {
  52994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52995. }
  52996. m.AddOrganizationID(v)
  52997. return nil
  52998. }
  52999. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53000. }
  53001. // ClearedFields returns all nullable fields that were cleared during this
  53002. // mutation.
  53003. func (m *XunjiServiceMutation) ClearedFields() []string {
  53004. var fields []string
  53005. if m.FieldCleared(xunjiservice.FieldStatus) {
  53006. fields = append(fields, xunjiservice.FieldStatus)
  53007. }
  53008. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53009. fields = append(fields, xunjiservice.FieldDeletedAt)
  53010. }
  53011. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53012. fields = append(fields, xunjiservice.FieldAPIBase)
  53013. }
  53014. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53015. fields = append(fields, xunjiservice.FieldAPIKey)
  53016. }
  53017. return fields
  53018. }
  53019. // FieldCleared returns a boolean indicating if a field with the given name was
  53020. // cleared in this mutation.
  53021. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53022. _, ok := m.clearedFields[name]
  53023. return ok
  53024. }
  53025. // ClearField clears the value of the field with the given name. It returns an
  53026. // error if the field is not defined in the schema.
  53027. func (m *XunjiServiceMutation) ClearField(name string) error {
  53028. switch name {
  53029. case xunjiservice.FieldStatus:
  53030. m.ClearStatus()
  53031. return nil
  53032. case xunjiservice.FieldDeletedAt:
  53033. m.ClearDeletedAt()
  53034. return nil
  53035. case xunjiservice.FieldAPIBase:
  53036. m.ClearAPIBase()
  53037. return nil
  53038. case xunjiservice.FieldAPIKey:
  53039. m.ClearAPIKey()
  53040. return nil
  53041. }
  53042. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53043. }
  53044. // ResetField resets all changes in the mutation for the field with the given name.
  53045. // It returns an error if the field is not defined in the schema.
  53046. func (m *XunjiServiceMutation) ResetField(name string) error {
  53047. switch name {
  53048. case xunjiservice.FieldCreatedAt:
  53049. m.ResetCreatedAt()
  53050. return nil
  53051. case xunjiservice.FieldUpdatedAt:
  53052. m.ResetUpdatedAt()
  53053. return nil
  53054. case xunjiservice.FieldStatus:
  53055. m.ResetStatus()
  53056. return nil
  53057. case xunjiservice.FieldDeletedAt:
  53058. m.ResetDeletedAt()
  53059. return nil
  53060. case xunjiservice.FieldXunjiID:
  53061. m.ResetXunjiID()
  53062. return nil
  53063. case xunjiservice.FieldAgentID:
  53064. m.ResetAgentID()
  53065. return nil
  53066. case xunjiservice.FieldOrganizationID:
  53067. m.ResetOrganizationID()
  53068. return nil
  53069. case xunjiservice.FieldWxid:
  53070. m.ResetWxid()
  53071. return nil
  53072. case xunjiservice.FieldAPIBase:
  53073. m.ResetAPIBase()
  53074. return nil
  53075. case xunjiservice.FieldAPIKey:
  53076. m.ResetAPIKey()
  53077. return nil
  53078. }
  53079. return fmt.Errorf("unknown XunjiService field %s", name)
  53080. }
  53081. // AddedEdges returns all edge names that were set/added in this mutation.
  53082. func (m *XunjiServiceMutation) AddedEdges() []string {
  53083. edges := make([]string, 0, 1)
  53084. if m.agent != nil {
  53085. edges = append(edges, xunjiservice.EdgeAgent)
  53086. }
  53087. return edges
  53088. }
  53089. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53090. // name in this mutation.
  53091. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53092. switch name {
  53093. case xunjiservice.EdgeAgent:
  53094. if id := m.agent; id != nil {
  53095. return []ent.Value{*id}
  53096. }
  53097. }
  53098. return nil
  53099. }
  53100. // RemovedEdges returns all edge names that were removed in this mutation.
  53101. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53102. edges := make([]string, 0, 1)
  53103. return edges
  53104. }
  53105. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53106. // the given name in this mutation.
  53107. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53108. return nil
  53109. }
  53110. // ClearedEdges returns all edge names that were cleared in this mutation.
  53111. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53112. edges := make([]string, 0, 1)
  53113. if m.clearedagent {
  53114. edges = append(edges, xunjiservice.EdgeAgent)
  53115. }
  53116. return edges
  53117. }
  53118. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53119. // was cleared in this mutation.
  53120. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53121. switch name {
  53122. case xunjiservice.EdgeAgent:
  53123. return m.clearedagent
  53124. }
  53125. return false
  53126. }
  53127. // ClearEdge clears the value of the edge with the given name. It returns an error
  53128. // if that edge is not defined in the schema.
  53129. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53130. switch name {
  53131. case xunjiservice.EdgeAgent:
  53132. m.ClearAgent()
  53133. return nil
  53134. }
  53135. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53136. }
  53137. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53138. // It returns an error if the edge is not defined in the schema.
  53139. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53140. switch name {
  53141. case xunjiservice.EdgeAgent:
  53142. m.ResetAgent()
  53143. return nil
  53144. }
  53145. return fmt.Errorf("unknown XunjiService edge %s", name)
  53146. }