mutation.go 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/contactfield"
  20. "wechat-api/ent/contactfieldtemplate"
  21. "wechat-api/ent/creditbalance"
  22. "wechat-api/ent/creditusage"
  23. "wechat-api/ent/custom_types"
  24. "wechat-api/ent/employee"
  25. "wechat-api/ent/employeeconfig"
  26. "wechat-api/ent/label"
  27. "wechat-api/ent/labelrelationship"
  28. "wechat-api/ent/labeltagging"
  29. "wechat-api/ent/message"
  30. "wechat-api/ent/messagerecords"
  31. "wechat-api/ent/msg"
  32. "wechat-api/ent/payrecharge"
  33. "wechat-api/ent/predicate"
  34. "wechat-api/ent/server"
  35. "wechat-api/ent/sopnode"
  36. "wechat-api/ent/sopstage"
  37. "wechat-api/ent/soptask"
  38. "wechat-api/ent/token"
  39. "wechat-api/ent/tutorial"
  40. "wechat-api/ent/usagedetail"
  41. "wechat-api/ent/usagestatisticday"
  42. "wechat-api/ent/usagestatistichour"
  43. "wechat-api/ent/usagestatisticmonth"
  44. "wechat-api/ent/usagetotal"
  45. "wechat-api/ent/whatsapp"
  46. "wechat-api/ent/whatsappchannel"
  47. "wechat-api/ent/workexperience"
  48. "wechat-api/ent/wpchatroom"
  49. "wechat-api/ent/wpchatroommember"
  50. "wechat-api/ent/wx"
  51. "wechat-api/ent/wxcard"
  52. "wechat-api/ent/wxcarduser"
  53. "wechat-api/ent/wxcardvisit"
  54. "wechat-api/ent/xunji"
  55. "wechat-api/ent/xunjiservice"
  56. "entgo.io/ent"
  57. "entgo.io/ent/dialect/sql"
  58. )
  59. const (
  60. // Operation types.
  61. OpCreate = ent.OpCreate
  62. OpDelete = ent.OpDelete
  63. OpDeleteOne = ent.OpDeleteOne
  64. OpUpdate = ent.OpUpdate
  65. OpUpdateOne = ent.OpUpdateOne
  66. // Node types.
  67. TypeAgent = "Agent"
  68. TypeAgentBase = "AgentBase"
  69. TypeAliyunAvatar = "AliyunAvatar"
  70. TypeAllocAgent = "AllocAgent"
  71. TypeApiKey = "ApiKey"
  72. TypeBatchMsg = "BatchMsg"
  73. TypeCategory = "Category"
  74. TypeChatRecords = "ChatRecords"
  75. TypeChatSession = "ChatSession"
  76. TypeContact = "Contact"
  77. TypeContactField = "ContactField"
  78. TypeContactFieldTemplate = "ContactFieldTemplate"
  79. TypeCreditBalance = "CreditBalance"
  80. TypeCreditUsage = "CreditUsage"
  81. TypeEmployee = "Employee"
  82. TypeEmployeeConfig = "EmployeeConfig"
  83. TypeLabel = "Label"
  84. TypeLabelRelationship = "LabelRelationship"
  85. TypeLabelTagging = "LabelTagging"
  86. TypeMessage = "Message"
  87. TypeMessageRecords = "MessageRecords"
  88. TypeMsg = "Msg"
  89. TypePayRecharge = "PayRecharge"
  90. TypeServer = "Server"
  91. TypeSopNode = "SopNode"
  92. TypeSopStage = "SopStage"
  93. TypeSopTask = "SopTask"
  94. TypeToken = "Token"
  95. TypeTutorial = "Tutorial"
  96. TypeUsageDetail = "UsageDetail"
  97. TypeUsageStatisticDay = "UsageStatisticDay"
  98. TypeUsageStatisticHour = "UsageStatisticHour"
  99. TypeUsageStatisticMonth = "UsageStatisticMonth"
  100. TypeUsageTotal = "UsageTotal"
  101. TypeWhatsapp = "Whatsapp"
  102. TypeWhatsappChannel = "WhatsappChannel"
  103. TypeWorkExperience = "WorkExperience"
  104. TypeWpChatroom = "WpChatroom"
  105. TypeWpChatroomMember = "WpChatroomMember"
  106. TypeWx = "Wx"
  107. TypeWxCard = "WxCard"
  108. TypeWxCardUser = "WxCardUser"
  109. TypeWxCardVisit = "WxCardVisit"
  110. TypeXunji = "Xunji"
  111. TypeXunjiService = "XunjiService"
  112. )
  113. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  114. type AgentMutation struct {
  115. config
  116. op Op
  117. typ string
  118. id *uint64
  119. created_at *time.Time
  120. updated_at *time.Time
  121. deleted_at *time.Time
  122. name *string
  123. role *string
  124. status *int
  125. addstatus *int
  126. background *string
  127. examples *string
  128. organization_id *uint64
  129. addorganization_id *int64
  130. dataset_id *string
  131. collection_id *string
  132. model *string
  133. api_base *string
  134. api_key *string
  135. _type *int
  136. add_type *int
  137. clearedFields map[string]struct{}
  138. wx_agent map[uint64]struct{}
  139. removedwx_agent map[uint64]struct{}
  140. clearedwx_agent bool
  141. token_agent map[uint64]struct{}
  142. removedtoken_agent map[uint64]struct{}
  143. clearedtoken_agent bool
  144. wa_agent map[uint64]struct{}
  145. removedwa_agent map[uint64]struct{}
  146. clearedwa_agent bool
  147. xjs_agent map[uint64]struct{}
  148. removedxjs_agent map[uint64]struct{}
  149. clearedxjs_agent bool
  150. key_agent map[uint64]struct{}
  151. removedkey_agent map[uint64]struct{}
  152. clearedkey_agent bool
  153. done bool
  154. oldValue func(context.Context) (*Agent, error)
  155. predicates []predicate.Agent
  156. }
  157. var _ ent.Mutation = (*AgentMutation)(nil)
  158. // agentOption allows management of the mutation configuration using functional options.
  159. type agentOption func(*AgentMutation)
  160. // newAgentMutation creates new mutation for the Agent entity.
  161. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  162. m := &AgentMutation{
  163. config: c,
  164. op: op,
  165. typ: TypeAgent,
  166. clearedFields: make(map[string]struct{}),
  167. }
  168. for _, opt := range opts {
  169. opt(m)
  170. }
  171. return m
  172. }
  173. // withAgentID sets the ID field of the mutation.
  174. func withAgentID(id uint64) agentOption {
  175. return func(m *AgentMutation) {
  176. var (
  177. err error
  178. once sync.Once
  179. value *Agent
  180. )
  181. m.oldValue = func(ctx context.Context) (*Agent, error) {
  182. once.Do(func() {
  183. if m.done {
  184. err = errors.New("querying old values post mutation is not allowed")
  185. } else {
  186. value, err = m.Client().Agent.Get(ctx, id)
  187. }
  188. })
  189. return value, err
  190. }
  191. m.id = &id
  192. }
  193. }
  194. // withAgent sets the old Agent of the mutation.
  195. func withAgent(node *Agent) agentOption {
  196. return func(m *AgentMutation) {
  197. m.oldValue = func(context.Context) (*Agent, error) {
  198. return node, nil
  199. }
  200. m.id = &node.ID
  201. }
  202. }
  203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  204. // executed in a transaction (ent.Tx), a transactional client is returned.
  205. func (m AgentMutation) Client() *Client {
  206. client := &Client{config: m.config}
  207. client.init()
  208. return client
  209. }
  210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  211. // it returns an error otherwise.
  212. func (m AgentMutation) Tx() (*Tx, error) {
  213. if _, ok := m.driver.(*txDriver); !ok {
  214. return nil, errors.New("ent: mutation is not running in a transaction")
  215. }
  216. tx := &Tx{config: m.config}
  217. tx.init()
  218. return tx, nil
  219. }
  220. // SetID sets the value of the id field. Note that this
  221. // operation is only accepted on creation of Agent entities.
  222. func (m *AgentMutation) SetID(id uint64) {
  223. m.id = &id
  224. }
  225. // ID returns the ID value in the mutation. Note that the ID is only available
  226. // if it was provided to the builder or after it was returned from the database.
  227. func (m *AgentMutation) ID() (id uint64, exists bool) {
  228. if m.id == nil {
  229. return
  230. }
  231. return *m.id, true
  232. }
  233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  234. // That means, if the mutation is applied within a transaction with an isolation level such
  235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  236. // or updated by the mutation.
  237. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  238. switch {
  239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  240. id, exists := m.ID()
  241. if exists {
  242. return []uint64{id}, nil
  243. }
  244. fallthrough
  245. case m.op.Is(OpUpdate | OpDelete):
  246. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  247. default:
  248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  249. }
  250. }
  251. // SetCreatedAt sets the "created_at" field.
  252. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  253. m.created_at = &t
  254. }
  255. // CreatedAt returns the value of the "created_at" field in the mutation.
  256. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  257. v := m.created_at
  258. if v == nil {
  259. return
  260. }
  261. return *v, true
  262. }
  263. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  264. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  266. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  267. if !m.op.Is(OpUpdateOne) {
  268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  269. }
  270. if m.id == nil || m.oldValue == nil {
  271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  272. }
  273. oldValue, err := m.oldValue(ctx)
  274. if err != nil {
  275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  276. }
  277. return oldValue.CreatedAt, nil
  278. }
  279. // ResetCreatedAt resets all changes to the "created_at" field.
  280. func (m *AgentMutation) ResetCreatedAt() {
  281. m.created_at = nil
  282. }
  283. // SetUpdatedAt sets the "updated_at" field.
  284. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  285. m.updated_at = &t
  286. }
  287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  288. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  289. v := m.updated_at
  290. if v == nil {
  291. return
  292. }
  293. return *v, true
  294. }
  295. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  296. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  298. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  299. if !m.op.Is(OpUpdateOne) {
  300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  301. }
  302. if m.id == nil || m.oldValue == nil {
  303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  304. }
  305. oldValue, err := m.oldValue(ctx)
  306. if err != nil {
  307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  308. }
  309. return oldValue.UpdatedAt, nil
  310. }
  311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  312. func (m *AgentMutation) ResetUpdatedAt() {
  313. m.updated_at = nil
  314. }
  315. // SetDeletedAt sets the "deleted_at" field.
  316. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  317. m.deleted_at = &t
  318. }
  319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  320. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  321. v := m.deleted_at
  322. if v == nil {
  323. return
  324. }
  325. return *v, true
  326. }
  327. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  328. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  330. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  331. if !m.op.Is(OpUpdateOne) {
  332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  333. }
  334. if m.id == nil || m.oldValue == nil {
  335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  336. }
  337. oldValue, err := m.oldValue(ctx)
  338. if err != nil {
  339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  340. }
  341. return oldValue.DeletedAt, nil
  342. }
  343. // ClearDeletedAt clears the value of the "deleted_at" field.
  344. func (m *AgentMutation) ClearDeletedAt() {
  345. m.deleted_at = nil
  346. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  347. }
  348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  349. func (m *AgentMutation) DeletedAtCleared() bool {
  350. _, ok := m.clearedFields[agent.FieldDeletedAt]
  351. return ok
  352. }
  353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  354. func (m *AgentMutation) ResetDeletedAt() {
  355. m.deleted_at = nil
  356. delete(m.clearedFields, agent.FieldDeletedAt)
  357. }
  358. // SetName sets the "name" field.
  359. func (m *AgentMutation) SetName(s string) {
  360. m.name = &s
  361. }
  362. // Name returns the value of the "name" field in the mutation.
  363. func (m *AgentMutation) Name() (r string, exists bool) {
  364. v := m.name
  365. if v == nil {
  366. return
  367. }
  368. return *v, true
  369. }
  370. // OldName returns the old "name" field's value of the Agent entity.
  371. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  373. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  374. if !m.op.Is(OpUpdateOne) {
  375. return v, errors.New("OldName is only allowed on UpdateOne operations")
  376. }
  377. if m.id == nil || m.oldValue == nil {
  378. return v, errors.New("OldName requires an ID field in the mutation")
  379. }
  380. oldValue, err := m.oldValue(ctx)
  381. if err != nil {
  382. return v, fmt.Errorf("querying old value for OldName: %w", err)
  383. }
  384. return oldValue.Name, nil
  385. }
  386. // ResetName resets all changes to the "name" field.
  387. func (m *AgentMutation) ResetName() {
  388. m.name = nil
  389. }
  390. // SetRole sets the "role" field.
  391. func (m *AgentMutation) SetRole(s string) {
  392. m.role = &s
  393. }
  394. // Role returns the value of the "role" field in the mutation.
  395. func (m *AgentMutation) Role() (r string, exists bool) {
  396. v := m.role
  397. if v == nil {
  398. return
  399. }
  400. return *v, true
  401. }
  402. // OldRole returns the old "role" field's value of the Agent entity.
  403. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  405. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  406. if !m.op.Is(OpUpdateOne) {
  407. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  408. }
  409. if m.id == nil || m.oldValue == nil {
  410. return v, errors.New("OldRole requires an ID field in the mutation")
  411. }
  412. oldValue, err := m.oldValue(ctx)
  413. if err != nil {
  414. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  415. }
  416. return oldValue.Role, nil
  417. }
  418. // ClearRole clears the value of the "role" field.
  419. func (m *AgentMutation) ClearRole() {
  420. m.role = nil
  421. m.clearedFields[agent.FieldRole] = struct{}{}
  422. }
  423. // RoleCleared returns if the "role" field was cleared in this mutation.
  424. func (m *AgentMutation) RoleCleared() bool {
  425. _, ok := m.clearedFields[agent.FieldRole]
  426. return ok
  427. }
  428. // ResetRole resets all changes to the "role" field.
  429. func (m *AgentMutation) ResetRole() {
  430. m.role = nil
  431. delete(m.clearedFields, agent.FieldRole)
  432. }
  433. // SetStatus sets the "status" field.
  434. func (m *AgentMutation) SetStatus(i int) {
  435. m.status = &i
  436. m.addstatus = nil
  437. }
  438. // Status returns the value of the "status" field in the mutation.
  439. func (m *AgentMutation) Status() (r int, exists bool) {
  440. v := m.status
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // OldStatus returns the old "status" field's value of the Agent entity.
  447. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  449. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  450. if !m.op.Is(OpUpdateOne) {
  451. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  452. }
  453. if m.id == nil || m.oldValue == nil {
  454. return v, errors.New("OldStatus requires an ID field in the mutation")
  455. }
  456. oldValue, err := m.oldValue(ctx)
  457. if err != nil {
  458. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  459. }
  460. return oldValue.Status, nil
  461. }
  462. // AddStatus adds i to the "status" field.
  463. func (m *AgentMutation) AddStatus(i int) {
  464. if m.addstatus != nil {
  465. *m.addstatus += i
  466. } else {
  467. m.addstatus = &i
  468. }
  469. }
  470. // AddedStatus returns the value that was added to the "status" field in this mutation.
  471. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  472. v := m.addstatus
  473. if v == nil {
  474. return
  475. }
  476. return *v, true
  477. }
  478. // ClearStatus clears the value of the "status" field.
  479. func (m *AgentMutation) ClearStatus() {
  480. m.status = nil
  481. m.addstatus = nil
  482. m.clearedFields[agent.FieldStatus] = struct{}{}
  483. }
  484. // StatusCleared returns if the "status" field was cleared in this mutation.
  485. func (m *AgentMutation) StatusCleared() bool {
  486. _, ok := m.clearedFields[agent.FieldStatus]
  487. return ok
  488. }
  489. // ResetStatus resets all changes to the "status" field.
  490. func (m *AgentMutation) ResetStatus() {
  491. m.status = nil
  492. m.addstatus = nil
  493. delete(m.clearedFields, agent.FieldStatus)
  494. }
  495. // SetBackground sets the "background" field.
  496. func (m *AgentMutation) SetBackground(s string) {
  497. m.background = &s
  498. }
  499. // Background returns the value of the "background" field in the mutation.
  500. func (m *AgentMutation) Background() (r string, exists bool) {
  501. v := m.background
  502. if v == nil {
  503. return
  504. }
  505. return *v, true
  506. }
  507. // OldBackground returns the old "background" field's value of the Agent entity.
  508. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  510. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  511. if !m.op.Is(OpUpdateOne) {
  512. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  513. }
  514. if m.id == nil || m.oldValue == nil {
  515. return v, errors.New("OldBackground requires an ID field in the mutation")
  516. }
  517. oldValue, err := m.oldValue(ctx)
  518. if err != nil {
  519. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  520. }
  521. return oldValue.Background, nil
  522. }
  523. // ClearBackground clears the value of the "background" field.
  524. func (m *AgentMutation) ClearBackground() {
  525. m.background = nil
  526. m.clearedFields[agent.FieldBackground] = struct{}{}
  527. }
  528. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  529. func (m *AgentMutation) BackgroundCleared() bool {
  530. _, ok := m.clearedFields[agent.FieldBackground]
  531. return ok
  532. }
  533. // ResetBackground resets all changes to the "background" field.
  534. func (m *AgentMutation) ResetBackground() {
  535. m.background = nil
  536. delete(m.clearedFields, agent.FieldBackground)
  537. }
  538. // SetExamples sets the "examples" field.
  539. func (m *AgentMutation) SetExamples(s string) {
  540. m.examples = &s
  541. }
  542. // Examples returns the value of the "examples" field in the mutation.
  543. func (m *AgentMutation) Examples() (r string, exists bool) {
  544. v := m.examples
  545. if v == nil {
  546. return
  547. }
  548. return *v, true
  549. }
  550. // OldExamples returns the old "examples" field's value of the Agent entity.
  551. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  553. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  554. if !m.op.Is(OpUpdateOne) {
  555. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  556. }
  557. if m.id == nil || m.oldValue == nil {
  558. return v, errors.New("OldExamples requires an ID field in the mutation")
  559. }
  560. oldValue, err := m.oldValue(ctx)
  561. if err != nil {
  562. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  563. }
  564. return oldValue.Examples, nil
  565. }
  566. // ClearExamples clears the value of the "examples" field.
  567. func (m *AgentMutation) ClearExamples() {
  568. m.examples = nil
  569. m.clearedFields[agent.FieldExamples] = struct{}{}
  570. }
  571. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  572. func (m *AgentMutation) ExamplesCleared() bool {
  573. _, ok := m.clearedFields[agent.FieldExamples]
  574. return ok
  575. }
  576. // ResetExamples resets all changes to the "examples" field.
  577. func (m *AgentMutation) ResetExamples() {
  578. m.examples = nil
  579. delete(m.clearedFields, agent.FieldExamples)
  580. }
  581. // SetOrganizationID sets the "organization_id" field.
  582. func (m *AgentMutation) SetOrganizationID(u uint64) {
  583. m.organization_id = &u
  584. m.addorganization_id = nil
  585. }
  586. // OrganizationID returns the value of the "organization_id" field in the mutation.
  587. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  588. v := m.organization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  595. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  597. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  598. if !m.op.Is(OpUpdateOne) {
  599. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  600. }
  601. if m.id == nil || m.oldValue == nil {
  602. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  603. }
  604. oldValue, err := m.oldValue(ctx)
  605. if err != nil {
  606. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  607. }
  608. return oldValue.OrganizationID, nil
  609. }
  610. // AddOrganizationID adds u to the "organization_id" field.
  611. func (m *AgentMutation) AddOrganizationID(u int64) {
  612. if m.addorganization_id != nil {
  613. *m.addorganization_id += u
  614. } else {
  615. m.addorganization_id = &u
  616. }
  617. }
  618. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  619. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  620. v := m.addorganization_id
  621. if v == nil {
  622. return
  623. }
  624. return *v, true
  625. }
  626. // ResetOrganizationID resets all changes to the "organization_id" field.
  627. func (m *AgentMutation) ResetOrganizationID() {
  628. m.organization_id = nil
  629. m.addorganization_id = nil
  630. }
  631. // SetDatasetID sets the "dataset_id" field.
  632. func (m *AgentMutation) SetDatasetID(s string) {
  633. m.dataset_id = &s
  634. }
  635. // DatasetID returns the value of the "dataset_id" field in the mutation.
  636. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  637. v := m.dataset_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  656. }
  657. return oldValue.DatasetID, nil
  658. }
  659. // ResetDatasetID resets all changes to the "dataset_id" field.
  660. func (m *AgentMutation) ResetDatasetID() {
  661. m.dataset_id = nil
  662. }
  663. // SetCollectionID sets the "collection_id" field.
  664. func (m *AgentMutation) SetCollectionID(s string) {
  665. m.collection_id = &s
  666. }
  667. // CollectionID returns the value of the "collection_id" field in the mutation.
  668. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  669. v := m.collection_id
  670. if v == nil {
  671. return
  672. }
  673. return *v, true
  674. }
  675. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  676. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  678. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  679. if !m.op.Is(OpUpdateOne) {
  680. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  681. }
  682. if m.id == nil || m.oldValue == nil {
  683. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  684. }
  685. oldValue, err := m.oldValue(ctx)
  686. if err != nil {
  687. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  688. }
  689. return oldValue.CollectionID, nil
  690. }
  691. // ResetCollectionID resets all changes to the "collection_id" field.
  692. func (m *AgentMutation) ResetCollectionID() {
  693. m.collection_id = nil
  694. }
  695. // SetModel sets the "model" field.
  696. func (m *AgentMutation) SetModel(s string) {
  697. m.model = &s
  698. }
  699. // Model returns the value of the "model" field in the mutation.
  700. func (m *AgentMutation) Model() (r string, exists bool) {
  701. v := m.model
  702. if v == nil {
  703. return
  704. }
  705. return *v, true
  706. }
  707. // OldModel returns the old "model" field's value of the Agent entity.
  708. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  710. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  711. if !m.op.Is(OpUpdateOne) {
  712. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  713. }
  714. if m.id == nil || m.oldValue == nil {
  715. return v, errors.New("OldModel requires an ID field in the mutation")
  716. }
  717. oldValue, err := m.oldValue(ctx)
  718. if err != nil {
  719. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  720. }
  721. return oldValue.Model, nil
  722. }
  723. // ClearModel clears the value of the "model" field.
  724. func (m *AgentMutation) ClearModel() {
  725. m.model = nil
  726. m.clearedFields[agent.FieldModel] = struct{}{}
  727. }
  728. // ModelCleared returns if the "model" field was cleared in this mutation.
  729. func (m *AgentMutation) ModelCleared() bool {
  730. _, ok := m.clearedFields[agent.FieldModel]
  731. return ok
  732. }
  733. // ResetModel resets all changes to the "model" field.
  734. func (m *AgentMutation) ResetModel() {
  735. m.model = nil
  736. delete(m.clearedFields, agent.FieldModel)
  737. }
  738. // SetAPIBase sets the "api_base" field.
  739. func (m *AgentMutation) SetAPIBase(s string) {
  740. m.api_base = &s
  741. }
  742. // APIBase returns the value of the "api_base" field in the mutation.
  743. func (m *AgentMutation) APIBase() (r string, exists bool) {
  744. v := m.api_base
  745. if v == nil {
  746. return
  747. }
  748. return *v, true
  749. }
  750. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  751. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  753. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  754. if !m.op.Is(OpUpdateOne) {
  755. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  756. }
  757. if m.id == nil || m.oldValue == nil {
  758. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  759. }
  760. oldValue, err := m.oldValue(ctx)
  761. if err != nil {
  762. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  763. }
  764. return oldValue.APIBase, nil
  765. }
  766. // ClearAPIBase clears the value of the "api_base" field.
  767. func (m *AgentMutation) ClearAPIBase() {
  768. m.api_base = nil
  769. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  770. }
  771. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  772. func (m *AgentMutation) APIBaseCleared() bool {
  773. _, ok := m.clearedFields[agent.FieldAPIBase]
  774. return ok
  775. }
  776. // ResetAPIBase resets all changes to the "api_base" field.
  777. func (m *AgentMutation) ResetAPIBase() {
  778. m.api_base = nil
  779. delete(m.clearedFields, agent.FieldAPIBase)
  780. }
  781. // SetAPIKey sets the "api_key" field.
  782. func (m *AgentMutation) SetAPIKey(s string) {
  783. m.api_key = &s
  784. }
  785. // APIKey returns the value of the "api_key" field in the mutation.
  786. func (m *AgentMutation) APIKey() (r string, exists bool) {
  787. v := m.api_key
  788. if v == nil {
  789. return
  790. }
  791. return *v, true
  792. }
  793. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  794. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  796. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  797. if !m.op.Is(OpUpdateOne) {
  798. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  799. }
  800. if m.id == nil || m.oldValue == nil {
  801. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  802. }
  803. oldValue, err := m.oldValue(ctx)
  804. if err != nil {
  805. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  806. }
  807. return oldValue.APIKey, nil
  808. }
  809. // ClearAPIKey clears the value of the "api_key" field.
  810. func (m *AgentMutation) ClearAPIKey() {
  811. m.api_key = nil
  812. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  813. }
  814. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  815. func (m *AgentMutation) APIKeyCleared() bool {
  816. _, ok := m.clearedFields[agent.FieldAPIKey]
  817. return ok
  818. }
  819. // ResetAPIKey resets all changes to the "api_key" field.
  820. func (m *AgentMutation) ResetAPIKey() {
  821. m.api_key = nil
  822. delete(m.clearedFields, agent.FieldAPIKey)
  823. }
  824. // SetType sets the "type" field.
  825. func (m *AgentMutation) SetType(i int) {
  826. m._type = &i
  827. m.add_type = nil
  828. }
  829. // GetType returns the value of the "type" field in the mutation.
  830. func (m *AgentMutation) GetType() (r int, exists bool) {
  831. v := m._type
  832. if v == nil {
  833. return
  834. }
  835. return *v, true
  836. }
  837. // OldType returns the old "type" field's value of the Agent entity.
  838. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  840. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  841. if !m.op.Is(OpUpdateOne) {
  842. return v, errors.New("OldType is only allowed on UpdateOne operations")
  843. }
  844. if m.id == nil || m.oldValue == nil {
  845. return v, errors.New("OldType requires an ID field in the mutation")
  846. }
  847. oldValue, err := m.oldValue(ctx)
  848. if err != nil {
  849. return v, fmt.Errorf("querying old value for OldType: %w", err)
  850. }
  851. return oldValue.Type, nil
  852. }
  853. // AddType adds i to the "type" field.
  854. func (m *AgentMutation) AddType(i int) {
  855. if m.add_type != nil {
  856. *m.add_type += i
  857. } else {
  858. m.add_type = &i
  859. }
  860. }
  861. // AddedType returns the value that was added to the "type" field in this mutation.
  862. func (m *AgentMutation) AddedType() (r int, exists bool) {
  863. v := m.add_type
  864. if v == nil {
  865. return
  866. }
  867. return *v, true
  868. }
  869. // ClearType clears the value of the "type" field.
  870. func (m *AgentMutation) ClearType() {
  871. m._type = nil
  872. m.add_type = nil
  873. m.clearedFields[agent.FieldType] = struct{}{}
  874. }
  875. // TypeCleared returns if the "type" field was cleared in this mutation.
  876. func (m *AgentMutation) TypeCleared() bool {
  877. _, ok := m.clearedFields[agent.FieldType]
  878. return ok
  879. }
  880. // ResetType resets all changes to the "type" field.
  881. func (m *AgentMutation) ResetType() {
  882. m._type = nil
  883. m.add_type = nil
  884. delete(m.clearedFields, agent.FieldType)
  885. }
  886. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  887. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  888. if m.wx_agent == nil {
  889. m.wx_agent = make(map[uint64]struct{})
  890. }
  891. for i := range ids {
  892. m.wx_agent[ids[i]] = struct{}{}
  893. }
  894. }
  895. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  896. func (m *AgentMutation) ClearWxAgent() {
  897. m.clearedwx_agent = true
  898. }
  899. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  900. func (m *AgentMutation) WxAgentCleared() bool {
  901. return m.clearedwx_agent
  902. }
  903. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  904. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  905. if m.removedwx_agent == nil {
  906. m.removedwx_agent = make(map[uint64]struct{})
  907. }
  908. for i := range ids {
  909. delete(m.wx_agent, ids[i])
  910. m.removedwx_agent[ids[i]] = struct{}{}
  911. }
  912. }
  913. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  914. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  915. for id := range m.removedwx_agent {
  916. ids = append(ids, id)
  917. }
  918. return
  919. }
  920. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  921. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  922. for id := range m.wx_agent {
  923. ids = append(ids, id)
  924. }
  925. return
  926. }
  927. // ResetWxAgent resets all changes to the "wx_agent" edge.
  928. func (m *AgentMutation) ResetWxAgent() {
  929. m.wx_agent = nil
  930. m.clearedwx_agent = false
  931. m.removedwx_agent = nil
  932. }
  933. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  934. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  935. if m.token_agent == nil {
  936. m.token_agent = make(map[uint64]struct{})
  937. }
  938. for i := range ids {
  939. m.token_agent[ids[i]] = struct{}{}
  940. }
  941. }
  942. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  943. func (m *AgentMutation) ClearTokenAgent() {
  944. m.clearedtoken_agent = true
  945. }
  946. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  947. func (m *AgentMutation) TokenAgentCleared() bool {
  948. return m.clearedtoken_agent
  949. }
  950. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  951. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  952. if m.removedtoken_agent == nil {
  953. m.removedtoken_agent = make(map[uint64]struct{})
  954. }
  955. for i := range ids {
  956. delete(m.token_agent, ids[i])
  957. m.removedtoken_agent[ids[i]] = struct{}{}
  958. }
  959. }
  960. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  961. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  962. for id := range m.removedtoken_agent {
  963. ids = append(ids, id)
  964. }
  965. return
  966. }
  967. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  968. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  969. for id := range m.token_agent {
  970. ids = append(ids, id)
  971. }
  972. return
  973. }
  974. // ResetTokenAgent resets all changes to the "token_agent" edge.
  975. func (m *AgentMutation) ResetTokenAgent() {
  976. m.token_agent = nil
  977. m.clearedtoken_agent = false
  978. m.removedtoken_agent = nil
  979. }
  980. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  981. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  982. if m.wa_agent == nil {
  983. m.wa_agent = make(map[uint64]struct{})
  984. }
  985. for i := range ids {
  986. m.wa_agent[ids[i]] = struct{}{}
  987. }
  988. }
  989. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  990. func (m *AgentMutation) ClearWaAgent() {
  991. m.clearedwa_agent = true
  992. }
  993. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  994. func (m *AgentMutation) WaAgentCleared() bool {
  995. return m.clearedwa_agent
  996. }
  997. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  998. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  999. if m.removedwa_agent == nil {
  1000. m.removedwa_agent = make(map[uint64]struct{})
  1001. }
  1002. for i := range ids {
  1003. delete(m.wa_agent, ids[i])
  1004. m.removedwa_agent[ids[i]] = struct{}{}
  1005. }
  1006. }
  1007. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1008. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1009. for id := range m.removedwa_agent {
  1010. ids = append(ids, id)
  1011. }
  1012. return
  1013. }
  1014. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1015. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1016. for id := range m.wa_agent {
  1017. ids = append(ids, id)
  1018. }
  1019. return
  1020. }
  1021. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1022. func (m *AgentMutation) ResetWaAgent() {
  1023. m.wa_agent = nil
  1024. m.clearedwa_agent = false
  1025. m.removedwa_agent = nil
  1026. }
  1027. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1028. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1029. if m.xjs_agent == nil {
  1030. m.xjs_agent = make(map[uint64]struct{})
  1031. }
  1032. for i := range ids {
  1033. m.xjs_agent[ids[i]] = struct{}{}
  1034. }
  1035. }
  1036. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1037. func (m *AgentMutation) ClearXjsAgent() {
  1038. m.clearedxjs_agent = true
  1039. }
  1040. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1041. func (m *AgentMutation) XjsAgentCleared() bool {
  1042. return m.clearedxjs_agent
  1043. }
  1044. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1045. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1046. if m.removedxjs_agent == nil {
  1047. m.removedxjs_agent = make(map[uint64]struct{})
  1048. }
  1049. for i := range ids {
  1050. delete(m.xjs_agent, ids[i])
  1051. m.removedxjs_agent[ids[i]] = struct{}{}
  1052. }
  1053. }
  1054. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1055. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1056. for id := range m.removedxjs_agent {
  1057. ids = append(ids, id)
  1058. }
  1059. return
  1060. }
  1061. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1062. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1063. for id := range m.xjs_agent {
  1064. ids = append(ids, id)
  1065. }
  1066. return
  1067. }
  1068. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1069. func (m *AgentMutation) ResetXjsAgent() {
  1070. m.xjs_agent = nil
  1071. m.clearedxjs_agent = false
  1072. m.removedxjs_agent = nil
  1073. }
  1074. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1075. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1076. if m.key_agent == nil {
  1077. m.key_agent = make(map[uint64]struct{})
  1078. }
  1079. for i := range ids {
  1080. m.key_agent[ids[i]] = struct{}{}
  1081. }
  1082. }
  1083. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1084. func (m *AgentMutation) ClearKeyAgent() {
  1085. m.clearedkey_agent = true
  1086. }
  1087. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1088. func (m *AgentMutation) KeyAgentCleared() bool {
  1089. return m.clearedkey_agent
  1090. }
  1091. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1092. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1093. if m.removedkey_agent == nil {
  1094. m.removedkey_agent = make(map[uint64]struct{})
  1095. }
  1096. for i := range ids {
  1097. delete(m.key_agent, ids[i])
  1098. m.removedkey_agent[ids[i]] = struct{}{}
  1099. }
  1100. }
  1101. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1102. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1103. for id := range m.removedkey_agent {
  1104. ids = append(ids, id)
  1105. }
  1106. return
  1107. }
  1108. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1109. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1110. for id := range m.key_agent {
  1111. ids = append(ids, id)
  1112. }
  1113. return
  1114. }
  1115. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1116. func (m *AgentMutation) ResetKeyAgent() {
  1117. m.key_agent = nil
  1118. m.clearedkey_agent = false
  1119. m.removedkey_agent = nil
  1120. }
  1121. // Where appends a list predicates to the AgentMutation builder.
  1122. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1123. m.predicates = append(m.predicates, ps...)
  1124. }
  1125. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1126. // users can use type-assertion to append predicates that do not depend on any generated package.
  1127. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1128. p := make([]predicate.Agent, len(ps))
  1129. for i := range ps {
  1130. p[i] = ps[i]
  1131. }
  1132. m.Where(p...)
  1133. }
  1134. // Op returns the operation name.
  1135. func (m *AgentMutation) Op() Op {
  1136. return m.op
  1137. }
  1138. // SetOp allows setting the mutation operation.
  1139. func (m *AgentMutation) SetOp(op Op) {
  1140. m.op = op
  1141. }
  1142. // Type returns the node type of this mutation (Agent).
  1143. func (m *AgentMutation) Type() string {
  1144. return m.typ
  1145. }
  1146. // Fields returns all fields that were changed during this mutation. Note that in
  1147. // order to get all numeric fields that were incremented/decremented, call
  1148. // AddedFields().
  1149. func (m *AgentMutation) Fields() []string {
  1150. fields := make([]string, 0, 15)
  1151. if m.created_at != nil {
  1152. fields = append(fields, agent.FieldCreatedAt)
  1153. }
  1154. if m.updated_at != nil {
  1155. fields = append(fields, agent.FieldUpdatedAt)
  1156. }
  1157. if m.deleted_at != nil {
  1158. fields = append(fields, agent.FieldDeletedAt)
  1159. }
  1160. if m.name != nil {
  1161. fields = append(fields, agent.FieldName)
  1162. }
  1163. if m.role != nil {
  1164. fields = append(fields, agent.FieldRole)
  1165. }
  1166. if m.status != nil {
  1167. fields = append(fields, agent.FieldStatus)
  1168. }
  1169. if m.background != nil {
  1170. fields = append(fields, agent.FieldBackground)
  1171. }
  1172. if m.examples != nil {
  1173. fields = append(fields, agent.FieldExamples)
  1174. }
  1175. if m.organization_id != nil {
  1176. fields = append(fields, agent.FieldOrganizationID)
  1177. }
  1178. if m.dataset_id != nil {
  1179. fields = append(fields, agent.FieldDatasetID)
  1180. }
  1181. if m.collection_id != nil {
  1182. fields = append(fields, agent.FieldCollectionID)
  1183. }
  1184. if m.model != nil {
  1185. fields = append(fields, agent.FieldModel)
  1186. }
  1187. if m.api_base != nil {
  1188. fields = append(fields, agent.FieldAPIBase)
  1189. }
  1190. if m.api_key != nil {
  1191. fields = append(fields, agent.FieldAPIKey)
  1192. }
  1193. if m._type != nil {
  1194. fields = append(fields, agent.FieldType)
  1195. }
  1196. return fields
  1197. }
  1198. // Field returns the value of a field with the given name. The second boolean
  1199. // return value indicates that this field was not set, or was not defined in the
  1200. // schema.
  1201. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1202. switch name {
  1203. case agent.FieldCreatedAt:
  1204. return m.CreatedAt()
  1205. case agent.FieldUpdatedAt:
  1206. return m.UpdatedAt()
  1207. case agent.FieldDeletedAt:
  1208. return m.DeletedAt()
  1209. case agent.FieldName:
  1210. return m.Name()
  1211. case agent.FieldRole:
  1212. return m.Role()
  1213. case agent.FieldStatus:
  1214. return m.Status()
  1215. case agent.FieldBackground:
  1216. return m.Background()
  1217. case agent.FieldExamples:
  1218. return m.Examples()
  1219. case agent.FieldOrganizationID:
  1220. return m.OrganizationID()
  1221. case agent.FieldDatasetID:
  1222. return m.DatasetID()
  1223. case agent.FieldCollectionID:
  1224. return m.CollectionID()
  1225. case agent.FieldModel:
  1226. return m.Model()
  1227. case agent.FieldAPIBase:
  1228. return m.APIBase()
  1229. case agent.FieldAPIKey:
  1230. return m.APIKey()
  1231. case agent.FieldType:
  1232. return m.GetType()
  1233. }
  1234. return nil, false
  1235. }
  1236. // OldField returns the old value of the field from the database. An error is
  1237. // returned if the mutation operation is not UpdateOne, or the query to the
  1238. // database failed.
  1239. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1240. switch name {
  1241. case agent.FieldCreatedAt:
  1242. return m.OldCreatedAt(ctx)
  1243. case agent.FieldUpdatedAt:
  1244. return m.OldUpdatedAt(ctx)
  1245. case agent.FieldDeletedAt:
  1246. return m.OldDeletedAt(ctx)
  1247. case agent.FieldName:
  1248. return m.OldName(ctx)
  1249. case agent.FieldRole:
  1250. return m.OldRole(ctx)
  1251. case agent.FieldStatus:
  1252. return m.OldStatus(ctx)
  1253. case agent.FieldBackground:
  1254. return m.OldBackground(ctx)
  1255. case agent.FieldExamples:
  1256. return m.OldExamples(ctx)
  1257. case agent.FieldOrganizationID:
  1258. return m.OldOrganizationID(ctx)
  1259. case agent.FieldDatasetID:
  1260. return m.OldDatasetID(ctx)
  1261. case agent.FieldCollectionID:
  1262. return m.OldCollectionID(ctx)
  1263. case agent.FieldModel:
  1264. return m.OldModel(ctx)
  1265. case agent.FieldAPIBase:
  1266. return m.OldAPIBase(ctx)
  1267. case agent.FieldAPIKey:
  1268. return m.OldAPIKey(ctx)
  1269. case agent.FieldType:
  1270. return m.OldType(ctx)
  1271. }
  1272. return nil, fmt.Errorf("unknown Agent field %s", name)
  1273. }
  1274. // SetField sets the value of a field with the given name. It returns an error if
  1275. // the field is not defined in the schema, or if the type mismatched the field
  1276. // type.
  1277. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1278. switch name {
  1279. case agent.FieldCreatedAt:
  1280. v, ok := value.(time.Time)
  1281. if !ok {
  1282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1283. }
  1284. m.SetCreatedAt(v)
  1285. return nil
  1286. case agent.FieldUpdatedAt:
  1287. v, ok := value.(time.Time)
  1288. if !ok {
  1289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1290. }
  1291. m.SetUpdatedAt(v)
  1292. return nil
  1293. case agent.FieldDeletedAt:
  1294. v, ok := value.(time.Time)
  1295. if !ok {
  1296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1297. }
  1298. m.SetDeletedAt(v)
  1299. return nil
  1300. case agent.FieldName:
  1301. v, ok := value.(string)
  1302. if !ok {
  1303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1304. }
  1305. m.SetName(v)
  1306. return nil
  1307. case agent.FieldRole:
  1308. v, ok := value.(string)
  1309. if !ok {
  1310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1311. }
  1312. m.SetRole(v)
  1313. return nil
  1314. case agent.FieldStatus:
  1315. v, ok := value.(int)
  1316. if !ok {
  1317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1318. }
  1319. m.SetStatus(v)
  1320. return nil
  1321. case agent.FieldBackground:
  1322. v, ok := value.(string)
  1323. if !ok {
  1324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1325. }
  1326. m.SetBackground(v)
  1327. return nil
  1328. case agent.FieldExamples:
  1329. v, ok := value.(string)
  1330. if !ok {
  1331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1332. }
  1333. m.SetExamples(v)
  1334. return nil
  1335. case agent.FieldOrganizationID:
  1336. v, ok := value.(uint64)
  1337. if !ok {
  1338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1339. }
  1340. m.SetOrganizationID(v)
  1341. return nil
  1342. case agent.FieldDatasetID:
  1343. v, ok := value.(string)
  1344. if !ok {
  1345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1346. }
  1347. m.SetDatasetID(v)
  1348. return nil
  1349. case agent.FieldCollectionID:
  1350. v, ok := value.(string)
  1351. if !ok {
  1352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1353. }
  1354. m.SetCollectionID(v)
  1355. return nil
  1356. case agent.FieldModel:
  1357. v, ok := value.(string)
  1358. if !ok {
  1359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1360. }
  1361. m.SetModel(v)
  1362. return nil
  1363. case agent.FieldAPIBase:
  1364. v, ok := value.(string)
  1365. if !ok {
  1366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1367. }
  1368. m.SetAPIBase(v)
  1369. return nil
  1370. case agent.FieldAPIKey:
  1371. v, ok := value.(string)
  1372. if !ok {
  1373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1374. }
  1375. m.SetAPIKey(v)
  1376. return nil
  1377. case agent.FieldType:
  1378. v, ok := value.(int)
  1379. if !ok {
  1380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1381. }
  1382. m.SetType(v)
  1383. return nil
  1384. }
  1385. return fmt.Errorf("unknown Agent field %s", name)
  1386. }
  1387. // AddedFields returns all numeric fields that were incremented/decremented during
  1388. // this mutation.
  1389. func (m *AgentMutation) AddedFields() []string {
  1390. var fields []string
  1391. if m.addstatus != nil {
  1392. fields = append(fields, agent.FieldStatus)
  1393. }
  1394. if m.addorganization_id != nil {
  1395. fields = append(fields, agent.FieldOrganizationID)
  1396. }
  1397. if m.add_type != nil {
  1398. fields = append(fields, agent.FieldType)
  1399. }
  1400. return fields
  1401. }
  1402. // AddedField returns the numeric value that was incremented/decremented on a field
  1403. // with the given name. The second boolean return value indicates that this field
  1404. // was not set, or was not defined in the schema.
  1405. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1406. switch name {
  1407. case agent.FieldStatus:
  1408. return m.AddedStatus()
  1409. case agent.FieldOrganizationID:
  1410. return m.AddedOrganizationID()
  1411. case agent.FieldType:
  1412. return m.AddedType()
  1413. }
  1414. return nil, false
  1415. }
  1416. // AddField adds the value to the field with the given name. It returns an error if
  1417. // the field is not defined in the schema, or if the type mismatched the field
  1418. // type.
  1419. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1420. switch name {
  1421. case agent.FieldStatus:
  1422. v, ok := value.(int)
  1423. if !ok {
  1424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1425. }
  1426. m.AddStatus(v)
  1427. return nil
  1428. case agent.FieldOrganizationID:
  1429. v, ok := value.(int64)
  1430. if !ok {
  1431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1432. }
  1433. m.AddOrganizationID(v)
  1434. return nil
  1435. case agent.FieldType:
  1436. v, ok := value.(int)
  1437. if !ok {
  1438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1439. }
  1440. m.AddType(v)
  1441. return nil
  1442. }
  1443. return fmt.Errorf("unknown Agent numeric field %s", name)
  1444. }
  1445. // ClearedFields returns all nullable fields that were cleared during this
  1446. // mutation.
  1447. func (m *AgentMutation) ClearedFields() []string {
  1448. var fields []string
  1449. if m.FieldCleared(agent.FieldDeletedAt) {
  1450. fields = append(fields, agent.FieldDeletedAt)
  1451. }
  1452. if m.FieldCleared(agent.FieldRole) {
  1453. fields = append(fields, agent.FieldRole)
  1454. }
  1455. if m.FieldCleared(agent.FieldStatus) {
  1456. fields = append(fields, agent.FieldStatus)
  1457. }
  1458. if m.FieldCleared(agent.FieldBackground) {
  1459. fields = append(fields, agent.FieldBackground)
  1460. }
  1461. if m.FieldCleared(agent.FieldExamples) {
  1462. fields = append(fields, agent.FieldExamples)
  1463. }
  1464. if m.FieldCleared(agent.FieldModel) {
  1465. fields = append(fields, agent.FieldModel)
  1466. }
  1467. if m.FieldCleared(agent.FieldAPIBase) {
  1468. fields = append(fields, agent.FieldAPIBase)
  1469. }
  1470. if m.FieldCleared(agent.FieldAPIKey) {
  1471. fields = append(fields, agent.FieldAPIKey)
  1472. }
  1473. if m.FieldCleared(agent.FieldType) {
  1474. fields = append(fields, agent.FieldType)
  1475. }
  1476. return fields
  1477. }
  1478. // FieldCleared returns a boolean indicating if a field with the given name was
  1479. // cleared in this mutation.
  1480. func (m *AgentMutation) FieldCleared(name string) bool {
  1481. _, ok := m.clearedFields[name]
  1482. return ok
  1483. }
  1484. // ClearField clears the value of the field with the given name. It returns an
  1485. // error if the field is not defined in the schema.
  1486. func (m *AgentMutation) ClearField(name string) error {
  1487. switch name {
  1488. case agent.FieldDeletedAt:
  1489. m.ClearDeletedAt()
  1490. return nil
  1491. case agent.FieldRole:
  1492. m.ClearRole()
  1493. return nil
  1494. case agent.FieldStatus:
  1495. m.ClearStatus()
  1496. return nil
  1497. case agent.FieldBackground:
  1498. m.ClearBackground()
  1499. return nil
  1500. case agent.FieldExamples:
  1501. m.ClearExamples()
  1502. return nil
  1503. case agent.FieldModel:
  1504. m.ClearModel()
  1505. return nil
  1506. case agent.FieldAPIBase:
  1507. m.ClearAPIBase()
  1508. return nil
  1509. case agent.FieldAPIKey:
  1510. m.ClearAPIKey()
  1511. return nil
  1512. case agent.FieldType:
  1513. m.ClearType()
  1514. return nil
  1515. }
  1516. return fmt.Errorf("unknown Agent nullable field %s", name)
  1517. }
  1518. // ResetField resets all changes in the mutation for the field with the given name.
  1519. // It returns an error if the field is not defined in the schema.
  1520. func (m *AgentMutation) ResetField(name string) error {
  1521. switch name {
  1522. case agent.FieldCreatedAt:
  1523. m.ResetCreatedAt()
  1524. return nil
  1525. case agent.FieldUpdatedAt:
  1526. m.ResetUpdatedAt()
  1527. return nil
  1528. case agent.FieldDeletedAt:
  1529. m.ResetDeletedAt()
  1530. return nil
  1531. case agent.FieldName:
  1532. m.ResetName()
  1533. return nil
  1534. case agent.FieldRole:
  1535. m.ResetRole()
  1536. return nil
  1537. case agent.FieldStatus:
  1538. m.ResetStatus()
  1539. return nil
  1540. case agent.FieldBackground:
  1541. m.ResetBackground()
  1542. return nil
  1543. case agent.FieldExamples:
  1544. m.ResetExamples()
  1545. return nil
  1546. case agent.FieldOrganizationID:
  1547. m.ResetOrganizationID()
  1548. return nil
  1549. case agent.FieldDatasetID:
  1550. m.ResetDatasetID()
  1551. return nil
  1552. case agent.FieldCollectionID:
  1553. m.ResetCollectionID()
  1554. return nil
  1555. case agent.FieldModel:
  1556. m.ResetModel()
  1557. return nil
  1558. case agent.FieldAPIBase:
  1559. m.ResetAPIBase()
  1560. return nil
  1561. case agent.FieldAPIKey:
  1562. m.ResetAPIKey()
  1563. return nil
  1564. case agent.FieldType:
  1565. m.ResetType()
  1566. return nil
  1567. }
  1568. return fmt.Errorf("unknown Agent field %s", name)
  1569. }
  1570. // AddedEdges returns all edge names that were set/added in this mutation.
  1571. func (m *AgentMutation) AddedEdges() []string {
  1572. edges := make([]string, 0, 5)
  1573. if m.wx_agent != nil {
  1574. edges = append(edges, agent.EdgeWxAgent)
  1575. }
  1576. if m.token_agent != nil {
  1577. edges = append(edges, agent.EdgeTokenAgent)
  1578. }
  1579. if m.wa_agent != nil {
  1580. edges = append(edges, agent.EdgeWaAgent)
  1581. }
  1582. if m.xjs_agent != nil {
  1583. edges = append(edges, agent.EdgeXjsAgent)
  1584. }
  1585. if m.key_agent != nil {
  1586. edges = append(edges, agent.EdgeKeyAgent)
  1587. }
  1588. return edges
  1589. }
  1590. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1591. // name in this mutation.
  1592. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1593. switch name {
  1594. case agent.EdgeWxAgent:
  1595. ids := make([]ent.Value, 0, len(m.wx_agent))
  1596. for id := range m.wx_agent {
  1597. ids = append(ids, id)
  1598. }
  1599. return ids
  1600. case agent.EdgeTokenAgent:
  1601. ids := make([]ent.Value, 0, len(m.token_agent))
  1602. for id := range m.token_agent {
  1603. ids = append(ids, id)
  1604. }
  1605. return ids
  1606. case agent.EdgeWaAgent:
  1607. ids := make([]ent.Value, 0, len(m.wa_agent))
  1608. for id := range m.wa_agent {
  1609. ids = append(ids, id)
  1610. }
  1611. return ids
  1612. case agent.EdgeXjsAgent:
  1613. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1614. for id := range m.xjs_agent {
  1615. ids = append(ids, id)
  1616. }
  1617. return ids
  1618. case agent.EdgeKeyAgent:
  1619. ids := make([]ent.Value, 0, len(m.key_agent))
  1620. for id := range m.key_agent {
  1621. ids = append(ids, id)
  1622. }
  1623. return ids
  1624. }
  1625. return nil
  1626. }
  1627. // RemovedEdges returns all edge names that were removed in this mutation.
  1628. func (m *AgentMutation) RemovedEdges() []string {
  1629. edges := make([]string, 0, 5)
  1630. if m.removedwx_agent != nil {
  1631. edges = append(edges, agent.EdgeWxAgent)
  1632. }
  1633. if m.removedtoken_agent != nil {
  1634. edges = append(edges, agent.EdgeTokenAgent)
  1635. }
  1636. if m.removedwa_agent != nil {
  1637. edges = append(edges, agent.EdgeWaAgent)
  1638. }
  1639. if m.removedxjs_agent != nil {
  1640. edges = append(edges, agent.EdgeXjsAgent)
  1641. }
  1642. if m.removedkey_agent != nil {
  1643. edges = append(edges, agent.EdgeKeyAgent)
  1644. }
  1645. return edges
  1646. }
  1647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1648. // the given name in this mutation.
  1649. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1650. switch name {
  1651. case agent.EdgeWxAgent:
  1652. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1653. for id := range m.removedwx_agent {
  1654. ids = append(ids, id)
  1655. }
  1656. return ids
  1657. case agent.EdgeTokenAgent:
  1658. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1659. for id := range m.removedtoken_agent {
  1660. ids = append(ids, id)
  1661. }
  1662. return ids
  1663. case agent.EdgeWaAgent:
  1664. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1665. for id := range m.removedwa_agent {
  1666. ids = append(ids, id)
  1667. }
  1668. return ids
  1669. case agent.EdgeXjsAgent:
  1670. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1671. for id := range m.removedxjs_agent {
  1672. ids = append(ids, id)
  1673. }
  1674. return ids
  1675. case agent.EdgeKeyAgent:
  1676. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1677. for id := range m.removedkey_agent {
  1678. ids = append(ids, id)
  1679. }
  1680. return ids
  1681. }
  1682. return nil
  1683. }
  1684. // ClearedEdges returns all edge names that were cleared in this mutation.
  1685. func (m *AgentMutation) ClearedEdges() []string {
  1686. edges := make([]string, 0, 5)
  1687. if m.clearedwx_agent {
  1688. edges = append(edges, agent.EdgeWxAgent)
  1689. }
  1690. if m.clearedtoken_agent {
  1691. edges = append(edges, agent.EdgeTokenAgent)
  1692. }
  1693. if m.clearedwa_agent {
  1694. edges = append(edges, agent.EdgeWaAgent)
  1695. }
  1696. if m.clearedxjs_agent {
  1697. edges = append(edges, agent.EdgeXjsAgent)
  1698. }
  1699. if m.clearedkey_agent {
  1700. edges = append(edges, agent.EdgeKeyAgent)
  1701. }
  1702. return edges
  1703. }
  1704. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1705. // was cleared in this mutation.
  1706. func (m *AgentMutation) EdgeCleared(name string) bool {
  1707. switch name {
  1708. case agent.EdgeWxAgent:
  1709. return m.clearedwx_agent
  1710. case agent.EdgeTokenAgent:
  1711. return m.clearedtoken_agent
  1712. case agent.EdgeWaAgent:
  1713. return m.clearedwa_agent
  1714. case agent.EdgeXjsAgent:
  1715. return m.clearedxjs_agent
  1716. case agent.EdgeKeyAgent:
  1717. return m.clearedkey_agent
  1718. }
  1719. return false
  1720. }
  1721. // ClearEdge clears the value of the edge with the given name. It returns an error
  1722. // if that edge is not defined in the schema.
  1723. func (m *AgentMutation) ClearEdge(name string) error {
  1724. switch name {
  1725. }
  1726. return fmt.Errorf("unknown Agent unique edge %s", name)
  1727. }
  1728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1729. // It returns an error if the edge is not defined in the schema.
  1730. func (m *AgentMutation) ResetEdge(name string) error {
  1731. switch name {
  1732. case agent.EdgeWxAgent:
  1733. m.ResetWxAgent()
  1734. return nil
  1735. case agent.EdgeTokenAgent:
  1736. m.ResetTokenAgent()
  1737. return nil
  1738. case agent.EdgeWaAgent:
  1739. m.ResetWaAgent()
  1740. return nil
  1741. case agent.EdgeXjsAgent:
  1742. m.ResetXjsAgent()
  1743. return nil
  1744. case agent.EdgeKeyAgent:
  1745. m.ResetKeyAgent()
  1746. return nil
  1747. }
  1748. return fmt.Errorf("unknown Agent edge %s", name)
  1749. }
  1750. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1751. type AgentBaseMutation struct {
  1752. config
  1753. op Op
  1754. typ string
  1755. id *string
  1756. q *string
  1757. a *string
  1758. chunk_index *uint64
  1759. addchunk_index *int64
  1760. indexes *[]string
  1761. appendindexes []string
  1762. dataset_id *string
  1763. collection_id *string
  1764. source_name *string
  1765. can_write *[]bool
  1766. appendcan_write []bool
  1767. is_owner *[]bool
  1768. appendis_owner []bool
  1769. clearedFields map[string]struct{}
  1770. wx_agent map[uint64]struct{}
  1771. removedwx_agent map[uint64]struct{}
  1772. clearedwx_agent bool
  1773. done bool
  1774. oldValue func(context.Context) (*AgentBase, error)
  1775. predicates []predicate.AgentBase
  1776. }
  1777. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1778. // agentbaseOption allows management of the mutation configuration using functional options.
  1779. type agentbaseOption func(*AgentBaseMutation)
  1780. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1781. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1782. m := &AgentBaseMutation{
  1783. config: c,
  1784. op: op,
  1785. typ: TypeAgentBase,
  1786. clearedFields: make(map[string]struct{}),
  1787. }
  1788. for _, opt := range opts {
  1789. opt(m)
  1790. }
  1791. return m
  1792. }
  1793. // withAgentBaseID sets the ID field of the mutation.
  1794. func withAgentBaseID(id string) agentbaseOption {
  1795. return func(m *AgentBaseMutation) {
  1796. var (
  1797. err error
  1798. once sync.Once
  1799. value *AgentBase
  1800. )
  1801. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1802. once.Do(func() {
  1803. if m.done {
  1804. err = errors.New("querying old values post mutation is not allowed")
  1805. } else {
  1806. value, err = m.Client().AgentBase.Get(ctx, id)
  1807. }
  1808. })
  1809. return value, err
  1810. }
  1811. m.id = &id
  1812. }
  1813. }
  1814. // withAgentBase sets the old AgentBase of the mutation.
  1815. func withAgentBase(node *AgentBase) agentbaseOption {
  1816. return func(m *AgentBaseMutation) {
  1817. m.oldValue = func(context.Context) (*AgentBase, error) {
  1818. return node, nil
  1819. }
  1820. m.id = &node.ID
  1821. }
  1822. }
  1823. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1824. // executed in a transaction (ent.Tx), a transactional client is returned.
  1825. func (m AgentBaseMutation) Client() *Client {
  1826. client := &Client{config: m.config}
  1827. client.init()
  1828. return client
  1829. }
  1830. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1831. // it returns an error otherwise.
  1832. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1833. if _, ok := m.driver.(*txDriver); !ok {
  1834. return nil, errors.New("ent: mutation is not running in a transaction")
  1835. }
  1836. tx := &Tx{config: m.config}
  1837. tx.init()
  1838. return tx, nil
  1839. }
  1840. // SetID sets the value of the id field. Note that this
  1841. // operation is only accepted on creation of AgentBase entities.
  1842. func (m *AgentBaseMutation) SetID(id string) {
  1843. m.id = &id
  1844. }
  1845. // ID returns the ID value in the mutation. Note that the ID is only available
  1846. // if it was provided to the builder or after it was returned from the database.
  1847. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1848. if m.id == nil {
  1849. return
  1850. }
  1851. return *m.id, true
  1852. }
  1853. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1854. // That means, if the mutation is applied within a transaction with an isolation level such
  1855. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1856. // or updated by the mutation.
  1857. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1858. switch {
  1859. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1860. id, exists := m.ID()
  1861. if exists {
  1862. return []string{id}, nil
  1863. }
  1864. fallthrough
  1865. case m.op.Is(OpUpdate | OpDelete):
  1866. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1867. default:
  1868. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1869. }
  1870. }
  1871. // SetQ sets the "q" field.
  1872. func (m *AgentBaseMutation) SetQ(s string) {
  1873. m.q = &s
  1874. }
  1875. // Q returns the value of the "q" field in the mutation.
  1876. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1877. v := m.q
  1878. if v == nil {
  1879. return
  1880. }
  1881. return *v, true
  1882. }
  1883. // OldQ returns the old "q" field's value of the AgentBase entity.
  1884. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1886. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1887. if !m.op.Is(OpUpdateOne) {
  1888. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1889. }
  1890. if m.id == nil || m.oldValue == nil {
  1891. return v, errors.New("OldQ requires an ID field in the mutation")
  1892. }
  1893. oldValue, err := m.oldValue(ctx)
  1894. if err != nil {
  1895. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1896. }
  1897. return oldValue.Q, nil
  1898. }
  1899. // ClearQ clears the value of the "q" field.
  1900. func (m *AgentBaseMutation) ClearQ() {
  1901. m.q = nil
  1902. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1903. }
  1904. // QCleared returns if the "q" field was cleared in this mutation.
  1905. func (m *AgentBaseMutation) QCleared() bool {
  1906. _, ok := m.clearedFields[agentbase.FieldQ]
  1907. return ok
  1908. }
  1909. // ResetQ resets all changes to the "q" field.
  1910. func (m *AgentBaseMutation) ResetQ() {
  1911. m.q = nil
  1912. delete(m.clearedFields, agentbase.FieldQ)
  1913. }
  1914. // SetA sets the "a" field.
  1915. func (m *AgentBaseMutation) SetA(s string) {
  1916. m.a = &s
  1917. }
  1918. // A returns the value of the "a" field in the mutation.
  1919. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1920. v := m.a
  1921. if v == nil {
  1922. return
  1923. }
  1924. return *v, true
  1925. }
  1926. // OldA returns the old "a" field's value of the AgentBase entity.
  1927. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1929. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1930. if !m.op.Is(OpUpdateOne) {
  1931. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1932. }
  1933. if m.id == nil || m.oldValue == nil {
  1934. return v, errors.New("OldA requires an ID field in the mutation")
  1935. }
  1936. oldValue, err := m.oldValue(ctx)
  1937. if err != nil {
  1938. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1939. }
  1940. return oldValue.A, nil
  1941. }
  1942. // ClearA clears the value of the "a" field.
  1943. func (m *AgentBaseMutation) ClearA() {
  1944. m.a = nil
  1945. m.clearedFields[agentbase.FieldA] = struct{}{}
  1946. }
  1947. // ACleared returns if the "a" field was cleared in this mutation.
  1948. func (m *AgentBaseMutation) ACleared() bool {
  1949. _, ok := m.clearedFields[agentbase.FieldA]
  1950. return ok
  1951. }
  1952. // ResetA resets all changes to the "a" field.
  1953. func (m *AgentBaseMutation) ResetA() {
  1954. m.a = nil
  1955. delete(m.clearedFields, agentbase.FieldA)
  1956. }
  1957. // SetChunkIndex sets the "chunk_index" field.
  1958. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1959. m.chunk_index = &u
  1960. m.addchunk_index = nil
  1961. }
  1962. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1963. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1964. v := m.chunk_index
  1965. if v == nil {
  1966. return
  1967. }
  1968. return *v, true
  1969. }
  1970. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1971. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1973. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1974. if !m.op.Is(OpUpdateOne) {
  1975. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1976. }
  1977. if m.id == nil || m.oldValue == nil {
  1978. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1979. }
  1980. oldValue, err := m.oldValue(ctx)
  1981. if err != nil {
  1982. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1983. }
  1984. return oldValue.ChunkIndex, nil
  1985. }
  1986. // AddChunkIndex adds u to the "chunk_index" field.
  1987. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1988. if m.addchunk_index != nil {
  1989. *m.addchunk_index += u
  1990. } else {
  1991. m.addchunk_index = &u
  1992. }
  1993. }
  1994. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1995. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1996. v := m.addchunk_index
  1997. if v == nil {
  1998. return
  1999. }
  2000. return *v, true
  2001. }
  2002. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2003. func (m *AgentBaseMutation) ResetChunkIndex() {
  2004. m.chunk_index = nil
  2005. m.addchunk_index = nil
  2006. }
  2007. // SetIndexes sets the "indexes" field.
  2008. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2009. m.indexes = &s
  2010. m.appendindexes = nil
  2011. }
  2012. // Indexes returns the value of the "indexes" field in the mutation.
  2013. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2014. v := m.indexes
  2015. if v == nil {
  2016. return
  2017. }
  2018. return *v, true
  2019. }
  2020. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2021. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2023. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2024. if !m.op.Is(OpUpdateOne) {
  2025. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2026. }
  2027. if m.id == nil || m.oldValue == nil {
  2028. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2029. }
  2030. oldValue, err := m.oldValue(ctx)
  2031. if err != nil {
  2032. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2033. }
  2034. return oldValue.Indexes, nil
  2035. }
  2036. // AppendIndexes adds s to the "indexes" field.
  2037. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2038. m.appendindexes = append(m.appendindexes, s...)
  2039. }
  2040. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2041. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2042. if len(m.appendindexes) == 0 {
  2043. return nil, false
  2044. }
  2045. return m.appendindexes, true
  2046. }
  2047. // ClearIndexes clears the value of the "indexes" field.
  2048. func (m *AgentBaseMutation) ClearIndexes() {
  2049. m.indexes = nil
  2050. m.appendindexes = nil
  2051. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2052. }
  2053. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2054. func (m *AgentBaseMutation) IndexesCleared() bool {
  2055. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2056. return ok
  2057. }
  2058. // ResetIndexes resets all changes to the "indexes" field.
  2059. func (m *AgentBaseMutation) ResetIndexes() {
  2060. m.indexes = nil
  2061. m.appendindexes = nil
  2062. delete(m.clearedFields, agentbase.FieldIndexes)
  2063. }
  2064. // SetDatasetID sets the "dataset_id" field.
  2065. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2066. m.dataset_id = &s
  2067. }
  2068. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2069. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2070. v := m.dataset_id
  2071. if v == nil {
  2072. return
  2073. }
  2074. return *v, true
  2075. }
  2076. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2077. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2079. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2080. if !m.op.Is(OpUpdateOne) {
  2081. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2082. }
  2083. if m.id == nil || m.oldValue == nil {
  2084. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2085. }
  2086. oldValue, err := m.oldValue(ctx)
  2087. if err != nil {
  2088. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2089. }
  2090. return oldValue.DatasetID, nil
  2091. }
  2092. // ClearDatasetID clears the value of the "dataset_id" field.
  2093. func (m *AgentBaseMutation) ClearDatasetID() {
  2094. m.dataset_id = nil
  2095. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2096. }
  2097. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2098. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2099. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2100. return ok
  2101. }
  2102. // ResetDatasetID resets all changes to the "dataset_id" field.
  2103. func (m *AgentBaseMutation) ResetDatasetID() {
  2104. m.dataset_id = nil
  2105. delete(m.clearedFields, agentbase.FieldDatasetID)
  2106. }
  2107. // SetCollectionID sets the "collection_id" field.
  2108. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2109. m.collection_id = &s
  2110. }
  2111. // CollectionID returns the value of the "collection_id" field in the mutation.
  2112. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2113. v := m.collection_id
  2114. if v == nil {
  2115. return
  2116. }
  2117. return *v, true
  2118. }
  2119. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2120. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2122. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2123. if !m.op.Is(OpUpdateOne) {
  2124. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2125. }
  2126. if m.id == nil || m.oldValue == nil {
  2127. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2128. }
  2129. oldValue, err := m.oldValue(ctx)
  2130. if err != nil {
  2131. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2132. }
  2133. return oldValue.CollectionID, nil
  2134. }
  2135. // ClearCollectionID clears the value of the "collection_id" field.
  2136. func (m *AgentBaseMutation) ClearCollectionID() {
  2137. m.collection_id = nil
  2138. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2139. }
  2140. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2141. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2142. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2143. return ok
  2144. }
  2145. // ResetCollectionID resets all changes to the "collection_id" field.
  2146. func (m *AgentBaseMutation) ResetCollectionID() {
  2147. m.collection_id = nil
  2148. delete(m.clearedFields, agentbase.FieldCollectionID)
  2149. }
  2150. // SetSourceName sets the "source_name" field.
  2151. func (m *AgentBaseMutation) SetSourceName(s string) {
  2152. m.source_name = &s
  2153. }
  2154. // SourceName returns the value of the "source_name" field in the mutation.
  2155. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2156. v := m.source_name
  2157. if v == nil {
  2158. return
  2159. }
  2160. return *v, true
  2161. }
  2162. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2163. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2165. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2166. if !m.op.Is(OpUpdateOne) {
  2167. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2168. }
  2169. if m.id == nil || m.oldValue == nil {
  2170. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2171. }
  2172. oldValue, err := m.oldValue(ctx)
  2173. if err != nil {
  2174. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2175. }
  2176. return oldValue.SourceName, nil
  2177. }
  2178. // ClearSourceName clears the value of the "source_name" field.
  2179. func (m *AgentBaseMutation) ClearSourceName() {
  2180. m.source_name = nil
  2181. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2182. }
  2183. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2184. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2185. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2186. return ok
  2187. }
  2188. // ResetSourceName resets all changes to the "source_name" field.
  2189. func (m *AgentBaseMutation) ResetSourceName() {
  2190. m.source_name = nil
  2191. delete(m.clearedFields, agentbase.FieldSourceName)
  2192. }
  2193. // SetCanWrite sets the "can_write" field.
  2194. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2195. m.can_write = &b
  2196. m.appendcan_write = nil
  2197. }
  2198. // CanWrite returns the value of the "can_write" field in the mutation.
  2199. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2200. v := m.can_write
  2201. if v == nil {
  2202. return
  2203. }
  2204. return *v, true
  2205. }
  2206. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2207. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2209. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2210. if !m.op.Is(OpUpdateOne) {
  2211. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2212. }
  2213. if m.id == nil || m.oldValue == nil {
  2214. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2215. }
  2216. oldValue, err := m.oldValue(ctx)
  2217. if err != nil {
  2218. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2219. }
  2220. return oldValue.CanWrite, nil
  2221. }
  2222. // AppendCanWrite adds b to the "can_write" field.
  2223. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2224. m.appendcan_write = append(m.appendcan_write, b...)
  2225. }
  2226. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2227. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2228. if len(m.appendcan_write) == 0 {
  2229. return nil, false
  2230. }
  2231. return m.appendcan_write, true
  2232. }
  2233. // ClearCanWrite clears the value of the "can_write" field.
  2234. func (m *AgentBaseMutation) ClearCanWrite() {
  2235. m.can_write = nil
  2236. m.appendcan_write = nil
  2237. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2238. }
  2239. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2240. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2241. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2242. return ok
  2243. }
  2244. // ResetCanWrite resets all changes to the "can_write" field.
  2245. func (m *AgentBaseMutation) ResetCanWrite() {
  2246. m.can_write = nil
  2247. m.appendcan_write = nil
  2248. delete(m.clearedFields, agentbase.FieldCanWrite)
  2249. }
  2250. // SetIsOwner sets the "is_owner" field.
  2251. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2252. m.is_owner = &b
  2253. m.appendis_owner = nil
  2254. }
  2255. // IsOwner returns the value of the "is_owner" field in the mutation.
  2256. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2257. v := m.is_owner
  2258. if v == nil {
  2259. return
  2260. }
  2261. return *v, true
  2262. }
  2263. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2264. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2266. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2267. if !m.op.Is(OpUpdateOne) {
  2268. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2269. }
  2270. if m.id == nil || m.oldValue == nil {
  2271. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2272. }
  2273. oldValue, err := m.oldValue(ctx)
  2274. if err != nil {
  2275. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2276. }
  2277. return oldValue.IsOwner, nil
  2278. }
  2279. // AppendIsOwner adds b to the "is_owner" field.
  2280. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2281. m.appendis_owner = append(m.appendis_owner, b...)
  2282. }
  2283. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2284. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2285. if len(m.appendis_owner) == 0 {
  2286. return nil, false
  2287. }
  2288. return m.appendis_owner, true
  2289. }
  2290. // ClearIsOwner clears the value of the "is_owner" field.
  2291. func (m *AgentBaseMutation) ClearIsOwner() {
  2292. m.is_owner = nil
  2293. m.appendis_owner = nil
  2294. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2295. }
  2296. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2297. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2298. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2299. return ok
  2300. }
  2301. // ResetIsOwner resets all changes to the "is_owner" field.
  2302. func (m *AgentBaseMutation) ResetIsOwner() {
  2303. m.is_owner = nil
  2304. m.appendis_owner = nil
  2305. delete(m.clearedFields, agentbase.FieldIsOwner)
  2306. }
  2307. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2308. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2309. if m.wx_agent == nil {
  2310. m.wx_agent = make(map[uint64]struct{})
  2311. }
  2312. for i := range ids {
  2313. m.wx_agent[ids[i]] = struct{}{}
  2314. }
  2315. }
  2316. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2317. func (m *AgentBaseMutation) ClearWxAgent() {
  2318. m.clearedwx_agent = true
  2319. }
  2320. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2321. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2322. return m.clearedwx_agent
  2323. }
  2324. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2325. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2326. if m.removedwx_agent == nil {
  2327. m.removedwx_agent = make(map[uint64]struct{})
  2328. }
  2329. for i := range ids {
  2330. delete(m.wx_agent, ids[i])
  2331. m.removedwx_agent[ids[i]] = struct{}{}
  2332. }
  2333. }
  2334. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2335. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2336. for id := range m.removedwx_agent {
  2337. ids = append(ids, id)
  2338. }
  2339. return
  2340. }
  2341. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2342. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2343. for id := range m.wx_agent {
  2344. ids = append(ids, id)
  2345. }
  2346. return
  2347. }
  2348. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2349. func (m *AgentBaseMutation) ResetWxAgent() {
  2350. m.wx_agent = nil
  2351. m.clearedwx_agent = false
  2352. m.removedwx_agent = nil
  2353. }
  2354. // Where appends a list predicates to the AgentBaseMutation builder.
  2355. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2356. m.predicates = append(m.predicates, ps...)
  2357. }
  2358. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2359. // users can use type-assertion to append predicates that do not depend on any generated package.
  2360. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2361. p := make([]predicate.AgentBase, len(ps))
  2362. for i := range ps {
  2363. p[i] = ps[i]
  2364. }
  2365. m.Where(p...)
  2366. }
  2367. // Op returns the operation name.
  2368. func (m *AgentBaseMutation) Op() Op {
  2369. return m.op
  2370. }
  2371. // SetOp allows setting the mutation operation.
  2372. func (m *AgentBaseMutation) SetOp(op Op) {
  2373. m.op = op
  2374. }
  2375. // Type returns the node type of this mutation (AgentBase).
  2376. func (m *AgentBaseMutation) Type() string {
  2377. return m.typ
  2378. }
  2379. // Fields returns all fields that were changed during this mutation. Note that in
  2380. // order to get all numeric fields that were incremented/decremented, call
  2381. // AddedFields().
  2382. func (m *AgentBaseMutation) Fields() []string {
  2383. fields := make([]string, 0, 9)
  2384. if m.q != nil {
  2385. fields = append(fields, agentbase.FieldQ)
  2386. }
  2387. if m.a != nil {
  2388. fields = append(fields, agentbase.FieldA)
  2389. }
  2390. if m.chunk_index != nil {
  2391. fields = append(fields, agentbase.FieldChunkIndex)
  2392. }
  2393. if m.indexes != nil {
  2394. fields = append(fields, agentbase.FieldIndexes)
  2395. }
  2396. if m.dataset_id != nil {
  2397. fields = append(fields, agentbase.FieldDatasetID)
  2398. }
  2399. if m.collection_id != nil {
  2400. fields = append(fields, agentbase.FieldCollectionID)
  2401. }
  2402. if m.source_name != nil {
  2403. fields = append(fields, agentbase.FieldSourceName)
  2404. }
  2405. if m.can_write != nil {
  2406. fields = append(fields, agentbase.FieldCanWrite)
  2407. }
  2408. if m.is_owner != nil {
  2409. fields = append(fields, agentbase.FieldIsOwner)
  2410. }
  2411. return fields
  2412. }
  2413. // Field returns the value of a field with the given name. The second boolean
  2414. // return value indicates that this field was not set, or was not defined in the
  2415. // schema.
  2416. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2417. switch name {
  2418. case agentbase.FieldQ:
  2419. return m.Q()
  2420. case agentbase.FieldA:
  2421. return m.A()
  2422. case agentbase.FieldChunkIndex:
  2423. return m.ChunkIndex()
  2424. case agentbase.FieldIndexes:
  2425. return m.Indexes()
  2426. case agentbase.FieldDatasetID:
  2427. return m.DatasetID()
  2428. case agentbase.FieldCollectionID:
  2429. return m.CollectionID()
  2430. case agentbase.FieldSourceName:
  2431. return m.SourceName()
  2432. case agentbase.FieldCanWrite:
  2433. return m.CanWrite()
  2434. case agentbase.FieldIsOwner:
  2435. return m.IsOwner()
  2436. }
  2437. return nil, false
  2438. }
  2439. // OldField returns the old value of the field from the database. An error is
  2440. // returned if the mutation operation is not UpdateOne, or the query to the
  2441. // database failed.
  2442. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2443. switch name {
  2444. case agentbase.FieldQ:
  2445. return m.OldQ(ctx)
  2446. case agentbase.FieldA:
  2447. return m.OldA(ctx)
  2448. case agentbase.FieldChunkIndex:
  2449. return m.OldChunkIndex(ctx)
  2450. case agentbase.FieldIndexes:
  2451. return m.OldIndexes(ctx)
  2452. case agentbase.FieldDatasetID:
  2453. return m.OldDatasetID(ctx)
  2454. case agentbase.FieldCollectionID:
  2455. return m.OldCollectionID(ctx)
  2456. case agentbase.FieldSourceName:
  2457. return m.OldSourceName(ctx)
  2458. case agentbase.FieldCanWrite:
  2459. return m.OldCanWrite(ctx)
  2460. case agentbase.FieldIsOwner:
  2461. return m.OldIsOwner(ctx)
  2462. }
  2463. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2464. }
  2465. // SetField sets the value of a field with the given name. It returns an error if
  2466. // the field is not defined in the schema, or if the type mismatched the field
  2467. // type.
  2468. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2469. switch name {
  2470. case agentbase.FieldQ:
  2471. v, ok := value.(string)
  2472. if !ok {
  2473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2474. }
  2475. m.SetQ(v)
  2476. return nil
  2477. case agentbase.FieldA:
  2478. v, ok := value.(string)
  2479. if !ok {
  2480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2481. }
  2482. m.SetA(v)
  2483. return nil
  2484. case agentbase.FieldChunkIndex:
  2485. v, ok := value.(uint64)
  2486. if !ok {
  2487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2488. }
  2489. m.SetChunkIndex(v)
  2490. return nil
  2491. case agentbase.FieldIndexes:
  2492. v, ok := value.([]string)
  2493. if !ok {
  2494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2495. }
  2496. m.SetIndexes(v)
  2497. return nil
  2498. case agentbase.FieldDatasetID:
  2499. v, ok := value.(string)
  2500. if !ok {
  2501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2502. }
  2503. m.SetDatasetID(v)
  2504. return nil
  2505. case agentbase.FieldCollectionID:
  2506. v, ok := value.(string)
  2507. if !ok {
  2508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2509. }
  2510. m.SetCollectionID(v)
  2511. return nil
  2512. case agentbase.FieldSourceName:
  2513. v, ok := value.(string)
  2514. if !ok {
  2515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2516. }
  2517. m.SetSourceName(v)
  2518. return nil
  2519. case agentbase.FieldCanWrite:
  2520. v, ok := value.([]bool)
  2521. if !ok {
  2522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2523. }
  2524. m.SetCanWrite(v)
  2525. return nil
  2526. case agentbase.FieldIsOwner:
  2527. v, ok := value.([]bool)
  2528. if !ok {
  2529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2530. }
  2531. m.SetIsOwner(v)
  2532. return nil
  2533. }
  2534. return fmt.Errorf("unknown AgentBase field %s", name)
  2535. }
  2536. // AddedFields returns all numeric fields that were incremented/decremented during
  2537. // this mutation.
  2538. func (m *AgentBaseMutation) AddedFields() []string {
  2539. var fields []string
  2540. if m.addchunk_index != nil {
  2541. fields = append(fields, agentbase.FieldChunkIndex)
  2542. }
  2543. return fields
  2544. }
  2545. // AddedField returns the numeric value that was incremented/decremented on a field
  2546. // with the given name. The second boolean return value indicates that this field
  2547. // was not set, or was not defined in the schema.
  2548. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2549. switch name {
  2550. case agentbase.FieldChunkIndex:
  2551. return m.AddedChunkIndex()
  2552. }
  2553. return nil, false
  2554. }
  2555. // AddField adds the value to the field with the given name. It returns an error if
  2556. // the field is not defined in the schema, or if the type mismatched the field
  2557. // type.
  2558. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2559. switch name {
  2560. case agentbase.FieldChunkIndex:
  2561. v, ok := value.(int64)
  2562. if !ok {
  2563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2564. }
  2565. m.AddChunkIndex(v)
  2566. return nil
  2567. }
  2568. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2569. }
  2570. // ClearedFields returns all nullable fields that were cleared during this
  2571. // mutation.
  2572. func (m *AgentBaseMutation) ClearedFields() []string {
  2573. var fields []string
  2574. if m.FieldCleared(agentbase.FieldQ) {
  2575. fields = append(fields, agentbase.FieldQ)
  2576. }
  2577. if m.FieldCleared(agentbase.FieldA) {
  2578. fields = append(fields, agentbase.FieldA)
  2579. }
  2580. if m.FieldCleared(agentbase.FieldIndexes) {
  2581. fields = append(fields, agentbase.FieldIndexes)
  2582. }
  2583. if m.FieldCleared(agentbase.FieldDatasetID) {
  2584. fields = append(fields, agentbase.FieldDatasetID)
  2585. }
  2586. if m.FieldCleared(agentbase.FieldCollectionID) {
  2587. fields = append(fields, agentbase.FieldCollectionID)
  2588. }
  2589. if m.FieldCleared(agentbase.FieldSourceName) {
  2590. fields = append(fields, agentbase.FieldSourceName)
  2591. }
  2592. if m.FieldCleared(agentbase.FieldCanWrite) {
  2593. fields = append(fields, agentbase.FieldCanWrite)
  2594. }
  2595. if m.FieldCleared(agentbase.FieldIsOwner) {
  2596. fields = append(fields, agentbase.FieldIsOwner)
  2597. }
  2598. return fields
  2599. }
  2600. // FieldCleared returns a boolean indicating if a field with the given name was
  2601. // cleared in this mutation.
  2602. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2603. _, ok := m.clearedFields[name]
  2604. return ok
  2605. }
  2606. // ClearField clears the value of the field with the given name. It returns an
  2607. // error if the field is not defined in the schema.
  2608. func (m *AgentBaseMutation) ClearField(name string) error {
  2609. switch name {
  2610. case agentbase.FieldQ:
  2611. m.ClearQ()
  2612. return nil
  2613. case agentbase.FieldA:
  2614. m.ClearA()
  2615. return nil
  2616. case agentbase.FieldIndexes:
  2617. m.ClearIndexes()
  2618. return nil
  2619. case agentbase.FieldDatasetID:
  2620. m.ClearDatasetID()
  2621. return nil
  2622. case agentbase.FieldCollectionID:
  2623. m.ClearCollectionID()
  2624. return nil
  2625. case agentbase.FieldSourceName:
  2626. m.ClearSourceName()
  2627. return nil
  2628. case agentbase.FieldCanWrite:
  2629. m.ClearCanWrite()
  2630. return nil
  2631. case agentbase.FieldIsOwner:
  2632. m.ClearIsOwner()
  2633. return nil
  2634. }
  2635. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2636. }
  2637. // ResetField resets all changes in the mutation for the field with the given name.
  2638. // It returns an error if the field is not defined in the schema.
  2639. func (m *AgentBaseMutation) ResetField(name string) error {
  2640. switch name {
  2641. case agentbase.FieldQ:
  2642. m.ResetQ()
  2643. return nil
  2644. case agentbase.FieldA:
  2645. m.ResetA()
  2646. return nil
  2647. case agentbase.FieldChunkIndex:
  2648. m.ResetChunkIndex()
  2649. return nil
  2650. case agentbase.FieldIndexes:
  2651. m.ResetIndexes()
  2652. return nil
  2653. case agentbase.FieldDatasetID:
  2654. m.ResetDatasetID()
  2655. return nil
  2656. case agentbase.FieldCollectionID:
  2657. m.ResetCollectionID()
  2658. return nil
  2659. case agentbase.FieldSourceName:
  2660. m.ResetSourceName()
  2661. return nil
  2662. case agentbase.FieldCanWrite:
  2663. m.ResetCanWrite()
  2664. return nil
  2665. case agentbase.FieldIsOwner:
  2666. m.ResetIsOwner()
  2667. return nil
  2668. }
  2669. return fmt.Errorf("unknown AgentBase field %s", name)
  2670. }
  2671. // AddedEdges returns all edge names that were set/added in this mutation.
  2672. func (m *AgentBaseMutation) AddedEdges() []string {
  2673. edges := make([]string, 0, 1)
  2674. if m.wx_agent != nil {
  2675. edges = append(edges, agentbase.EdgeWxAgent)
  2676. }
  2677. return edges
  2678. }
  2679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2680. // name in this mutation.
  2681. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2682. switch name {
  2683. case agentbase.EdgeWxAgent:
  2684. ids := make([]ent.Value, 0, len(m.wx_agent))
  2685. for id := range m.wx_agent {
  2686. ids = append(ids, id)
  2687. }
  2688. return ids
  2689. }
  2690. return nil
  2691. }
  2692. // RemovedEdges returns all edge names that were removed in this mutation.
  2693. func (m *AgentBaseMutation) RemovedEdges() []string {
  2694. edges := make([]string, 0, 1)
  2695. if m.removedwx_agent != nil {
  2696. edges = append(edges, agentbase.EdgeWxAgent)
  2697. }
  2698. return edges
  2699. }
  2700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2701. // the given name in this mutation.
  2702. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2703. switch name {
  2704. case agentbase.EdgeWxAgent:
  2705. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2706. for id := range m.removedwx_agent {
  2707. ids = append(ids, id)
  2708. }
  2709. return ids
  2710. }
  2711. return nil
  2712. }
  2713. // ClearedEdges returns all edge names that were cleared in this mutation.
  2714. func (m *AgentBaseMutation) ClearedEdges() []string {
  2715. edges := make([]string, 0, 1)
  2716. if m.clearedwx_agent {
  2717. edges = append(edges, agentbase.EdgeWxAgent)
  2718. }
  2719. return edges
  2720. }
  2721. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2722. // was cleared in this mutation.
  2723. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2724. switch name {
  2725. case agentbase.EdgeWxAgent:
  2726. return m.clearedwx_agent
  2727. }
  2728. return false
  2729. }
  2730. // ClearEdge clears the value of the edge with the given name. It returns an error
  2731. // if that edge is not defined in the schema.
  2732. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2733. switch name {
  2734. }
  2735. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2736. }
  2737. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2738. // It returns an error if the edge is not defined in the schema.
  2739. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2740. switch name {
  2741. case agentbase.EdgeWxAgent:
  2742. m.ResetWxAgent()
  2743. return nil
  2744. }
  2745. return fmt.Errorf("unknown AgentBase edge %s", name)
  2746. }
  2747. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2748. type AliyunAvatarMutation struct {
  2749. config
  2750. op Op
  2751. typ string
  2752. id *uint64
  2753. created_at *time.Time
  2754. updated_at *time.Time
  2755. deleted_at *time.Time
  2756. user_id *uint64
  2757. adduser_id *int64
  2758. biz_id *string
  2759. access_key_id *string
  2760. access_key_secret *string
  2761. app_id *string
  2762. tenant_id *uint64
  2763. addtenant_id *int64
  2764. response *string
  2765. token *string
  2766. session_id *string
  2767. clearedFields map[string]struct{}
  2768. done bool
  2769. oldValue func(context.Context) (*AliyunAvatar, error)
  2770. predicates []predicate.AliyunAvatar
  2771. }
  2772. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2773. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2774. type aliyunavatarOption func(*AliyunAvatarMutation)
  2775. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2776. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2777. m := &AliyunAvatarMutation{
  2778. config: c,
  2779. op: op,
  2780. typ: TypeAliyunAvatar,
  2781. clearedFields: make(map[string]struct{}),
  2782. }
  2783. for _, opt := range opts {
  2784. opt(m)
  2785. }
  2786. return m
  2787. }
  2788. // withAliyunAvatarID sets the ID field of the mutation.
  2789. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2790. return func(m *AliyunAvatarMutation) {
  2791. var (
  2792. err error
  2793. once sync.Once
  2794. value *AliyunAvatar
  2795. )
  2796. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2797. once.Do(func() {
  2798. if m.done {
  2799. err = errors.New("querying old values post mutation is not allowed")
  2800. } else {
  2801. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2802. }
  2803. })
  2804. return value, err
  2805. }
  2806. m.id = &id
  2807. }
  2808. }
  2809. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2810. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2811. return func(m *AliyunAvatarMutation) {
  2812. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2813. return node, nil
  2814. }
  2815. m.id = &node.ID
  2816. }
  2817. }
  2818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2819. // executed in a transaction (ent.Tx), a transactional client is returned.
  2820. func (m AliyunAvatarMutation) Client() *Client {
  2821. client := &Client{config: m.config}
  2822. client.init()
  2823. return client
  2824. }
  2825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2826. // it returns an error otherwise.
  2827. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2828. if _, ok := m.driver.(*txDriver); !ok {
  2829. return nil, errors.New("ent: mutation is not running in a transaction")
  2830. }
  2831. tx := &Tx{config: m.config}
  2832. tx.init()
  2833. return tx, nil
  2834. }
  2835. // SetID sets the value of the id field. Note that this
  2836. // operation is only accepted on creation of AliyunAvatar entities.
  2837. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2838. m.id = &id
  2839. }
  2840. // ID returns the ID value in the mutation. Note that the ID is only available
  2841. // if it was provided to the builder or after it was returned from the database.
  2842. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2843. if m.id == nil {
  2844. return
  2845. }
  2846. return *m.id, true
  2847. }
  2848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2849. // That means, if the mutation is applied within a transaction with an isolation level such
  2850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2851. // or updated by the mutation.
  2852. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2853. switch {
  2854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2855. id, exists := m.ID()
  2856. if exists {
  2857. return []uint64{id}, nil
  2858. }
  2859. fallthrough
  2860. case m.op.Is(OpUpdate | OpDelete):
  2861. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2862. default:
  2863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2864. }
  2865. }
  2866. // SetCreatedAt sets the "created_at" field.
  2867. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2868. m.created_at = &t
  2869. }
  2870. // CreatedAt returns the value of the "created_at" field in the mutation.
  2871. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2872. v := m.created_at
  2873. if v == nil {
  2874. return
  2875. }
  2876. return *v, true
  2877. }
  2878. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2879. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2881. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2882. if !m.op.Is(OpUpdateOne) {
  2883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2884. }
  2885. if m.id == nil || m.oldValue == nil {
  2886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2887. }
  2888. oldValue, err := m.oldValue(ctx)
  2889. if err != nil {
  2890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2891. }
  2892. return oldValue.CreatedAt, nil
  2893. }
  2894. // ResetCreatedAt resets all changes to the "created_at" field.
  2895. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2896. m.created_at = nil
  2897. }
  2898. // SetUpdatedAt sets the "updated_at" field.
  2899. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2900. m.updated_at = &t
  2901. }
  2902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2903. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2904. v := m.updated_at
  2905. if v == nil {
  2906. return
  2907. }
  2908. return *v, true
  2909. }
  2910. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2911. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2913. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2914. if !m.op.Is(OpUpdateOne) {
  2915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2916. }
  2917. if m.id == nil || m.oldValue == nil {
  2918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2919. }
  2920. oldValue, err := m.oldValue(ctx)
  2921. if err != nil {
  2922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2923. }
  2924. return oldValue.UpdatedAt, nil
  2925. }
  2926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2927. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2928. m.updated_at = nil
  2929. }
  2930. // SetDeletedAt sets the "deleted_at" field.
  2931. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2932. m.deleted_at = &t
  2933. }
  2934. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2935. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2936. v := m.deleted_at
  2937. if v == nil {
  2938. return
  2939. }
  2940. return *v, true
  2941. }
  2942. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2943. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2945. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2946. if !m.op.Is(OpUpdateOne) {
  2947. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2948. }
  2949. if m.id == nil || m.oldValue == nil {
  2950. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2951. }
  2952. oldValue, err := m.oldValue(ctx)
  2953. if err != nil {
  2954. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2955. }
  2956. return oldValue.DeletedAt, nil
  2957. }
  2958. // ClearDeletedAt clears the value of the "deleted_at" field.
  2959. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2960. m.deleted_at = nil
  2961. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2962. }
  2963. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2964. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2965. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2966. return ok
  2967. }
  2968. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2969. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2970. m.deleted_at = nil
  2971. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2972. }
  2973. // SetUserID sets the "user_id" field.
  2974. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2975. m.user_id = &u
  2976. m.adduser_id = nil
  2977. }
  2978. // UserID returns the value of the "user_id" field in the mutation.
  2979. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2980. v := m.user_id
  2981. if v == nil {
  2982. return
  2983. }
  2984. return *v, true
  2985. }
  2986. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2987. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2989. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2990. if !m.op.Is(OpUpdateOne) {
  2991. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2992. }
  2993. if m.id == nil || m.oldValue == nil {
  2994. return v, errors.New("OldUserID requires an ID field in the mutation")
  2995. }
  2996. oldValue, err := m.oldValue(ctx)
  2997. if err != nil {
  2998. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2999. }
  3000. return oldValue.UserID, nil
  3001. }
  3002. // AddUserID adds u to the "user_id" field.
  3003. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3004. if m.adduser_id != nil {
  3005. *m.adduser_id += u
  3006. } else {
  3007. m.adduser_id = &u
  3008. }
  3009. }
  3010. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3011. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3012. v := m.adduser_id
  3013. if v == nil {
  3014. return
  3015. }
  3016. return *v, true
  3017. }
  3018. // ResetUserID resets all changes to the "user_id" field.
  3019. func (m *AliyunAvatarMutation) ResetUserID() {
  3020. m.user_id = nil
  3021. m.adduser_id = nil
  3022. }
  3023. // SetBizID sets the "biz_id" field.
  3024. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3025. m.biz_id = &s
  3026. }
  3027. // BizID returns the value of the "biz_id" field in the mutation.
  3028. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3029. v := m.biz_id
  3030. if v == nil {
  3031. return
  3032. }
  3033. return *v, true
  3034. }
  3035. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3036. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3038. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3039. if !m.op.Is(OpUpdateOne) {
  3040. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3041. }
  3042. if m.id == nil || m.oldValue == nil {
  3043. return v, errors.New("OldBizID requires an ID field in the mutation")
  3044. }
  3045. oldValue, err := m.oldValue(ctx)
  3046. if err != nil {
  3047. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3048. }
  3049. return oldValue.BizID, nil
  3050. }
  3051. // ResetBizID resets all changes to the "biz_id" field.
  3052. func (m *AliyunAvatarMutation) ResetBizID() {
  3053. m.biz_id = nil
  3054. }
  3055. // SetAccessKeyID sets the "access_key_id" field.
  3056. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3057. m.access_key_id = &s
  3058. }
  3059. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3060. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3061. v := m.access_key_id
  3062. if v == nil {
  3063. return
  3064. }
  3065. return *v, true
  3066. }
  3067. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3068. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3070. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3071. if !m.op.Is(OpUpdateOne) {
  3072. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3073. }
  3074. if m.id == nil || m.oldValue == nil {
  3075. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3076. }
  3077. oldValue, err := m.oldValue(ctx)
  3078. if err != nil {
  3079. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3080. }
  3081. return oldValue.AccessKeyID, nil
  3082. }
  3083. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3084. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3085. m.access_key_id = nil
  3086. }
  3087. // SetAccessKeySecret sets the "access_key_secret" field.
  3088. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3089. m.access_key_secret = &s
  3090. }
  3091. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3092. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3093. v := m.access_key_secret
  3094. if v == nil {
  3095. return
  3096. }
  3097. return *v, true
  3098. }
  3099. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3100. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3102. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3103. if !m.op.Is(OpUpdateOne) {
  3104. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3105. }
  3106. if m.id == nil || m.oldValue == nil {
  3107. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3108. }
  3109. oldValue, err := m.oldValue(ctx)
  3110. if err != nil {
  3111. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3112. }
  3113. return oldValue.AccessKeySecret, nil
  3114. }
  3115. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3116. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3117. m.access_key_secret = nil
  3118. }
  3119. // SetAppID sets the "app_id" field.
  3120. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3121. m.app_id = &s
  3122. }
  3123. // AppID returns the value of the "app_id" field in the mutation.
  3124. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3125. v := m.app_id
  3126. if v == nil {
  3127. return
  3128. }
  3129. return *v, true
  3130. }
  3131. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3132. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3134. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3135. if !m.op.Is(OpUpdateOne) {
  3136. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3137. }
  3138. if m.id == nil || m.oldValue == nil {
  3139. return v, errors.New("OldAppID requires an ID field in the mutation")
  3140. }
  3141. oldValue, err := m.oldValue(ctx)
  3142. if err != nil {
  3143. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3144. }
  3145. return oldValue.AppID, nil
  3146. }
  3147. // ClearAppID clears the value of the "app_id" field.
  3148. func (m *AliyunAvatarMutation) ClearAppID() {
  3149. m.app_id = nil
  3150. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3151. }
  3152. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3153. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3154. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3155. return ok
  3156. }
  3157. // ResetAppID resets all changes to the "app_id" field.
  3158. func (m *AliyunAvatarMutation) ResetAppID() {
  3159. m.app_id = nil
  3160. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3161. }
  3162. // SetTenantID sets the "tenant_id" field.
  3163. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3164. m.tenant_id = &u
  3165. m.addtenant_id = nil
  3166. }
  3167. // TenantID returns the value of the "tenant_id" field in the mutation.
  3168. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3169. v := m.tenant_id
  3170. if v == nil {
  3171. return
  3172. }
  3173. return *v, true
  3174. }
  3175. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3176. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3178. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3179. if !m.op.Is(OpUpdateOne) {
  3180. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3181. }
  3182. if m.id == nil || m.oldValue == nil {
  3183. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3184. }
  3185. oldValue, err := m.oldValue(ctx)
  3186. if err != nil {
  3187. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3188. }
  3189. return oldValue.TenantID, nil
  3190. }
  3191. // AddTenantID adds u to the "tenant_id" field.
  3192. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3193. if m.addtenant_id != nil {
  3194. *m.addtenant_id += u
  3195. } else {
  3196. m.addtenant_id = &u
  3197. }
  3198. }
  3199. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3200. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3201. v := m.addtenant_id
  3202. if v == nil {
  3203. return
  3204. }
  3205. return *v, true
  3206. }
  3207. // ResetTenantID resets all changes to the "tenant_id" field.
  3208. func (m *AliyunAvatarMutation) ResetTenantID() {
  3209. m.tenant_id = nil
  3210. m.addtenant_id = nil
  3211. }
  3212. // SetResponse sets the "response" field.
  3213. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3214. m.response = &s
  3215. }
  3216. // Response returns the value of the "response" field in the mutation.
  3217. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3218. v := m.response
  3219. if v == nil {
  3220. return
  3221. }
  3222. return *v, true
  3223. }
  3224. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3225. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3227. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3228. if !m.op.Is(OpUpdateOne) {
  3229. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3230. }
  3231. if m.id == nil || m.oldValue == nil {
  3232. return v, errors.New("OldResponse requires an ID field in the mutation")
  3233. }
  3234. oldValue, err := m.oldValue(ctx)
  3235. if err != nil {
  3236. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3237. }
  3238. return oldValue.Response, nil
  3239. }
  3240. // ResetResponse resets all changes to the "response" field.
  3241. func (m *AliyunAvatarMutation) ResetResponse() {
  3242. m.response = nil
  3243. }
  3244. // SetToken sets the "token" field.
  3245. func (m *AliyunAvatarMutation) SetToken(s string) {
  3246. m.token = &s
  3247. }
  3248. // Token returns the value of the "token" field in the mutation.
  3249. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3250. v := m.token
  3251. if v == nil {
  3252. return
  3253. }
  3254. return *v, true
  3255. }
  3256. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3257. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3259. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3260. if !m.op.Is(OpUpdateOne) {
  3261. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3262. }
  3263. if m.id == nil || m.oldValue == nil {
  3264. return v, errors.New("OldToken requires an ID field in the mutation")
  3265. }
  3266. oldValue, err := m.oldValue(ctx)
  3267. if err != nil {
  3268. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3269. }
  3270. return oldValue.Token, nil
  3271. }
  3272. // ResetToken resets all changes to the "token" field.
  3273. func (m *AliyunAvatarMutation) ResetToken() {
  3274. m.token = nil
  3275. }
  3276. // SetSessionID sets the "session_id" field.
  3277. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3278. m.session_id = &s
  3279. }
  3280. // SessionID returns the value of the "session_id" field in the mutation.
  3281. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3282. v := m.session_id
  3283. if v == nil {
  3284. return
  3285. }
  3286. return *v, true
  3287. }
  3288. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3289. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3291. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3292. if !m.op.Is(OpUpdateOne) {
  3293. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3294. }
  3295. if m.id == nil || m.oldValue == nil {
  3296. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3297. }
  3298. oldValue, err := m.oldValue(ctx)
  3299. if err != nil {
  3300. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3301. }
  3302. return oldValue.SessionID, nil
  3303. }
  3304. // ResetSessionID resets all changes to the "session_id" field.
  3305. func (m *AliyunAvatarMutation) ResetSessionID() {
  3306. m.session_id = nil
  3307. }
  3308. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3309. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3310. m.predicates = append(m.predicates, ps...)
  3311. }
  3312. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3313. // users can use type-assertion to append predicates that do not depend on any generated package.
  3314. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3315. p := make([]predicate.AliyunAvatar, len(ps))
  3316. for i := range ps {
  3317. p[i] = ps[i]
  3318. }
  3319. m.Where(p...)
  3320. }
  3321. // Op returns the operation name.
  3322. func (m *AliyunAvatarMutation) Op() Op {
  3323. return m.op
  3324. }
  3325. // SetOp allows setting the mutation operation.
  3326. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3327. m.op = op
  3328. }
  3329. // Type returns the node type of this mutation (AliyunAvatar).
  3330. func (m *AliyunAvatarMutation) Type() string {
  3331. return m.typ
  3332. }
  3333. // Fields returns all fields that were changed during this mutation. Note that in
  3334. // order to get all numeric fields that were incremented/decremented, call
  3335. // AddedFields().
  3336. func (m *AliyunAvatarMutation) Fields() []string {
  3337. fields := make([]string, 0, 12)
  3338. if m.created_at != nil {
  3339. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3340. }
  3341. if m.updated_at != nil {
  3342. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3343. }
  3344. if m.deleted_at != nil {
  3345. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3346. }
  3347. if m.user_id != nil {
  3348. fields = append(fields, aliyunavatar.FieldUserID)
  3349. }
  3350. if m.biz_id != nil {
  3351. fields = append(fields, aliyunavatar.FieldBizID)
  3352. }
  3353. if m.access_key_id != nil {
  3354. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3355. }
  3356. if m.access_key_secret != nil {
  3357. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3358. }
  3359. if m.app_id != nil {
  3360. fields = append(fields, aliyunavatar.FieldAppID)
  3361. }
  3362. if m.tenant_id != nil {
  3363. fields = append(fields, aliyunavatar.FieldTenantID)
  3364. }
  3365. if m.response != nil {
  3366. fields = append(fields, aliyunavatar.FieldResponse)
  3367. }
  3368. if m.token != nil {
  3369. fields = append(fields, aliyunavatar.FieldToken)
  3370. }
  3371. if m.session_id != nil {
  3372. fields = append(fields, aliyunavatar.FieldSessionID)
  3373. }
  3374. return fields
  3375. }
  3376. // Field returns the value of a field with the given name. The second boolean
  3377. // return value indicates that this field was not set, or was not defined in the
  3378. // schema.
  3379. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3380. switch name {
  3381. case aliyunavatar.FieldCreatedAt:
  3382. return m.CreatedAt()
  3383. case aliyunavatar.FieldUpdatedAt:
  3384. return m.UpdatedAt()
  3385. case aliyunavatar.FieldDeletedAt:
  3386. return m.DeletedAt()
  3387. case aliyunavatar.FieldUserID:
  3388. return m.UserID()
  3389. case aliyunavatar.FieldBizID:
  3390. return m.BizID()
  3391. case aliyunavatar.FieldAccessKeyID:
  3392. return m.AccessKeyID()
  3393. case aliyunavatar.FieldAccessKeySecret:
  3394. return m.AccessKeySecret()
  3395. case aliyunavatar.FieldAppID:
  3396. return m.AppID()
  3397. case aliyunavatar.FieldTenantID:
  3398. return m.TenantID()
  3399. case aliyunavatar.FieldResponse:
  3400. return m.Response()
  3401. case aliyunavatar.FieldToken:
  3402. return m.Token()
  3403. case aliyunavatar.FieldSessionID:
  3404. return m.SessionID()
  3405. }
  3406. return nil, false
  3407. }
  3408. // OldField returns the old value of the field from the database. An error is
  3409. // returned if the mutation operation is not UpdateOne, or the query to the
  3410. // database failed.
  3411. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3412. switch name {
  3413. case aliyunavatar.FieldCreatedAt:
  3414. return m.OldCreatedAt(ctx)
  3415. case aliyunavatar.FieldUpdatedAt:
  3416. return m.OldUpdatedAt(ctx)
  3417. case aliyunavatar.FieldDeletedAt:
  3418. return m.OldDeletedAt(ctx)
  3419. case aliyunavatar.FieldUserID:
  3420. return m.OldUserID(ctx)
  3421. case aliyunavatar.FieldBizID:
  3422. return m.OldBizID(ctx)
  3423. case aliyunavatar.FieldAccessKeyID:
  3424. return m.OldAccessKeyID(ctx)
  3425. case aliyunavatar.FieldAccessKeySecret:
  3426. return m.OldAccessKeySecret(ctx)
  3427. case aliyunavatar.FieldAppID:
  3428. return m.OldAppID(ctx)
  3429. case aliyunavatar.FieldTenantID:
  3430. return m.OldTenantID(ctx)
  3431. case aliyunavatar.FieldResponse:
  3432. return m.OldResponse(ctx)
  3433. case aliyunavatar.FieldToken:
  3434. return m.OldToken(ctx)
  3435. case aliyunavatar.FieldSessionID:
  3436. return m.OldSessionID(ctx)
  3437. }
  3438. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3439. }
  3440. // SetField sets the value of a field with the given name. It returns an error if
  3441. // the field is not defined in the schema, or if the type mismatched the field
  3442. // type.
  3443. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3444. switch name {
  3445. case aliyunavatar.FieldCreatedAt:
  3446. v, ok := value.(time.Time)
  3447. if !ok {
  3448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3449. }
  3450. m.SetCreatedAt(v)
  3451. return nil
  3452. case aliyunavatar.FieldUpdatedAt:
  3453. v, ok := value.(time.Time)
  3454. if !ok {
  3455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3456. }
  3457. m.SetUpdatedAt(v)
  3458. return nil
  3459. case aliyunavatar.FieldDeletedAt:
  3460. v, ok := value.(time.Time)
  3461. if !ok {
  3462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3463. }
  3464. m.SetDeletedAt(v)
  3465. return nil
  3466. case aliyunavatar.FieldUserID:
  3467. v, ok := value.(uint64)
  3468. if !ok {
  3469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3470. }
  3471. m.SetUserID(v)
  3472. return nil
  3473. case aliyunavatar.FieldBizID:
  3474. v, ok := value.(string)
  3475. if !ok {
  3476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3477. }
  3478. m.SetBizID(v)
  3479. return nil
  3480. case aliyunavatar.FieldAccessKeyID:
  3481. v, ok := value.(string)
  3482. if !ok {
  3483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3484. }
  3485. m.SetAccessKeyID(v)
  3486. return nil
  3487. case aliyunavatar.FieldAccessKeySecret:
  3488. v, ok := value.(string)
  3489. if !ok {
  3490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3491. }
  3492. m.SetAccessKeySecret(v)
  3493. return nil
  3494. case aliyunavatar.FieldAppID:
  3495. v, ok := value.(string)
  3496. if !ok {
  3497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3498. }
  3499. m.SetAppID(v)
  3500. return nil
  3501. case aliyunavatar.FieldTenantID:
  3502. v, ok := value.(uint64)
  3503. if !ok {
  3504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3505. }
  3506. m.SetTenantID(v)
  3507. return nil
  3508. case aliyunavatar.FieldResponse:
  3509. v, ok := value.(string)
  3510. if !ok {
  3511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3512. }
  3513. m.SetResponse(v)
  3514. return nil
  3515. case aliyunavatar.FieldToken:
  3516. v, ok := value.(string)
  3517. if !ok {
  3518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3519. }
  3520. m.SetToken(v)
  3521. return nil
  3522. case aliyunavatar.FieldSessionID:
  3523. v, ok := value.(string)
  3524. if !ok {
  3525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3526. }
  3527. m.SetSessionID(v)
  3528. return nil
  3529. }
  3530. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3531. }
  3532. // AddedFields returns all numeric fields that were incremented/decremented during
  3533. // this mutation.
  3534. func (m *AliyunAvatarMutation) AddedFields() []string {
  3535. var fields []string
  3536. if m.adduser_id != nil {
  3537. fields = append(fields, aliyunavatar.FieldUserID)
  3538. }
  3539. if m.addtenant_id != nil {
  3540. fields = append(fields, aliyunavatar.FieldTenantID)
  3541. }
  3542. return fields
  3543. }
  3544. // AddedField returns the numeric value that was incremented/decremented on a field
  3545. // with the given name. The second boolean return value indicates that this field
  3546. // was not set, or was not defined in the schema.
  3547. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3548. switch name {
  3549. case aliyunavatar.FieldUserID:
  3550. return m.AddedUserID()
  3551. case aliyunavatar.FieldTenantID:
  3552. return m.AddedTenantID()
  3553. }
  3554. return nil, false
  3555. }
  3556. // AddField adds the value to the field with the given name. It returns an error if
  3557. // the field is not defined in the schema, or if the type mismatched the field
  3558. // type.
  3559. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3560. switch name {
  3561. case aliyunavatar.FieldUserID:
  3562. v, ok := value.(int64)
  3563. if !ok {
  3564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3565. }
  3566. m.AddUserID(v)
  3567. return nil
  3568. case aliyunavatar.FieldTenantID:
  3569. v, ok := value.(int64)
  3570. if !ok {
  3571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3572. }
  3573. m.AddTenantID(v)
  3574. return nil
  3575. }
  3576. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3577. }
  3578. // ClearedFields returns all nullable fields that were cleared during this
  3579. // mutation.
  3580. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3581. var fields []string
  3582. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3583. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3584. }
  3585. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3586. fields = append(fields, aliyunavatar.FieldAppID)
  3587. }
  3588. return fields
  3589. }
  3590. // FieldCleared returns a boolean indicating if a field with the given name was
  3591. // cleared in this mutation.
  3592. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3593. _, ok := m.clearedFields[name]
  3594. return ok
  3595. }
  3596. // ClearField clears the value of the field with the given name. It returns an
  3597. // error if the field is not defined in the schema.
  3598. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3599. switch name {
  3600. case aliyunavatar.FieldDeletedAt:
  3601. m.ClearDeletedAt()
  3602. return nil
  3603. case aliyunavatar.FieldAppID:
  3604. m.ClearAppID()
  3605. return nil
  3606. }
  3607. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3608. }
  3609. // ResetField resets all changes in the mutation for the field with the given name.
  3610. // It returns an error if the field is not defined in the schema.
  3611. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3612. switch name {
  3613. case aliyunavatar.FieldCreatedAt:
  3614. m.ResetCreatedAt()
  3615. return nil
  3616. case aliyunavatar.FieldUpdatedAt:
  3617. m.ResetUpdatedAt()
  3618. return nil
  3619. case aliyunavatar.FieldDeletedAt:
  3620. m.ResetDeletedAt()
  3621. return nil
  3622. case aliyunavatar.FieldUserID:
  3623. m.ResetUserID()
  3624. return nil
  3625. case aliyunavatar.FieldBizID:
  3626. m.ResetBizID()
  3627. return nil
  3628. case aliyunavatar.FieldAccessKeyID:
  3629. m.ResetAccessKeyID()
  3630. return nil
  3631. case aliyunavatar.FieldAccessKeySecret:
  3632. m.ResetAccessKeySecret()
  3633. return nil
  3634. case aliyunavatar.FieldAppID:
  3635. m.ResetAppID()
  3636. return nil
  3637. case aliyunavatar.FieldTenantID:
  3638. m.ResetTenantID()
  3639. return nil
  3640. case aliyunavatar.FieldResponse:
  3641. m.ResetResponse()
  3642. return nil
  3643. case aliyunavatar.FieldToken:
  3644. m.ResetToken()
  3645. return nil
  3646. case aliyunavatar.FieldSessionID:
  3647. m.ResetSessionID()
  3648. return nil
  3649. }
  3650. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3651. }
  3652. // AddedEdges returns all edge names that were set/added in this mutation.
  3653. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3654. edges := make([]string, 0, 0)
  3655. return edges
  3656. }
  3657. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3658. // name in this mutation.
  3659. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3660. return nil
  3661. }
  3662. // RemovedEdges returns all edge names that were removed in this mutation.
  3663. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3664. edges := make([]string, 0, 0)
  3665. return edges
  3666. }
  3667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3668. // the given name in this mutation.
  3669. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3670. return nil
  3671. }
  3672. // ClearedEdges returns all edge names that were cleared in this mutation.
  3673. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3674. edges := make([]string, 0, 0)
  3675. return edges
  3676. }
  3677. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3678. // was cleared in this mutation.
  3679. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3680. return false
  3681. }
  3682. // ClearEdge clears the value of the edge with the given name. It returns an error
  3683. // if that edge is not defined in the schema.
  3684. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3685. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3686. }
  3687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3688. // It returns an error if the edge is not defined in the schema.
  3689. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3690. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3691. }
  3692. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3693. type AllocAgentMutation struct {
  3694. config
  3695. op Op
  3696. typ string
  3697. id *uint64
  3698. created_at *time.Time
  3699. updated_at *time.Time
  3700. deleted_at *time.Time
  3701. user_id *string
  3702. organization_id *uint64
  3703. addorganization_id *int64
  3704. agents *[]uint64
  3705. appendagents []uint64
  3706. status *int
  3707. addstatus *int
  3708. clearedFields map[string]struct{}
  3709. done bool
  3710. oldValue func(context.Context) (*AllocAgent, error)
  3711. predicates []predicate.AllocAgent
  3712. }
  3713. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3714. // allocagentOption allows management of the mutation configuration using functional options.
  3715. type allocagentOption func(*AllocAgentMutation)
  3716. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3717. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3718. m := &AllocAgentMutation{
  3719. config: c,
  3720. op: op,
  3721. typ: TypeAllocAgent,
  3722. clearedFields: make(map[string]struct{}),
  3723. }
  3724. for _, opt := range opts {
  3725. opt(m)
  3726. }
  3727. return m
  3728. }
  3729. // withAllocAgentID sets the ID field of the mutation.
  3730. func withAllocAgentID(id uint64) allocagentOption {
  3731. return func(m *AllocAgentMutation) {
  3732. var (
  3733. err error
  3734. once sync.Once
  3735. value *AllocAgent
  3736. )
  3737. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3738. once.Do(func() {
  3739. if m.done {
  3740. err = errors.New("querying old values post mutation is not allowed")
  3741. } else {
  3742. value, err = m.Client().AllocAgent.Get(ctx, id)
  3743. }
  3744. })
  3745. return value, err
  3746. }
  3747. m.id = &id
  3748. }
  3749. }
  3750. // withAllocAgent sets the old AllocAgent of the mutation.
  3751. func withAllocAgent(node *AllocAgent) allocagentOption {
  3752. return func(m *AllocAgentMutation) {
  3753. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3754. return node, nil
  3755. }
  3756. m.id = &node.ID
  3757. }
  3758. }
  3759. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3760. // executed in a transaction (ent.Tx), a transactional client is returned.
  3761. func (m AllocAgentMutation) Client() *Client {
  3762. client := &Client{config: m.config}
  3763. client.init()
  3764. return client
  3765. }
  3766. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3767. // it returns an error otherwise.
  3768. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3769. if _, ok := m.driver.(*txDriver); !ok {
  3770. return nil, errors.New("ent: mutation is not running in a transaction")
  3771. }
  3772. tx := &Tx{config: m.config}
  3773. tx.init()
  3774. return tx, nil
  3775. }
  3776. // SetID sets the value of the id field. Note that this
  3777. // operation is only accepted on creation of AllocAgent entities.
  3778. func (m *AllocAgentMutation) SetID(id uint64) {
  3779. m.id = &id
  3780. }
  3781. // ID returns the ID value in the mutation. Note that the ID is only available
  3782. // if it was provided to the builder or after it was returned from the database.
  3783. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3784. if m.id == nil {
  3785. return
  3786. }
  3787. return *m.id, true
  3788. }
  3789. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3790. // That means, if the mutation is applied within a transaction with an isolation level such
  3791. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3792. // or updated by the mutation.
  3793. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3794. switch {
  3795. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3796. id, exists := m.ID()
  3797. if exists {
  3798. return []uint64{id}, nil
  3799. }
  3800. fallthrough
  3801. case m.op.Is(OpUpdate | OpDelete):
  3802. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3803. default:
  3804. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3805. }
  3806. }
  3807. // SetCreatedAt sets the "created_at" field.
  3808. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3809. m.created_at = &t
  3810. }
  3811. // CreatedAt returns the value of the "created_at" field in the mutation.
  3812. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3813. v := m.created_at
  3814. if v == nil {
  3815. return
  3816. }
  3817. return *v, true
  3818. }
  3819. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3820. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3822. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3823. if !m.op.Is(OpUpdateOne) {
  3824. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3825. }
  3826. if m.id == nil || m.oldValue == nil {
  3827. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3828. }
  3829. oldValue, err := m.oldValue(ctx)
  3830. if err != nil {
  3831. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3832. }
  3833. return oldValue.CreatedAt, nil
  3834. }
  3835. // ResetCreatedAt resets all changes to the "created_at" field.
  3836. func (m *AllocAgentMutation) ResetCreatedAt() {
  3837. m.created_at = nil
  3838. }
  3839. // SetUpdatedAt sets the "updated_at" field.
  3840. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3841. m.updated_at = &t
  3842. }
  3843. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3844. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3845. v := m.updated_at
  3846. if v == nil {
  3847. return
  3848. }
  3849. return *v, true
  3850. }
  3851. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3852. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3854. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3855. if !m.op.Is(OpUpdateOne) {
  3856. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3857. }
  3858. if m.id == nil || m.oldValue == nil {
  3859. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3860. }
  3861. oldValue, err := m.oldValue(ctx)
  3862. if err != nil {
  3863. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3864. }
  3865. return oldValue.UpdatedAt, nil
  3866. }
  3867. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3868. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3869. m.updated_at = nil
  3870. }
  3871. // SetDeletedAt sets the "deleted_at" field.
  3872. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3873. m.deleted_at = &t
  3874. }
  3875. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3876. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3877. v := m.deleted_at
  3878. if v == nil {
  3879. return
  3880. }
  3881. return *v, true
  3882. }
  3883. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3884. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3886. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3887. if !m.op.Is(OpUpdateOne) {
  3888. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3889. }
  3890. if m.id == nil || m.oldValue == nil {
  3891. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3892. }
  3893. oldValue, err := m.oldValue(ctx)
  3894. if err != nil {
  3895. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3896. }
  3897. return oldValue.DeletedAt, nil
  3898. }
  3899. // ClearDeletedAt clears the value of the "deleted_at" field.
  3900. func (m *AllocAgentMutation) ClearDeletedAt() {
  3901. m.deleted_at = nil
  3902. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3903. }
  3904. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3905. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3906. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3907. return ok
  3908. }
  3909. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3910. func (m *AllocAgentMutation) ResetDeletedAt() {
  3911. m.deleted_at = nil
  3912. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3913. }
  3914. // SetUserID sets the "user_id" field.
  3915. func (m *AllocAgentMutation) SetUserID(s string) {
  3916. m.user_id = &s
  3917. }
  3918. // UserID returns the value of the "user_id" field in the mutation.
  3919. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3920. v := m.user_id
  3921. if v == nil {
  3922. return
  3923. }
  3924. return *v, true
  3925. }
  3926. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3927. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3929. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3930. if !m.op.Is(OpUpdateOne) {
  3931. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3932. }
  3933. if m.id == nil || m.oldValue == nil {
  3934. return v, errors.New("OldUserID requires an ID field in the mutation")
  3935. }
  3936. oldValue, err := m.oldValue(ctx)
  3937. if err != nil {
  3938. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3939. }
  3940. return oldValue.UserID, nil
  3941. }
  3942. // ClearUserID clears the value of the "user_id" field.
  3943. func (m *AllocAgentMutation) ClearUserID() {
  3944. m.user_id = nil
  3945. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3946. }
  3947. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3948. func (m *AllocAgentMutation) UserIDCleared() bool {
  3949. _, ok := m.clearedFields[allocagent.FieldUserID]
  3950. return ok
  3951. }
  3952. // ResetUserID resets all changes to the "user_id" field.
  3953. func (m *AllocAgentMutation) ResetUserID() {
  3954. m.user_id = nil
  3955. delete(m.clearedFields, allocagent.FieldUserID)
  3956. }
  3957. // SetOrganizationID sets the "organization_id" field.
  3958. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3959. m.organization_id = &u
  3960. m.addorganization_id = nil
  3961. }
  3962. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3963. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3964. v := m.organization_id
  3965. if v == nil {
  3966. return
  3967. }
  3968. return *v, true
  3969. }
  3970. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3971. // If the AllocAgent 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 *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3974. if !m.op.Is(OpUpdateOne) {
  3975. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3976. }
  3977. if m.id == nil || m.oldValue == nil {
  3978. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  3983. }
  3984. return oldValue.OrganizationID, nil
  3985. }
  3986. // AddOrganizationID adds u to the "organization_id" field.
  3987. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3988. if m.addorganization_id != nil {
  3989. *m.addorganization_id += u
  3990. } else {
  3991. m.addorganization_id = &u
  3992. }
  3993. }
  3994. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3995. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3996. v := m.addorganization_id
  3997. if v == nil {
  3998. return
  3999. }
  4000. return *v, true
  4001. }
  4002. // ClearOrganizationID clears the value of the "organization_id" field.
  4003. func (m *AllocAgentMutation) ClearOrganizationID() {
  4004. m.organization_id = nil
  4005. m.addorganization_id = nil
  4006. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4007. }
  4008. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4009. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4010. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4011. return ok
  4012. }
  4013. // ResetOrganizationID resets all changes to the "organization_id" field.
  4014. func (m *AllocAgentMutation) ResetOrganizationID() {
  4015. m.organization_id = nil
  4016. m.addorganization_id = nil
  4017. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4018. }
  4019. // SetAgents sets the "agents" field.
  4020. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4021. m.agents = &u
  4022. m.appendagents = nil
  4023. }
  4024. // Agents returns the value of the "agents" field in the mutation.
  4025. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4026. v := m.agents
  4027. if v == nil {
  4028. return
  4029. }
  4030. return *v, true
  4031. }
  4032. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4033. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4035. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4036. if !m.op.Is(OpUpdateOne) {
  4037. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4038. }
  4039. if m.id == nil || m.oldValue == nil {
  4040. return v, errors.New("OldAgents requires an ID field in the mutation")
  4041. }
  4042. oldValue, err := m.oldValue(ctx)
  4043. if err != nil {
  4044. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4045. }
  4046. return oldValue.Agents, nil
  4047. }
  4048. // AppendAgents adds u to the "agents" field.
  4049. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4050. m.appendagents = append(m.appendagents, u...)
  4051. }
  4052. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4053. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4054. if len(m.appendagents) == 0 {
  4055. return nil, false
  4056. }
  4057. return m.appendagents, true
  4058. }
  4059. // ResetAgents resets all changes to the "agents" field.
  4060. func (m *AllocAgentMutation) ResetAgents() {
  4061. m.agents = nil
  4062. m.appendagents = nil
  4063. }
  4064. // SetStatus sets the "status" field.
  4065. func (m *AllocAgentMutation) SetStatus(i int) {
  4066. m.status = &i
  4067. m.addstatus = nil
  4068. }
  4069. // Status returns the value of the "status" field in the mutation.
  4070. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4071. v := m.status
  4072. if v == nil {
  4073. return
  4074. }
  4075. return *v, true
  4076. }
  4077. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4078. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4080. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4081. if !m.op.Is(OpUpdateOne) {
  4082. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4083. }
  4084. if m.id == nil || m.oldValue == nil {
  4085. return v, errors.New("OldStatus requires an ID field in the mutation")
  4086. }
  4087. oldValue, err := m.oldValue(ctx)
  4088. if err != nil {
  4089. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4090. }
  4091. return oldValue.Status, nil
  4092. }
  4093. // AddStatus adds i to the "status" field.
  4094. func (m *AllocAgentMutation) AddStatus(i int) {
  4095. if m.addstatus != nil {
  4096. *m.addstatus += i
  4097. } else {
  4098. m.addstatus = &i
  4099. }
  4100. }
  4101. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4102. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4103. v := m.addstatus
  4104. if v == nil {
  4105. return
  4106. }
  4107. return *v, true
  4108. }
  4109. // ClearStatus clears the value of the "status" field.
  4110. func (m *AllocAgentMutation) ClearStatus() {
  4111. m.status = nil
  4112. m.addstatus = nil
  4113. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4114. }
  4115. // StatusCleared returns if the "status" field was cleared in this mutation.
  4116. func (m *AllocAgentMutation) StatusCleared() bool {
  4117. _, ok := m.clearedFields[allocagent.FieldStatus]
  4118. return ok
  4119. }
  4120. // ResetStatus resets all changes to the "status" field.
  4121. func (m *AllocAgentMutation) ResetStatus() {
  4122. m.status = nil
  4123. m.addstatus = nil
  4124. delete(m.clearedFields, allocagent.FieldStatus)
  4125. }
  4126. // Where appends a list predicates to the AllocAgentMutation builder.
  4127. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4128. m.predicates = append(m.predicates, ps...)
  4129. }
  4130. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4131. // users can use type-assertion to append predicates that do not depend on any generated package.
  4132. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4133. p := make([]predicate.AllocAgent, len(ps))
  4134. for i := range ps {
  4135. p[i] = ps[i]
  4136. }
  4137. m.Where(p...)
  4138. }
  4139. // Op returns the operation name.
  4140. func (m *AllocAgentMutation) Op() Op {
  4141. return m.op
  4142. }
  4143. // SetOp allows setting the mutation operation.
  4144. func (m *AllocAgentMutation) SetOp(op Op) {
  4145. m.op = op
  4146. }
  4147. // Type returns the node type of this mutation (AllocAgent).
  4148. func (m *AllocAgentMutation) Type() string {
  4149. return m.typ
  4150. }
  4151. // Fields returns all fields that were changed during this mutation. Note that in
  4152. // order to get all numeric fields that were incremented/decremented, call
  4153. // AddedFields().
  4154. func (m *AllocAgentMutation) Fields() []string {
  4155. fields := make([]string, 0, 7)
  4156. if m.created_at != nil {
  4157. fields = append(fields, allocagent.FieldCreatedAt)
  4158. }
  4159. if m.updated_at != nil {
  4160. fields = append(fields, allocagent.FieldUpdatedAt)
  4161. }
  4162. if m.deleted_at != nil {
  4163. fields = append(fields, allocagent.FieldDeletedAt)
  4164. }
  4165. if m.user_id != nil {
  4166. fields = append(fields, allocagent.FieldUserID)
  4167. }
  4168. if m.organization_id != nil {
  4169. fields = append(fields, allocagent.FieldOrganizationID)
  4170. }
  4171. if m.agents != nil {
  4172. fields = append(fields, allocagent.FieldAgents)
  4173. }
  4174. if m.status != nil {
  4175. fields = append(fields, allocagent.FieldStatus)
  4176. }
  4177. return fields
  4178. }
  4179. // Field returns the value of a field with the given name. The second boolean
  4180. // return value indicates that this field was not set, or was not defined in the
  4181. // schema.
  4182. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4183. switch name {
  4184. case allocagent.FieldCreatedAt:
  4185. return m.CreatedAt()
  4186. case allocagent.FieldUpdatedAt:
  4187. return m.UpdatedAt()
  4188. case allocagent.FieldDeletedAt:
  4189. return m.DeletedAt()
  4190. case allocagent.FieldUserID:
  4191. return m.UserID()
  4192. case allocagent.FieldOrganizationID:
  4193. return m.OrganizationID()
  4194. case allocagent.FieldAgents:
  4195. return m.Agents()
  4196. case allocagent.FieldStatus:
  4197. return m.Status()
  4198. }
  4199. return nil, false
  4200. }
  4201. // OldField returns the old value of the field from the database. An error is
  4202. // returned if the mutation operation is not UpdateOne, or the query to the
  4203. // database failed.
  4204. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4205. switch name {
  4206. case allocagent.FieldCreatedAt:
  4207. return m.OldCreatedAt(ctx)
  4208. case allocagent.FieldUpdatedAt:
  4209. return m.OldUpdatedAt(ctx)
  4210. case allocagent.FieldDeletedAt:
  4211. return m.OldDeletedAt(ctx)
  4212. case allocagent.FieldUserID:
  4213. return m.OldUserID(ctx)
  4214. case allocagent.FieldOrganizationID:
  4215. return m.OldOrganizationID(ctx)
  4216. case allocagent.FieldAgents:
  4217. return m.OldAgents(ctx)
  4218. case allocagent.FieldStatus:
  4219. return m.OldStatus(ctx)
  4220. }
  4221. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4222. }
  4223. // SetField sets the value of a field with the given name. It returns an error if
  4224. // the field is not defined in the schema, or if the type mismatched the field
  4225. // type.
  4226. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4227. switch name {
  4228. case allocagent.FieldCreatedAt:
  4229. v, ok := value.(time.Time)
  4230. if !ok {
  4231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4232. }
  4233. m.SetCreatedAt(v)
  4234. return nil
  4235. case allocagent.FieldUpdatedAt:
  4236. v, ok := value.(time.Time)
  4237. if !ok {
  4238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4239. }
  4240. m.SetUpdatedAt(v)
  4241. return nil
  4242. case allocagent.FieldDeletedAt:
  4243. v, ok := value.(time.Time)
  4244. if !ok {
  4245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4246. }
  4247. m.SetDeletedAt(v)
  4248. return nil
  4249. case allocagent.FieldUserID:
  4250. v, ok := value.(string)
  4251. if !ok {
  4252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4253. }
  4254. m.SetUserID(v)
  4255. return nil
  4256. case allocagent.FieldOrganizationID:
  4257. v, ok := value.(uint64)
  4258. if !ok {
  4259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4260. }
  4261. m.SetOrganizationID(v)
  4262. return nil
  4263. case allocagent.FieldAgents:
  4264. v, ok := value.([]uint64)
  4265. if !ok {
  4266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4267. }
  4268. m.SetAgents(v)
  4269. return nil
  4270. case allocagent.FieldStatus:
  4271. v, ok := value.(int)
  4272. if !ok {
  4273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4274. }
  4275. m.SetStatus(v)
  4276. return nil
  4277. }
  4278. return fmt.Errorf("unknown AllocAgent field %s", name)
  4279. }
  4280. // AddedFields returns all numeric fields that were incremented/decremented during
  4281. // this mutation.
  4282. func (m *AllocAgentMutation) AddedFields() []string {
  4283. var fields []string
  4284. if m.addorganization_id != nil {
  4285. fields = append(fields, allocagent.FieldOrganizationID)
  4286. }
  4287. if m.addstatus != nil {
  4288. fields = append(fields, allocagent.FieldStatus)
  4289. }
  4290. return fields
  4291. }
  4292. // AddedField returns the numeric value that was incremented/decremented on a field
  4293. // with the given name. The second boolean return value indicates that this field
  4294. // was not set, or was not defined in the schema.
  4295. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4296. switch name {
  4297. case allocagent.FieldOrganizationID:
  4298. return m.AddedOrganizationID()
  4299. case allocagent.FieldStatus:
  4300. return m.AddedStatus()
  4301. }
  4302. return nil, false
  4303. }
  4304. // AddField adds the value to the field with the given name. It returns an error if
  4305. // the field is not defined in the schema, or if the type mismatched the field
  4306. // type.
  4307. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4308. switch name {
  4309. case allocagent.FieldOrganizationID:
  4310. v, ok := value.(int64)
  4311. if !ok {
  4312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4313. }
  4314. m.AddOrganizationID(v)
  4315. return nil
  4316. case allocagent.FieldStatus:
  4317. v, ok := value.(int)
  4318. if !ok {
  4319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4320. }
  4321. m.AddStatus(v)
  4322. return nil
  4323. }
  4324. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4325. }
  4326. // ClearedFields returns all nullable fields that were cleared during this
  4327. // mutation.
  4328. func (m *AllocAgentMutation) ClearedFields() []string {
  4329. var fields []string
  4330. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4331. fields = append(fields, allocagent.FieldDeletedAt)
  4332. }
  4333. if m.FieldCleared(allocagent.FieldUserID) {
  4334. fields = append(fields, allocagent.FieldUserID)
  4335. }
  4336. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4337. fields = append(fields, allocagent.FieldOrganizationID)
  4338. }
  4339. if m.FieldCleared(allocagent.FieldStatus) {
  4340. fields = append(fields, allocagent.FieldStatus)
  4341. }
  4342. return fields
  4343. }
  4344. // FieldCleared returns a boolean indicating if a field with the given name was
  4345. // cleared in this mutation.
  4346. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4347. _, ok := m.clearedFields[name]
  4348. return ok
  4349. }
  4350. // ClearField clears the value of the field with the given name. It returns an
  4351. // error if the field is not defined in the schema.
  4352. func (m *AllocAgentMutation) ClearField(name string) error {
  4353. switch name {
  4354. case allocagent.FieldDeletedAt:
  4355. m.ClearDeletedAt()
  4356. return nil
  4357. case allocagent.FieldUserID:
  4358. m.ClearUserID()
  4359. return nil
  4360. case allocagent.FieldOrganizationID:
  4361. m.ClearOrganizationID()
  4362. return nil
  4363. case allocagent.FieldStatus:
  4364. m.ClearStatus()
  4365. return nil
  4366. }
  4367. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4368. }
  4369. // ResetField resets all changes in the mutation for the field with the given name.
  4370. // It returns an error if the field is not defined in the schema.
  4371. func (m *AllocAgentMutation) ResetField(name string) error {
  4372. switch name {
  4373. case allocagent.FieldCreatedAt:
  4374. m.ResetCreatedAt()
  4375. return nil
  4376. case allocagent.FieldUpdatedAt:
  4377. m.ResetUpdatedAt()
  4378. return nil
  4379. case allocagent.FieldDeletedAt:
  4380. m.ResetDeletedAt()
  4381. return nil
  4382. case allocagent.FieldUserID:
  4383. m.ResetUserID()
  4384. return nil
  4385. case allocagent.FieldOrganizationID:
  4386. m.ResetOrganizationID()
  4387. return nil
  4388. case allocagent.FieldAgents:
  4389. m.ResetAgents()
  4390. return nil
  4391. case allocagent.FieldStatus:
  4392. m.ResetStatus()
  4393. return nil
  4394. }
  4395. return fmt.Errorf("unknown AllocAgent field %s", name)
  4396. }
  4397. // AddedEdges returns all edge names that were set/added in this mutation.
  4398. func (m *AllocAgentMutation) AddedEdges() []string {
  4399. edges := make([]string, 0, 0)
  4400. return edges
  4401. }
  4402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4403. // name in this mutation.
  4404. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4405. return nil
  4406. }
  4407. // RemovedEdges returns all edge names that were removed in this mutation.
  4408. func (m *AllocAgentMutation) RemovedEdges() []string {
  4409. edges := make([]string, 0, 0)
  4410. return edges
  4411. }
  4412. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4413. // the given name in this mutation.
  4414. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4415. return nil
  4416. }
  4417. // ClearedEdges returns all edge names that were cleared in this mutation.
  4418. func (m *AllocAgentMutation) ClearedEdges() []string {
  4419. edges := make([]string, 0, 0)
  4420. return edges
  4421. }
  4422. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4423. // was cleared in this mutation.
  4424. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4425. return false
  4426. }
  4427. // ClearEdge clears the value of the edge with the given name. It returns an error
  4428. // if that edge is not defined in the schema.
  4429. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4430. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4431. }
  4432. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4433. // It returns an error if the edge is not defined in the schema.
  4434. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4435. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4436. }
  4437. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4438. type ApiKeyMutation struct {
  4439. config
  4440. op Op
  4441. typ string
  4442. id *uint64
  4443. created_at *time.Time
  4444. updated_at *time.Time
  4445. deleted_at *time.Time
  4446. title *string
  4447. key *string
  4448. organization_id *uint64
  4449. addorganization_id *int64
  4450. custom_agent_base *string
  4451. custom_agent_key *string
  4452. openai_base *string
  4453. openai_key *string
  4454. clearedFields map[string]struct{}
  4455. agent *uint64
  4456. clearedagent bool
  4457. done bool
  4458. oldValue func(context.Context) (*ApiKey, error)
  4459. predicates []predicate.ApiKey
  4460. }
  4461. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4462. // apikeyOption allows management of the mutation configuration using functional options.
  4463. type apikeyOption func(*ApiKeyMutation)
  4464. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4465. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4466. m := &ApiKeyMutation{
  4467. config: c,
  4468. op: op,
  4469. typ: TypeApiKey,
  4470. clearedFields: make(map[string]struct{}),
  4471. }
  4472. for _, opt := range opts {
  4473. opt(m)
  4474. }
  4475. return m
  4476. }
  4477. // withApiKeyID sets the ID field of the mutation.
  4478. func withApiKeyID(id uint64) apikeyOption {
  4479. return func(m *ApiKeyMutation) {
  4480. var (
  4481. err error
  4482. once sync.Once
  4483. value *ApiKey
  4484. )
  4485. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4486. once.Do(func() {
  4487. if m.done {
  4488. err = errors.New("querying old values post mutation is not allowed")
  4489. } else {
  4490. value, err = m.Client().ApiKey.Get(ctx, id)
  4491. }
  4492. })
  4493. return value, err
  4494. }
  4495. m.id = &id
  4496. }
  4497. }
  4498. // withApiKey sets the old ApiKey of the mutation.
  4499. func withApiKey(node *ApiKey) apikeyOption {
  4500. return func(m *ApiKeyMutation) {
  4501. m.oldValue = func(context.Context) (*ApiKey, error) {
  4502. return node, nil
  4503. }
  4504. m.id = &node.ID
  4505. }
  4506. }
  4507. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4508. // executed in a transaction (ent.Tx), a transactional client is returned.
  4509. func (m ApiKeyMutation) Client() *Client {
  4510. client := &Client{config: m.config}
  4511. client.init()
  4512. return client
  4513. }
  4514. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4515. // it returns an error otherwise.
  4516. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4517. if _, ok := m.driver.(*txDriver); !ok {
  4518. return nil, errors.New("ent: mutation is not running in a transaction")
  4519. }
  4520. tx := &Tx{config: m.config}
  4521. tx.init()
  4522. return tx, nil
  4523. }
  4524. // SetID sets the value of the id field. Note that this
  4525. // operation is only accepted on creation of ApiKey entities.
  4526. func (m *ApiKeyMutation) SetID(id uint64) {
  4527. m.id = &id
  4528. }
  4529. // ID returns the ID value in the mutation. Note that the ID is only available
  4530. // if it was provided to the builder or after it was returned from the database.
  4531. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4532. if m.id == nil {
  4533. return
  4534. }
  4535. return *m.id, true
  4536. }
  4537. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4538. // That means, if the mutation is applied within a transaction with an isolation level such
  4539. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4540. // or updated by the mutation.
  4541. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4542. switch {
  4543. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4544. id, exists := m.ID()
  4545. if exists {
  4546. return []uint64{id}, nil
  4547. }
  4548. fallthrough
  4549. case m.op.Is(OpUpdate | OpDelete):
  4550. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4551. default:
  4552. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4553. }
  4554. }
  4555. // SetCreatedAt sets the "created_at" field.
  4556. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4557. m.created_at = &t
  4558. }
  4559. // CreatedAt returns the value of the "created_at" field in the mutation.
  4560. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4561. v := m.created_at
  4562. if v == nil {
  4563. return
  4564. }
  4565. return *v, true
  4566. }
  4567. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4568. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4570. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4571. if !m.op.Is(OpUpdateOne) {
  4572. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4573. }
  4574. if m.id == nil || m.oldValue == nil {
  4575. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4576. }
  4577. oldValue, err := m.oldValue(ctx)
  4578. if err != nil {
  4579. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4580. }
  4581. return oldValue.CreatedAt, nil
  4582. }
  4583. // ResetCreatedAt resets all changes to the "created_at" field.
  4584. func (m *ApiKeyMutation) ResetCreatedAt() {
  4585. m.created_at = nil
  4586. }
  4587. // SetUpdatedAt sets the "updated_at" field.
  4588. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4589. m.updated_at = &t
  4590. }
  4591. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4592. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4593. v := m.updated_at
  4594. if v == nil {
  4595. return
  4596. }
  4597. return *v, true
  4598. }
  4599. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4600. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4602. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4603. if !m.op.Is(OpUpdateOne) {
  4604. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4605. }
  4606. if m.id == nil || m.oldValue == nil {
  4607. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4608. }
  4609. oldValue, err := m.oldValue(ctx)
  4610. if err != nil {
  4611. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4612. }
  4613. return oldValue.UpdatedAt, nil
  4614. }
  4615. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4616. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4617. m.updated_at = nil
  4618. }
  4619. // SetDeletedAt sets the "deleted_at" field.
  4620. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4621. m.deleted_at = &t
  4622. }
  4623. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4624. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4625. v := m.deleted_at
  4626. if v == nil {
  4627. return
  4628. }
  4629. return *v, true
  4630. }
  4631. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4632. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4634. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4635. if !m.op.Is(OpUpdateOne) {
  4636. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4637. }
  4638. if m.id == nil || m.oldValue == nil {
  4639. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4640. }
  4641. oldValue, err := m.oldValue(ctx)
  4642. if err != nil {
  4643. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4644. }
  4645. return oldValue.DeletedAt, nil
  4646. }
  4647. // ClearDeletedAt clears the value of the "deleted_at" field.
  4648. func (m *ApiKeyMutation) ClearDeletedAt() {
  4649. m.deleted_at = nil
  4650. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4651. }
  4652. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4653. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4654. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4655. return ok
  4656. }
  4657. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4658. func (m *ApiKeyMutation) ResetDeletedAt() {
  4659. m.deleted_at = nil
  4660. delete(m.clearedFields, apikey.FieldDeletedAt)
  4661. }
  4662. // SetTitle sets the "title" field.
  4663. func (m *ApiKeyMutation) SetTitle(s string) {
  4664. m.title = &s
  4665. }
  4666. // Title returns the value of the "title" field in the mutation.
  4667. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4668. v := m.title
  4669. if v == nil {
  4670. return
  4671. }
  4672. return *v, true
  4673. }
  4674. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4675. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4677. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4678. if !m.op.Is(OpUpdateOne) {
  4679. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4680. }
  4681. if m.id == nil || m.oldValue == nil {
  4682. return v, errors.New("OldTitle requires an ID field in the mutation")
  4683. }
  4684. oldValue, err := m.oldValue(ctx)
  4685. if err != nil {
  4686. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4687. }
  4688. return oldValue.Title, nil
  4689. }
  4690. // ClearTitle clears the value of the "title" field.
  4691. func (m *ApiKeyMutation) ClearTitle() {
  4692. m.title = nil
  4693. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4694. }
  4695. // TitleCleared returns if the "title" field was cleared in this mutation.
  4696. func (m *ApiKeyMutation) TitleCleared() bool {
  4697. _, ok := m.clearedFields[apikey.FieldTitle]
  4698. return ok
  4699. }
  4700. // ResetTitle resets all changes to the "title" field.
  4701. func (m *ApiKeyMutation) ResetTitle() {
  4702. m.title = nil
  4703. delete(m.clearedFields, apikey.FieldTitle)
  4704. }
  4705. // SetKey sets the "key" field.
  4706. func (m *ApiKeyMutation) SetKey(s string) {
  4707. m.key = &s
  4708. }
  4709. // Key returns the value of the "key" field in the mutation.
  4710. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4711. v := m.key
  4712. if v == nil {
  4713. return
  4714. }
  4715. return *v, true
  4716. }
  4717. // OldKey returns the old "key" field's value of the ApiKey entity.
  4718. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4720. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4721. if !m.op.Is(OpUpdateOne) {
  4722. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4723. }
  4724. if m.id == nil || m.oldValue == nil {
  4725. return v, errors.New("OldKey requires an ID field in the mutation")
  4726. }
  4727. oldValue, err := m.oldValue(ctx)
  4728. if err != nil {
  4729. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4730. }
  4731. return oldValue.Key, nil
  4732. }
  4733. // ClearKey clears the value of the "key" field.
  4734. func (m *ApiKeyMutation) ClearKey() {
  4735. m.key = nil
  4736. m.clearedFields[apikey.FieldKey] = struct{}{}
  4737. }
  4738. // KeyCleared returns if the "key" field was cleared in this mutation.
  4739. func (m *ApiKeyMutation) KeyCleared() bool {
  4740. _, ok := m.clearedFields[apikey.FieldKey]
  4741. return ok
  4742. }
  4743. // ResetKey resets all changes to the "key" field.
  4744. func (m *ApiKeyMutation) ResetKey() {
  4745. m.key = nil
  4746. delete(m.clearedFields, apikey.FieldKey)
  4747. }
  4748. // SetOrganizationID sets the "organization_id" field.
  4749. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4750. m.organization_id = &u
  4751. m.addorganization_id = nil
  4752. }
  4753. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4754. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4755. v := m.organization_id
  4756. if v == nil {
  4757. return
  4758. }
  4759. return *v, true
  4760. }
  4761. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4762. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4764. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4765. if !m.op.Is(OpUpdateOne) {
  4766. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4767. }
  4768. if m.id == nil || m.oldValue == nil {
  4769. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4770. }
  4771. oldValue, err := m.oldValue(ctx)
  4772. if err != nil {
  4773. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4774. }
  4775. return oldValue.OrganizationID, nil
  4776. }
  4777. // AddOrganizationID adds u to the "organization_id" field.
  4778. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4779. if m.addorganization_id != nil {
  4780. *m.addorganization_id += u
  4781. } else {
  4782. m.addorganization_id = &u
  4783. }
  4784. }
  4785. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4786. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4787. v := m.addorganization_id
  4788. if v == nil {
  4789. return
  4790. }
  4791. return *v, true
  4792. }
  4793. // ResetOrganizationID resets all changes to the "organization_id" field.
  4794. func (m *ApiKeyMutation) ResetOrganizationID() {
  4795. m.organization_id = nil
  4796. m.addorganization_id = nil
  4797. }
  4798. // SetAgentID sets the "agent_id" field.
  4799. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4800. m.agent = &u
  4801. }
  4802. // AgentID returns the value of the "agent_id" field in the mutation.
  4803. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4804. v := m.agent
  4805. if v == nil {
  4806. return
  4807. }
  4808. return *v, true
  4809. }
  4810. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4811. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4813. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4814. if !m.op.Is(OpUpdateOne) {
  4815. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4816. }
  4817. if m.id == nil || m.oldValue == nil {
  4818. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4819. }
  4820. oldValue, err := m.oldValue(ctx)
  4821. if err != nil {
  4822. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4823. }
  4824. return oldValue.AgentID, nil
  4825. }
  4826. // ResetAgentID resets all changes to the "agent_id" field.
  4827. func (m *ApiKeyMutation) ResetAgentID() {
  4828. m.agent = nil
  4829. }
  4830. // SetCustomAgentBase sets the "custom_agent_base" field.
  4831. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4832. m.custom_agent_base = &s
  4833. }
  4834. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4835. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4836. v := m.custom_agent_base
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4843. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4855. }
  4856. return oldValue.CustomAgentBase, nil
  4857. }
  4858. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4859. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4860. m.custom_agent_base = nil
  4861. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4862. }
  4863. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4864. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4865. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4866. return ok
  4867. }
  4868. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4869. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4870. m.custom_agent_base = nil
  4871. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4872. }
  4873. // SetCustomAgentKey sets the "custom_agent_key" field.
  4874. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4875. m.custom_agent_key = &s
  4876. }
  4877. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4878. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4879. v := m.custom_agent_key
  4880. if v == nil {
  4881. return
  4882. }
  4883. return *v, true
  4884. }
  4885. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4886. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4888. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4889. if !m.op.Is(OpUpdateOne) {
  4890. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4891. }
  4892. if m.id == nil || m.oldValue == nil {
  4893. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4894. }
  4895. oldValue, err := m.oldValue(ctx)
  4896. if err != nil {
  4897. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4898. }
  4899. return oldValue.CustomAgentKey, nil
  4900. }
  4901. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4902. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4903. m.custom_agent_key = nil
  4904. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4905. }
  4906. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4907. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4908. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4909. return ok
  4910. }
  4911. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4912. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4913. m.custom_agent_key = nil
  4914. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4915. }
  4916. // SetOpenaiBase sets the "openai_base" field.
  4917. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4918. m.openai_base = &s
  4919. }
  4920. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4921. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4922. v := m.openai_base
  4923. if v == nil {
  4924. return
  4925. }
  4926. return *v, true
  4927. }
  4928. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4929. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4931. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4932. if !m.op.Is(OpUpdateOne) {
  4933. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4934. }
  4935. if m.id == nil || m.oldValue == nil {
  4936. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4937. }
  4938. oldValue, err := m.oldValue(ctx)
  4939. if err != nil {
  4940. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4941. }
  4942. return oldValue.OpenaiBase, nil
  4943. }
  4944. // ClearOpenaiBase clears the value of the "openai_base" field.
  4945. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4946. m.openai_base = nil
  4947. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4948. }
  4949. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4950. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4951. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4952. return ok
  4953. }
  4954. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4955. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4956. m.openai_base = nil
  4957. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4958. }
  4959. // SetOpenaiKey sets the "openai_key" field.
  4960. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4961. m.openai_key = &s
  4962. }
  4963. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4964. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4965. v := m.openai_key
  4966. if v == nil {
  4967. return
  4968. }
  4969. return *v, true
  4970. }
  4971. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4972. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4974. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4975. if !m.op.Is(OpUpdateOne) {
  4976. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4977. }
  4978. if m.id == nil || m.oldValue == nil {
  4979. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4980. }
  4981. oldValue, err := m.oldValue(ctx)
  4982. if err != nil {
  4983. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4984. }
  4985. return oldValue.OpenaiKey, nil
  4986. }
  4987. // ClearOpenaiKey clears the value of the "openai_key" field.
  4988. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4989. m.openai_key = nil
  4990. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4991. }
  4992. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4993. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4994. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4995. return ok
  4996. }
  4997. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4998. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4999. m.openai_key = nil
  5000. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5001. }
  5002. // ClearAgent clears the "agent" edge to the Agent entity.
  5003. func (m *ApiKeyMutation) ClearAgent() {
  5004. m.clearedagent = true
  5005. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5006. }
  5007. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5008. func (m *ApiKeyMutation) AgentCleared() bool {
  5009. return m.clearedagent
  5010. }
  5011. // AgentIDs returns the "agent" edge IDs in the mutation.
  5012. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5013. // AgentID instead. It exists only for internal usage by the builders.
  5014. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5015. if id := m.agent; id != nil {
  5016. ids = append(ids, *id)
  5017. }
  5018. return
  5019. }
  5020. // ResetAgent resets all changes to the "agent" edge.
  5021. func (m *ApiKeyMutation) ResetAgent() {
  5022. m.agent = nil
  5023. m.clearedagent = false
  5024. }
  5025. // Where appends a list predicates to the ApiKeyMutation builder.
  5026. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5027. m.predicates = append(m.predicates, ps...)
  5028. }
  5029. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5030. // users can use type-assertion to append predicates that do not depend on any generated package.
  5031. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5032. p := make([]predicate.ApiKey, len(ps))
  5033. for i := range ps {
  5034. p[i] = ps[i]
  5035. }
  5036. m.Where(p...)
  5037. }
  5038. // Op returns the operation name.
  5039. func (m *ApiKeyMutation) Op() Op {
  5040. return m.op
  5041. }
  5042. // SetOp allows setting the mutation operation.
  5043. func (m *ApiKeyMutation) SetOp(op Op) {
  5044. m.op = op
  5045. }
  5046. // Type returns the node type of this mutation (ApiKey).
  5047. func (m *ApiKeyMutation) Type() string {
  5048. return m.typ
  5049. }
  5050. // Fields returns all fields that were changed during this mutation. Note that in
  5051. // order to get all numeric fields that were incremented/decremented, call
  5052. // AddedFields().
  5053. func (m *ApiKeyMutation) Fields() []string {
  5054. fields := make([]string, 0, 11)
  5055. if m.created_at != nil {
  5056. fields = append(fields, apikey.FieldCreatedAt)
  5057. }
  5058. if m.updated_at != nil {
  5059. fields = append(fields, apikey.FieldUpdatedAt)
  5060. }
  5061. if m.deleted_at != nil {
  5062. fields = append(fields, apikey.FieldDeletedAt)
  5063. }
  5064. if m.title != nil {
  5065. fields = append(fields, apikey.FieldTitle)
  5066. }
  5067. if m.key != nil {
  5068. fields = append(fields, apikey.FieldKey)
  5069. }
  5070. if m.organization_id != nil {
  5071. fields = append(fields, apikey.FieldOrganizationID)
  5072. }
  5073. if m.agent != nil {
  5074. fields = append(fields, apikey.FieldAgentID)
  5075. }
  5076. if m.custom_agent_base != nil {
  5077. fields = append(fields, apikey.FieldCustomAgentBase)
  5078. }
  5079. if m.custom_agent_key != nil {
  5080. fields = append(fields, apikey.FieldCustomAgentKey)
  5081. }
  5082. if m.openai_base != nil {
  5083. fields = append(fields, apikey.FieldOpenaiBase)
  5084. }
  5085. if m.openai_key != nil {
  5086. fields = append(fields, apikey.FieldOpenaiKey)
  5087. }
  5088. return fields
  5089. }
  5090. // Field returns the value of a field with the given name. The second boolean
  5091. // return value indicates that this field was not set, or was not defined in the
  5092. // schema.
  5093. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5094. switch name {
  5095. case apikey.FieldCreatedAt:
  5096. return m.CreatedAt()
  5097. case apikey.FieldUpdatedAt:
  5098. return m.UpdatedAt()
  5099. case apikey.FieldDeletedAt:
  5100. return m.DeletedAt()
  5101. case apikey.FieldTitle:
  5102. return m.Title()
  5103. case apikey.FieldKey:
  5104. return m.Key()
  5105. case apikey.FieldOrganizationID:
  5106. return m.OrganizationID()
  5107. case apikey.FieldAgentID:
  5108. return m.AgentID()
  5109. case apikey.FieldCustomAgentBase:
  5110. return m.CustomAgentBase()
  5111. case apikey.FieldCustomAgentKey:
  5112. return m.CustomAgentKey()
  5113. case apikey.FieldOpenaiBase:
  5114. return m.OpenaiBase()
  5115. case apikey.FieldOpenaiKey:
  5116. return m.OpenaiKey()
  5117. }
  5118. return nil, false
  5119. }
  5120. // OldField returns the old value of the field from the database. An error is
  5121. // returned if the mutation operation is not UpdateOne, or the query to the
  5122. // database failed.
  5123. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5124. switch name {
  5125. case apikey.FieldCreatedAt:
  5126. return m.OldCreatedAt(ctx)
  5127. case apikey.FieldUpdatedAt:
  5128. return m.OldUpdatedAt(ctx)
  5129. case apikey.FieldDeletedAt:
  5130. return m.OldDeletedAt(ctx)
  5131. case apikey.FieldTitle:
  5132. return m.OldTitle(ctx)
  5133. case apikey.FieldKey:
  5134. return m.OldKey(ctx)
  5135. case apikey.FieldOrganizationID:
  5136. return m.OldOrganizationID(ctx)
  5137. case apikey.FieldAgentID:
  5138. return m.OldAgentID(ctx)
  5139. case apikey.FieldCustomAgentBase:
  5140. return m.OldCustomAgentBase(ctx)
  5141. case apikey.FieldCustomAgentKey:
  5142. return m.OldCustomAgentKey(ctx)
  5143. case apikey.FieldOpenaiBase:
  5144. return m.OldOpenaiBase(ctx)
  5145. case apikey.FieldOpenaiKey:
  5146. return m.OldOpenaiKey(ctx)
  5147. }
  5148. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5149. }
  5150. // SetField sets the value of a field with the given name. It returns an error if
  5151. // the field is not defined in the schema, or if the type mismatched the field
  5152. // type.
  5153. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5154. switch name {
  5155. case apikey.FieldCreatedAt:
  5156. v, ok := value.(time.Time)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetCreatedAt(v)
  5161. return nil
  5162. case apikey.FieldUpdatedAt:
  5163. v, ok := value.(time.Time)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetUpdatedAt(v)
  5168. return nil
  5169. case apikey.FieldDeletedAt:
  5170. v, ok := value.(time.Time)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetDeletedAt(v)
  5175. return nil
  5176. case apikey.FieldTitle:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTitle(v)
  5182. return nil
  5183. case apikey.FieldKey:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetKey(v)
  5189. return nil
  5190. case apikey.FieldOrganizationID:
  5191. v, ok := value.(uint64)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetOrganizationID(v)
  5196. return nil
  5197. case apikey.FieldAgentID:
  5198. v, ok := value.(uint64)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetAgentID(v)
  5203. return nil
  5204. case apikey.FieldCustomAgentBase:
  5205. v, ok := value.(string)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetCustomAgentBase(v)
  5210. return nil
  5211. case apikey.FieldCustomAgentKey:
  5212. v, ok := value.(string)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetCustomAgentKey(v)
  5217. return nil
  5218. case apikey.FieldOpenaiBase:
  5219. v, ok := value.(string)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetOpenaiBase(v)
  5224. return nil
  5225. case apikey.FieldOpenaiKey:
  5226. v, ok := value.(string)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetOpenaiKey(v)
  5231. return nil
  5232. }
  5233. return fmt.Errorf("unknown ApiKey field %s", name)
  5234. }
  5235. // AddedFields returns all numeric fields that were incremented/decremented during
  5236. // this mutation.
  5237. func (m *ApiKeyMutation) AddedFields() []string {
  5238. var fields []string
  5239. if m.addorganization_id != nil {
  5240. fields = append(fields, apikey.FieldOrganizationID)
  5241. }
  5242. return fields
  5243. }
  5244. // AddedField returns the numeric value that was incremented/decremented on a field
  5245. // with the given name. The second boolean return value indicates that this field
  5246. // was not set, or was not defined in the schema.
  5247. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5248. switch name {
  5249. case apikey.FieldOrganizationID:
  5250. return m.AddedOrganizationID()
  5251. }
  5252. return nil, false
  5253. }
  5254. // AddField adds the value to the field with the given name. It returns an error if
  5255. // the field is not defined in the schema, or if the type mismatched the field
  5256. // type.
  5257. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5258. switch name {
  5259. case apikey.FieldOrganizationID:
  5260. v, ok := value.(int64)
  5261. if !ok {
  5262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5263. }
  5264. m.AddOrganizationID(v)
  5265. return nil
  5266. }
  5267. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5268. }
  5269. // ClearedFields returns all nullable fields that were cleared during this
  5270. // mutation.
  5271. func (m *ApiKeyMutation) ClearedFields() []string {
  5272. var fields []string
  5273. if m.FieldCleared(apikey.FieldDeletedAt) {
  5274. fields = append(fields, apikey.FieldDeletedAt)
  5275. }
  5276. if m.FieldCleared(apikey.FieldTitle) {
  5277. fields = append(fields, apikey.FieldTitle)
  5278. }
  5279. if m.FieldCleared(apikey.FieldKey) {
  5280. fields = append(fields, apikey.FieldKey)
  5281. }
  5282. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5283. fields = append(fields, apikey.FieldCustomAgentBase)
  5284. }
  5285. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5286. fields = append(fields, apikey.FieldCustomAgentKey)
  5287. }
  5288. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5289. fields = append(fields, apikey.FieldOpenaiBase)
  5290. }
  5291. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5292. fields = append(fields, apikey.FieldOpenaiKey)
  5293. }
  5294. return fields
  5295. }
  5296. // FieldCleared returns a boolean indicating if a field with the given name was
  5297. // cleared in this mutation.
  5298. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5299. _, ok := m.clearedFields[name]
  5300. return ok
  5301. }
  5302. // ClearField clears the value of the field with the given name. It returns an
  5303. // error if the field is not defined in the schema.
  5304. func (m *ApiKeyMutation) ClearField(name string) error {
  5305. switch name {
  5306. case apikey.FieldDeletedAt:
  5307. m.ClearDeletedAt()
  5308. return nil
  5309. case apikey.FieldTitle:
  5310. m.ClearTitle()
  5311. return nil
  5312. case apikey.FieldKey:
  5313. m.ClearKey()
  5314. return nil
  5315. case apikey.FieldCustomAgentBase:
  5316. m.ClearCustomAgentBase()
  5317. return nil
  5318. case apikey.FieldCustomAgentKey:
  5319. m.ClearCustomAgentKey()
  5320. return nil
  5321. case apikey.FieldOpenaiBase:
  5322. m.ClearOpenaiBase()
  5323. return nil
  5324. case apikey.FieldOpenaiKey:
  5325. m.ClearOpenaiKey()
  5326. return nil
  5327. }
  5328. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5329. }
  5330. // ResetField resets all changes in the mutation for the field with the given name.
  5331. // It returns an error if the field is not defined in the schema.
  5332. func (m *ApiKeyMutation) ResetField(name string) error {
  5333. switch name {
  5334. case apikey.FieldCreatedAt:
  5335. m.ResetCreatedAt()
  5336. return nil
  5337. case apikey.FieldUpdatedAt:
  5338. m.ResetUpdatedAt()
  5339. return nil
  5340. case apikey.FieldDeletedAt:
  5341. m.ResetDeletedAt()
  5342. return nil
  5343. case apikey.FieldTitle:
  5344. m.ResetTitle()
  5345. return nil
  5346. case apikey.FieldKey:
  5347. m.ResetKey()
  5348. return nil
  5349. case apikey.FieldOrganizationID:
  5350. m.ResetOrganizationID()
  5351. return nil
  5352. case apikey.FieldAgentID:
  5353. m.ResetAgentID()
  5354. return nil
  5355. case apikey.FieldCustomAgentBase:
  5356. m.ResetCustomAgentBase()
  5357. return nil
  5358. case apikey.FieldCustomAgentKey:
  5359. m.ResetCustomAgentKey()
  5360. return nil
  5361. case apikey.FieldOpenaiBase:
  5362. m.ResetOpenaiBase()
  5363. return nil
  5364. case apikey.FieldOpenaiKey:
  5365. m.ResetOpenaiKey()
  5366. return nil
  5367. }
  5368. return fmt.Errorf("unknown ApiKey field %s", name)
  5369. }
  5370. // AddedEdges returns all edge names that were set/added in this mutation.
  5371. func (m *ApiKeyMutation) AddedEdges() []string {
  5372. edges := make([]string, 0, 1)
  5373. if m.agent != nil {
  5374. edges = append(edges, apikey.EdgeAgent)
  5375. }
  5376. return edges
  5377. }
  5378. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5379. // name in this mutation.
  5380. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5381. switch name {
  5382. case apikey.EdgeAgent:
  5383. if id := m.agent; id != nil {
  5384. return []ent.Value{*id}
  5385. }
  5386. }
  5387. return nil
  5388. }
  5389. // RemovedEdges returns all edge names that were removed in this mutation.
  5390. func (m *ApiKeyMutation) RemovedEdges() []string {
  5391. edges := make([]string, 0, 1)
  5392. return edges
  5393. }
  5394. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5395. // the given name in this mutation.
  5396. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5397. return nil
  5398. }
  5399. // ClearedEdges returns all edge names that were cleared in this mutation.
  5400. func (m *ApiKeyMutation) ClearedEdges() []string {
  5401. edges := make([]string, 0, 1)
  5402. if m.clearedagent {
  5403. edges = append(edges, apikey.EdgeAgent)
  5404. }
  5405. return edges
  5406. }
  5407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5408. // was cleared in this mutation.
  5409. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5410. switch name {
  5411. case apikey.EdgeAgent:
  5412. return m.clearedagent
  5413. }
  5414. return false
  5415. }
  5416. // ClearEdge clears the value of the edge with the given name. It returns an error
  5417. // if that edge is not defined in the schema.
  5418. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5419. switch name {
  5420. case apikey.EdgeAgent:
  5421. m.ClearAgent()
  5422. return nil
  5423. }
  5424. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5425. }
  5426. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5427. // It returns an error if the edge is not defined in the schema.
  5428. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5429. switch name {
  5430. case apikey.EdgeAgent:
  5431. m.ResetAgent()
  5432. return nil
  5433. }
  5434. return fmt.Errorf("unknown ApiKey edge %s", name)
  5435. }
  5436. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5437. type BatchMsgMutation struct {
  5438. config
  5439. op Op
  5440. typ string
  5441. id *uint64
  5442. created_at *time.Time
  5443. updated_at *time.Time
  5444. deleted_at *time.Time
  5445. status *uint8
  5446. addstatus *int8
  5447. batch_no *string
  5448. task_name *string
  5449. fromwxid *string
  5450. msg *string
  5451. tag *string
  5452. tagids *string
  5453. total *int32
  5454. addtotal *int32
  5455. success *int32
  5456. addsuccess *int32
  5457. fail *int32
  5458. addfail *int32
  5459. start_time *time.Time
  5460. stop_time *time.Time
  5461. send_time *time.Time
  5462. _type *int32
  5463. add_type *int32
  5464. organization_id *uint64
  5465. addorganization_id *int64
  5466. ctype *uint64
  5467. addctype *int64
  5468. cc *string
  5469. phone *string
  5470. template_name *string
  5471. template_code *string
  5472. lang *string
  5473. clearedFields map[string]struct{}
  5474. done bool
  5475. oldValue func(context.Context) (*BatchMsg, error)
  5476. predicates []predicate.BatchMsg
  5477. }
  5478. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5479. // batchmsgOption allows management of the mutation configuration using functional options.
  5480. type batchmsgOption func(*BatchMsgMutation)
  5481. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5482. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5483. m := &BatchMsgMutation{
  5484. config: c,
  5485. op: op,
  5486. typ: TypeBatchMsg,
  5487. clearedFields: make(map[string]struct{}),
  5488. }
  5489. for _, opt := range opts {
  5490. opt(m)
  5491. }
  5492. return m
  5493. }
  5494. // withBatchMsgID sets the ID field of the mutation.
  5495. func withBatchMsgID(id uint64) batchmsgOption {
  5496. return func(m *BatchMsgMutation) {
  5497. var (
  5498. err error
  5499. once sync.Once
  5500. value *BatchMsg
  5501. )
  5502. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5503. once.Do(func() {
  5504. if m.done {
  5505. err = errors.New("querying old values post mutation is not allowed")
  5506. } else {
  5507. value, err = m.Client().BatchMsg.Get(ctx, id)
  5508. }
  5509. })
  5510. return value, err
  5511. }
  5512. m.id = &id
  5513. }
  5514. }
  5515. // withBatchMsg sets the old BatchMsg of the mutation.
  5516. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5517. return func(m *BatchMsgMutation) {
  5518. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5519. return node, nil
  5520. }
  5521. m.id = &node.ID
  5522. }
  5523. }
  5524. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5525. // executed in a transaction (ent.Tx), a transactional client is returned.
  5526. func (m BatchMsgMutation) Client() *Client {
  5527. client := &Client{config: m.config}
  5528. client.init()
  5529. return client
  5530. }
  5531. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5532. // it returns an error otherwise.
  5533. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5534. if _, ok := m.driver.(*txDriver); !ok {
  5535. return nil, errors.New("ent: mutation is not running in a transaction")
  5536. }
  5537. tx := &Tx{config: m.config}
  5538. tx.init()
  5539. return tx, nil
  5540. }
  5541. // SetID sets the value of the id field. Note that this
  5542. // operation is only accepted on creation of BatchMsg entities.
  5543. func (m *BatchMsgMutation) SetID(id uint64) {
  5544. m.id = &id
  5545. }
  5546. // ID returns the ID value in the mutation. Note that the ID is only available
  5547. // if it was provided to the builder or after it was returned from the database.
  5548. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5549. if m.id == nil {
  5550. return
  5551. }
  5552. return *m.id, true
  5553. }
  5554. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5555. // That means, if the mutation is applied within a transaction with an isolation level such
  5556. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5557. // or updated by the mutation.
  5558. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5559. switch {
  5560. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5561. id, exists := m.ID()
  5562. if exists {
  5563. return []uint64{id}, nil
  5564. }
  5565. fallthrough
  5566. case m.op.Is(OpUpdate | OpDelete):
  5567. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5568. default:
  5569. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5570. }
  5571. }
  5572. // SetCreatedAt sets the "created_at" field.
  5573. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5574. m.created_at = &t
  5575. }
  5576. // CreatedAt returns the value of the "created_at" field in the mutation.
  5577. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5578. v := m.created_at
  5579. if v == nil {
  5580. return
  5581. }
  5582. return *v, true
  5583. }
  5584. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5585. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5587. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5588. if !m.op.Is(OpUpdateOne) {
  5589. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5590. }
  5591. if m.id == nil || m.oldValue == nil {
  5592. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5593. }
  5594. oldValue, err := m.oldValue(ctx)
  5595. if err != nil {
  5596. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5597. }
  5598. return oldValue.CreatedAt, nil
  5599. }
  5600. // ResetCreatedAt resets all changes to the "created_at" field.
  5601. func (m *BatchMsgMutation) ResetCreatedAt() {
  5602. m.created_at = nil
  5603. }
  5604. // SetUpdatedAt sets the "updated_at" field.
  5605. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5606. m.updated_at = &t
  5607. }
  5608. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5609. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5610. v := m.updated_at
  5611. if v == nil {
  5612. return
  5613. }
  5614. return *v, true
  5615. }
  5616. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5617. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5619. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5620. if !m.op.Is(OpUpdateOne) {
  5621. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5622. }
  5623. if m.id == nil || m.oldValue == nil {
  5624. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5625. }
  5626. oldValue, err := m.oldValue(ctx)
  5627. if err != nil {
  5628. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5629. }
  5630. return oldValue.UpdatedAt, nil
  5631. }
  5632. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5633. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5634. m.updated_at = nil
  5635. }
  5636. // SetDeletedAt sets the "deleted_at" field.
  5637. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5638. m.deleted_at = &t
  5639. }
  5640. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5641. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5642. v := m.deleted_at
  5643. if v == nil {
  5644. return
  5645. }
  5646. return *v, true
  5647. }
  5648. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5649. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5651. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5652. if !m.op.Is(OpUpdateOne) {
  5653. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5654. }
  5655. if m.id == nil || m.oldValue == nil {
  5656. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5657. }
  5658. oldValue, err := m.oldValue(ctx)
  5659. if err != nil {
  5660. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5661. }
  5662. return oldValue.DeletedAt, nil
  5663. }
  5664. // ClearDeletedAt clears the value of the "deleted_at" field.
  5665. func (m *BatchMsgMutation) ClearDeletedAt() {
  5666. m.deleted_at = nil
  5667. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5668. }
  5669. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5670. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5671. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5672. return ok
  5673. }
  5674. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5675. func (m *BatchMsgMutation) ResetDeletedAt() {
  5676. m.deleted_at = nil
  5677. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5678. }
  5679. // SetStatus sets the "status" field.
  5680. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5681. m.status = &u
  5682. m.addstatus = nil
  5683. }
  5684. // Status returns the value of the "status" field in the mutation.
  5685. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5686. v := m.status
  5687. if v == nil {
  5688. return
  5689. }
  5690. return *v, true
  5691. }
  5692. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5693. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5695. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5696. if !m.op.Is(OpUpdateOne) {
  5697. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5698. }
  5699. if m.id == nil || m.oldValue == nil {
  5700. return v, errors.New("OldStatus requires an ID field in the mutation")
  5701. }
  5702. oldValue, err := m.oldValue(ctx)
  5703. if err != nil {
  5704. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5705. }
  5706. return oldValue.Status, nil
  5707. }
  5708. // AddStatus adds u to the "status" field.
  5709. func (m *BatchMsgMutation) AddStatus(u int8) {
  5710. if m.addstatus != nil {
  5711. *m.addstatus += u
  5712. } else {
  5713. m.addstatus = &u
  5714. }
  5715. }
  5716. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5717. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5718. v := m.addstatus
  5719. if v == nil {
  5720. return
  5721. }
  5722. return *v, true
  5723. }
  5724. // ClearStatus clears the value of the "status" field.
  5725. func (m *BatchMsgMutation) ClearStatus() {
  5726. m.status = nil
  5727. m.addstatus = nil
  5728. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5729. }
  5730. // StatusCleared returns if the "status" field was cleared in this mutation.
  5731. func (m *BatchMsgMutation) StatusCleared() bool {
  5732. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5733. return ok
  5734. }
  5735. // ResetStatus resets all changes to the "status" field.
  5736. func (m *BatchMsgMutation) ResetStatus() {
  5737. m.status = nil
  5738. m.addstatus = nil
  5739. delete(m.clearedFields, batchmsg.FieldStatus)
  5740. }
  5741. // SetBatchNo sets the "batch_no" field.
  5742. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5743. m.batch_no = &s
  5744. }
  5745. // BatchNo returns the value of the "batch_no" field in the mutation.
  5746. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5747. v := m.batch_no
  5748. if v == nil {
  5749. return
  5750. }
  5751. return *v, true
  5752. }
  5753. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5756. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5757. if !m.op.Is(OpUpdateOne) {
  5758. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5759. }
  5760. if m.id == nil || m.oldValue == nil {
  5761. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5762. }
  5763. oldValue, err := m.oldValue(ctx)
  5764. if err != nil {
  5765. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5766. }
  5767. return oldValue.BatchNo, nil
  5768. }
  5769. // ClearBatchNo clears the value of the "batch_no" field.
  5770. func (m *BatchMsgMutation) ClearBatchNo() {
  5771. m.batch_no = nil
  5772. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5773. }
  5774. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5775. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5776. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5777. return ok
  5778. }
  5779. // ResetBatchNo resets all changes to the "batch_no" field.
  5780. func (m *BatchMsgMutation) ResetBatchNo() {
  5781. m.batch_no = nil
  5782. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5783. }
  5784. // SetTaskName sets the "task_name" field.
  5785. func (m *BatchMsgMutation) SetTaskName(s string) {
  5786. m.task_name = &s
  5787. }
  5788. // TaskName returns the value of the "task_name" field in the mutation.
  5789. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5790. v := m.task_name
  5791. if v == nil {
  5792. return
  5793. }
  5794. return *v, true
  5795. }
  5796. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5797. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5799. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5800. if !m.op.Is(OpUpdateOne) {
  5801. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5802. }
  5803. if m.id == nil || m.oldValue == nil {
  5804. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5805. }
  5806. oldValue, err := m.oldValue(ctx)
  5807. if err != nil {
  5808. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5809. }
  5810. return oldValue.TaskName, nil
  5811. }
  5812. // ClearTaskName clears the value of the "task_name" field.
  5813. func (m *BatchMsgMutation) ClearTaskName() {
  5814. m.task_name = nil
  5815. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5816. }
  5817. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5818. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5819. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5820. return ok
  5821. }
  5822. // ResetTaskName resets all changes to the "task_name" field.
  5823. func (m *BatchMsgMutation) ResetTaskName() {
  5824. m.task_name = nil
  5825. delete(m.clearedFields, batchmsg.FieldTaskName)
  5826. }
  5827. // SetFromwxid sets the "fromwxid" field.
  5828. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5829. m.fromwxid = &s
  5830. }
  5831. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5832. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5833. v := m.fromwxid
  5834. if v == nil {
  5835. return
  5836. }
  5837. return *v, true
  5838. }
  5839. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5840. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5842. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5843. if !m.op.Is(OpUpdateOne) {
  5844. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5845. }
  5846. if m.id == nil || m.oldValue == nil {
  5847. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5848. }
  5849. oldValue, err := m.oldValue(ctx)
  5850. if err != nil {
  5851. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5852. }
  5853. return oldValue.Fromwxid, nil
  5854. }
  5855. // ClearFromwxid clears the value of the "fromwxid" field.
  5856. func (m *BatchMsgMutation) ClearFromwxid() {
  5857. m.fromwxid = nil
  5858. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5859. }
  5860. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5861. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5862. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5863. return ok
  5864. }
  5865. // ResetFromwxid resets all changes to the "fromwxid" field.
  5866. func (m *BatchMsgMutation) ResetFromwxid() {
  5867. m.fromwxid = nil
  5868. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5869. }
  5870. // SetMsg sets the "msg" field.
  5871. func (m *BatchMsgMutation) SetMsg(s string) {
  5872. m.msg = &s
  5873. }
  5874. // Msg returns the value of the "msg" field in the mutation.
  5875. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5876. v := m.msg
  5877. if v == nil {
  5878. return
  5879. }
  5880. return *v, true
  5881. }
  5882. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5883. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5885. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5886. if !m.op.Is(OpUpdateOne) {
  5887. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5888. }
  5889. if m.id == nil || m.oldValue == nil {
  5890. return v, errors.New("OldMsg requires an ID field in the mutation")
  5891. }
  5892. oldValue, err := m.oldValue(ctx)
  5893. if err != nil {
  5894. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5895. }
  5896. return oldValue.Msg, nil
  5897. }
  5898. // ClearMsg clears the value of the "msg" field.
  5899. func (m *BatchMsgMutation) ClearMsg() {
  5900. m.msg = nil
  5901. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5902. }
  5903. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5904. func (m *BatchMsgMutation) MsgCleared() bool {
  5905. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5906. return ok
  5907. }
  5908. // ResetMsg resets all changes to the "msg" field.
  5909. func (m *BatchMsgMutation) ResetMsg() {
  5910. m.msg = nil
  5911. delete(m.clearedFields, batchmsg.FieldMsg)
  5912. }
  5913. // SetTag sets the "tag" field.
  5914. func (m *BatchMsgMutation) SetTag(s string) {
  5915. m.tag = &s
  5916. }
  5917. // Tag returns the value of the "tag" field in the mutation.
  5918. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5919. v := m.tag
  5920. if v == nil {
  5921. return
  5922. }
  5923. return *v, true
  5924. }
  5925. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5926. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5928. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5929. if !m.op.Is(OpUpdateOne) {
  5930. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5931. }
  5932. if m.id == nil || m.oldValue == nil {
  5933. return v, errors.New("OldTag requires an ID field in the mutation")
  5934. }
  5935. oldValue, err := m.oldValue(ctx)
  5936. if err != nil {
  5937. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5938. }
  5939. return oldValue.Tag, nil
  5940. }
  5941. // ClearTag clears the value of the "tag" field.
  5942. func (m *BatchMsgMutation) ClearTag() {
  5943. m.tag = nil
  5944. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5945. }
  5946. // TagCleared returns if the "tag" field was cleared in this mutation.
  5947. func (m *BatchMsgMutation) TagCleared() bool {
  5948. _, ok := m.clearedFields[batchmsg.FieldTag]
  5949. return ok
  5950. }
  5951. // ResetTag resets all changes to the "tag" field.
  5952. func (m *BatchMsgMutation) ResetTag() {
  5953. m.tag = nil
  5954. delete(m.clearedFields, batchmsg.FieldTag)
  5955. }
  5956. // SetTagids sets the "tagids" field.
  5957. func (m *BatchMsgMutation) SetTagids(s string) {
  5958. m.tagids = &s
  5959. }
  5960. // Tagids returns the value of the "tagids" field in the mutation.
  5961. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5962. v := m.tagids
  5963. if v == nil {
  5964. return
  5965. }
  5966. return *v, true
  5967. }
  5968. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5969. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5971. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5972. if !m.op.Is(OpUpdateOne) {
  5973. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5974. }
  5975. if m.id == nil || m.oldValue == nil {
  5976. return v, errors.New("OldTagids requires an ID field in the mutation")
  5977. }
  5978. oldValue, err := m.oldValue(ctx)
  5979. if err != nil {
  5980. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5981. }
  5982. return oldValue.Tagids, nil
  5983. }
  5984. // ClearTagids clears the value of the "tagids" field.
  5985. func (m *BatchMsgMutation) ClearTagids() {
  5986. m.tagids = nil
  5987. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5988. }
  5989. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5990. func (m *BatchMsgMutation) TagidsCleared() bool {
  5991. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5992. return ok
  5993. }
  5994. // ResetTagids resets all changes to the "tagids" field.
  5995. func (m *BatchMsgMutation) ResetTagids() {
  5996. m.tagids = nil
  5997. delete(m.clearedFields, batchmsg.FieldTagids)
  5998. }
  5999. // SetTotal sets the "total" field.
  6000. func (m *BatchMsgMutation) SetTotal(i int32) {
  6001. m.total = &i
  6002. m.addtotal = nil
  6003. }
  6004. // Total returns the value of the "total" field in the mutation.
  6005. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6006. v := m.total
  6007. if v == nil {
  6008. return
  6009. }
  6010. return *v, true
  6011. }
  6012. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6013. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6015. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6016. if !m.op.Is(OpUpdateOne) {
  6017. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6018. }
  6019. if m.id == nil || m.oldValue == nil {
  6020. return v, errors.New("OldTotal requires an ID field in the mutation")
  6021. }
  6022. oldValue, err := m.oldValue(ctx)
  6023. if err != nil {
  6024. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6025. }
  6026. return oldValue.Total, nil
  6027. }
  6028. // AddTotal adds i to the "total" field.
  6029. func (m *BatchMsgMutation) AddTotal(i int32) {
  6030. if m.addtotal != nil {
  6031. *m.addtotal += i
  6032. } else {
  6033. m.addtotal = &i
  6034. }
  6035. }
  6036. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6037. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6038. v := m.addtotal
  6039. if v == nil {
  6040. return
  6041. }
  6042. return *v, true
  6043. }
  6044. // ClearTotal clears the value of the "total" field.
  6045. func (m *BatchMsgMutation) ClearTotal() {
  6046. m.total = nil
  6047. m.addtotal = nil
  6048. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6049. }
  6050. // TotalCleared returns if the "total" field was cleared in this mutation.
  6051. func (m *BatchMsgMutation) TotalCleared() bool {
  6052. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6053. return ok
  6054. }
  6055. // ResetTotal resets all changes to the "total" field.
  6056. func (m *BatchMsgMutation) ResetTotal() {
  6057. m.total = nil
  6058. m.addtotal = nil
  6059. delete(m.clearedFields, batchmsg.FieldTotal)
  6060. }
  6061. // SetSuccess sets the "success" field.
  6062. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6063. m.success = &i
  6064. m.addsuccess = nil
  6065. }
  6066. // Success returns the value of the "success" field in the mutation.
  6067. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6068. v := m.success
  6069. if v == nil {
  6070. return
  6071. }
  6072. return *v, true
  6073. }
  6074. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6075. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6077. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6078. if !m.op.Is(OpUpdateOne) {
  6079. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6080. }
  6081. if m.id == nil || m.oldValue == nil {
  6082. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6083. }
  6084. oldValue, err := m.oldValue(ctx)
  6085. if err != nil {
  6086. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6087. }
  6088. return oldValue.Success, nil
  6089. }
  6090. // AddSuccess adds i to the "success" field.
  6091. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6092. if m.addsuccess != nil {
  6093. *m.addsuccess += i
  6094. } else {
  6095. m.addsuccess = &i
  6096. }
  6097. }
  6098. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6099. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6100. v := m.addsuccess
  6101. if v == nil {
  6102. return
  6103. }
  6104. return *v, true
  6105. }
  6106. // ClearSuccess clears the value of the "success" field.
  6107. func (m *BatchMsgMutation) ClearSuccess() {
  6108. m.success = nil
  6109. m.addsuccess = nil
  6110. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6111. }
  6112. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6113. func (m *BatchMsgMutation) SuccessCleared() bool {
  6114. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6115. return ok
  6116. }
  6117. // ResetSuccess resets all changes to the "success" field.
  6118. func (m *BatchMsgMutation) ResetSuccess() {
  6119. m.success = nil
  6120. m.addsuccess = nil
  6121. delete(m.clearedFields, batchmsg.FieldSuccess)
  6122. }
  6123. // SetFail sets the "fail" field.
  6124. func (m *BatchMsgMutation) SetFail(i int32) {
  6125. m.fail = &i
  6126. m.addfail = nil
  6127. }
  6128. // Fail returns the value of the "fail" field in the mutation.
  6129. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6130. v := m.fail
  6131. if v == nil {
  6132. return
  6133. }
  6134. return *v, true
  6135. }
  6136. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6137. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6139. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6140. if !m.op.Is(OpUpdateOne) {
  6141. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6142. }
  6143. if m.id == nil || m.oldValue == nil {
  6144. return v, errors.New("OldFail requires an ID field in the mutation")
  6145. }
  6146. oldValue, err := m.oldValue(ctx)
  6147. if err != nil {
  6148. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6149. }
  6150. return oldValue.Fail, nil
  6151. }
  6152. // AddFail adds i to the "fail" field.
  6153. func (m *BatchMsgMutation) AddFail(i int32) {
  6154. if m.addfail != nil {
  6155. *m.addfail += i
  6156. } else {
  6157. m.addfail = &i
  6158. }
  6159. }
  6160. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6161. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6162. v := m.addfail
  6163. if v == nil {
  6164. return
  6165. }
  6166. return *v, true
  6167. }
  6168. // ClearFail clears the value of the "fail" field.
  6169. func (m *BatchMsgMutation) ClearFail() {
  6170. m.fail = nil
  6171. m.addfail = nil
  6172. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6173. }
  6174. // FailCleared returns if the "fail" field was cleared in this mutation.
  6175. func (m *BatchMsgMutation) FailCleared() bool {
  6176. _, ok := m.clearedFields[batchmsg.FieldFail]
  6177. return ok
  6178. }
  6179. // ResetFail resets all changes to the "fail" field.
  6180. func (m *BatchMsgMutation) ResetFail() {
  6181. m.fail = nil
  6182. m.addfail = nil
  6183. delete(m.clearedFields, batchmsg.FieldFail)
  6184. }
  6185. // SetStartTime sets the "start_time" field.
  6186. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6187. m.start_time = &t
  6188. }
  6189. // StartTime returns the value of the "start_time" field in the mutation.
  6190. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6191. v := m.start_time
  6192. if v == nil {
  6193. return
  6194. }
  6195. return *v, true
  6196. }
  6197. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6198. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6200. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6201. if !m.op.Is(OpUpdateOne) {
  6202. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6203. }
  6204. if m.id == nil || m.oldValue == nil {
  6205. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6206. }
  6207. oldValue, err := m.oldValue(ctx)
  6208. if err != nil {
  6209. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6210. }
  6211. return oldValue.StartTime, nil
  6212. }
  6213. // ClearStartTime clears the value of the "start_time" field.
  6214. func (m *BatchMsgMutation) ClearStartTime() {
  6215. m.start_time = nil
  6216. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6217. }
  6218. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6219. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6220. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6221. return ok
  6222. }
  6223. // ResetStartTime resets all changes to the "start_time" field.
  6224. func (m *BatchMsgMutation) ResetStartTime() {
  6225. m.start_time = nil
  6226. delete(m.clearedFields, batchmsg.FieldStartTime)
  6227. }
  6228. // SetStopTime sets the "stop_time" field.
  6229. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6230. m.stop_time = &t
  6231. }
  6232. // StopTime returns the value of the "stop_time" field in the mutation.
  6233. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6234. v := m.stop_time
  6235. if v == nil {
  6236. return
  6237. }
  6238. return *v, true
  6239. }
  6240. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6241. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6243. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6244. if !m.op.Is(OpUpdateOne) {
  6245. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6246. }
  6247. if m.id == nil || m.oldValue == nil {
  6248. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6249. }
  6250. oldValue, err := m.oldValue(ctx)
  6251. if err != nil {
  6252. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6253. }
  6254. return oldValue.StopTime, nil
  6255. }
  6256. // ClearStopTime clears the value of the "stop_time" field.
  6257. func (m *BatchMsgMutation) ClearStopTime() {
  6258. m.stop_time = nil
  6259. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6260. }
  6261. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6262. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6263. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6264. return ok
  6265. }
  6266. // ResetStopTime resets all changes to the "stop_time" field.
  6267. func (m *BatchMsgMutation) ResetStopTime() {
  6268. m.stop_time = nil
  6269. delete(m.clearedFields, batchmsg.FieldStopTime)
  6270. }
  6271. // SetSendTime sets the "send_time" field.
  6272. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6273. m.send_time = &t
  6274. }
  6275. // SendTime returns the value of the "send_time" field in the mutation.
  6276. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6277. v := m.send_time
  6278. if v == nil {
  6279. return
  6280. }
  6281. return *v, true
  6282. }
  6283. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6284. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6286. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6287. if !m.op.Is(OpUpdateOne) {
  6288. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6289. }
  6290. if m.id == nil || m.oldValue == nil {
  6291. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6292. }
  6293. oldValue, err := m.oldValue(ctx)
  6294. if err != nil {
  6295. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6296. }
  6297. return oldValue.SendTime, nil
  6298. }
  6299. // ClearSendTime clears the value of the "send_time" field.
  6300. func (m *BatchMsgMutation) ClearSendTime() {
  6301. m.send_time = nil
  6302. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6303. }
  6304. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6305. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6306. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6307. return ok
  6308. }
  6309. // ResetSendTime resets all changes to the "send_time" field.
  6310. func (m *BatchMsgMutation) ResetSendTime() {
  6311. m.send_time = nil
  6312. delete(m.clearedFields, batchmsg.FieldSendTime)
  6313. }
  6314. // SetType sets the "type" field.
  6315. func (m *BatchMsgMutation) SetType(i int32) {
  6316. m._type = &i
  6317. m.add_type = nil
  6318. }
  6319. // GetType returns the value of the "type" field in the mutation.
  6320. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6321. v := m._type
  6322. if v == nil {
  6323. return
  6324. }
  6325. return *v, true
  6326. }
  6327. // OldType returns the old "type" field's value of the BatchMsg entity.
  6328. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6330. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6331. if !m.op.Is(OpUpdateOne) {
  6332. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6333. }
  6334. if m.id == nil || m.oldValue == nil {
  6335. return v, errors.New("OldType requires an ID field in the mutation")
  6336. }
  6337. oldValue, err := m.oldValue(ctx)
  6338. if err != nil {
  6339. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6340. }
  6341. return oldValue.Type, nil
  6342. }
  6343. // AddType adds i to the "type" field.
  6344. func (m *BatchMsgMutation) AddType(i int32) {
  6345. if m.add_type != nil {
  6346. *m.add_type += i
  6347. } else {
  6348. m.add_type = &i
  6349. }
  6350. }
  6351. // AddedType returns the value that was added to the "type" field in this mutation.
  6352. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6353. v := m.add_type
  6354. if v == nil {
  6355. return
  6356. }
  6357. return *v, true
  6358. }
  6359. // ClearType clears the value of the "type" field.
  6360. func (m *BatchMsgMutation) ClearType() {
  6361. m._type = nil
  6362. m.add_type = nil
  6363. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6364. }
  6365. // TypeCleared returns if the "type" field was cleared in this mutation.
  6366. func (m *BatchMsgMutation) TypeCleared() bool {
  6367. _, ok := m.clearedFields[batchmsg.FieldType]
  6368. return ok
  6369. }
  6370. // ResetType resets all changes to the "type" field.
  6371. func (m *BatchMsgMutation) ResetType() {
  6372. m._type = nil
  6373. m.add_type = nil
  6374. delete(m.clearedFields, batchmsg.FieldType)
  6375. }
  6376. // SetOrganizationID sets the "organization_id" field.
  6377. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6378. m.organization_id = &u
  6379. m.addorganization_id = nil
  6380. }
  6381. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6382. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6383. v := m.organization_id
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6390. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6392. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6393. if !m.op.Is(OpUpdateOne) {
  6394. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6395. }
  6396. if m.id == nil || m.oldValue == nil {
  6397. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6398. }
  6399. oldValue, err := m.oldValue(ctx)
  6400. if err != nil {
  6401. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6402. }
  6403. return oldValue.OrganizationID, nil
  6404. }
  6405. // AddOrganizationID adds u to the "organization_id" field.
  6406. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6407. if m.addorganization_id != nil {
  6408. *m.addorganization_id += u
  6409. } else {
  6410. m.addorganization_id = &u
  6411. }
  6412. }
  6413. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6414. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6415. v := m.addorganization_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // ResetOrganizationID resets all changes to the "organization_id" field.
  6422. func (m *BatchMsgMutation) ResetOrganizationID() {
  6423. m.organization_id = nil
  6424. m.addorganization_id = nil
  6425. }
  6426. // SetCtype sets the "ctype" field.
  6427. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6428. m.ctype = &u
  6429. m.addctype = nil
  6430. }
  6431. // Ctype returns the value of the "ctype" field in the mutation.
  6432. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6433. v := m.ctype
  6434. if v == nil {
  6435. return
  6436. }
  6437. return *v, true
  6438. }
  6439. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6440. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6442. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6443. if !m.op.Is(OpUpdateOne) {
  6444. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6445. }
  6446. if m.id == nil || m.oldValue == nil {
  6447. return v, errors.New("OldCtype requires an ID field in the mutation")
  6448. }
  6449. oldValue, err := m.oldValue(ctx)
  6450. if err != nil {
  6451. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6452. }
  6453. return oldValue.Ctype, nil
  6454. }
  6455. // AddCtype adds u to the "ctype" field.
  6456. func (m *BatchMsgMutation) AddCtype(u int64) {
  6457. if m.addctype != nil {
  6458. *m.addctype += u
  6459. } else {
  6460. m.addctype = &u
  6461. }
  6462. }
  6463. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6464. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6465. v := m.addctype
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // ResetCtype resets all changes to the "ctype" field.
  6472. func (m *BatchMsgMutation) ResetCtype() {
  6473. m.ctype = nil
  6474. m.addctype = nil
  6475. }
  6476. // SetCc sets the "cc" field.
  6477. func (m *BatchMsgMutation) SetCc(s string) {
  6478. m.cc = &s
  6479. }
  6480. // Cc returns the value of the "cc" field in the mutation.
  6481. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6482. v := m.cc
  6483. if v == nil {
  6484. return
  6485. }
  6486. return *v, true
  6487. }
  6488. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6489. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6491. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6492. if !m.op.Is(OpUpdateOne) {
  6493. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6494. }
  6495. if m.id == nil || m.oldValue == nil {
  6496. return v, errors.New("OldCc requires an ID field in the mutation")
  6497. }
  6498. oldValue, err := m.oldValue(ctx)
  6499. if err != nil {
  6500. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6501. }
  6502. return oldValue.Cc, nil
  6503. }
  6504. // ClearCc clears the value of the "cc" field.
  6505. func (m *BatchMsgMutation) ClearCc() {
  6506. m.cc = nil
  6507. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6508. }
  6509. // CcCleared returns if the "cc" field was cleared in this mutation.
  6510. func (m *BatchMsgMutation) CcCleared() bool {
  6511. _, ok := m.clearedFields[batchmsg.FieldCc]
  6512. return ok
  6513. }
  6514. // ResetCc resets all changes to the "cc" field.
  6515. func (m *BatchMsgMutation) ResetCc() {
  6516. m.cc = nil
  6517. delete(m.clearedFields, batchmsg.FieldCc)
  6518. }
  6519. // SetPhone sets the "phone" field.
  6520. func (m *BatchMsgMutation) SetPhone(s string) {
  6521. m.phone = &s
  6522. }
  6523. // Phone returns the value of the "phone" field in the mutation.
  6524. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6525. v := m.phone
  6526. if v == nil {
  6527. return
  6528. }
  6529. return *v, true
  6530. }
  6531. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6532. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6534. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6535. if !m.op.Is(OpUpdateOne) {
  6536. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6537. }
  6538. if m.id == nil || m.oldValue == nil {
  6539. return v, errors.New("OldPhone requires an ID field in the mutation")
  6540. }
  6541. oldValue, err := m.oldValue(ctx)
  6542. if err != nil {
  6543. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6544. }
  6545. return oldValue.Phone, nil
  6546. }
  6547. // ClearPhone clears the value of the "phone" field.
  6548. func (m *BatchMsgMutation) ClearPhone() {
  6549. m.phone = nil
  6550. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6551. }
  6552. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6553. func (m *BatchMsgMutation) PhoneCleared() bool {
  6554. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6555. return ok
  6556. }
  6557. // ResetPhone resets all changes to the "phone" field.
  6558. func (m *BatchMsgMutation) ResetPhone() {
  6559. m.phone = nil
  6560. delete(m.clearedFields, batchmsg.FieldPhone)
  6561. }
  6562. // SetTemplateName sets the "template_name" field.
  6563. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6564. m.template_name = &s
  6565. }
  6566. // TemplateName returns the value of the "template_name" field in the mutation.
  6567. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6568. v := m.template_name
  6569. if v == nil {
  6570. return
  6571. }
  6572. return *v, true
  6573. }
  6574. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6575. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6577. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6578. if !m.op.Is(OpUpdateOne) {
  6579. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6580. }
  6581. if m.id == nil || m.oldValue == nil {
  6582. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6583. }
  6584. oldValue, err := m.oldValue(ctx)
  6585. if err != nil {
  6586. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6587. }
  6588. return oldValue.TemplateName, nil
  6589. }
  6590. // ClearTemplateName clears the value of the "template_name" field.
  6591. func (m *BatchMsgMutation) ClearTemplateName() {
  6592. m.template_name = nil
  6593. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6594. }
  6595. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6596. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6597. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6598. return ok
  6599. }
  6600. // ResetTemplateName resets all changes to the "template_name" field.
  6601. func (m *BatchMsgMutation) ResetTemplateName() {
  6602. m.template_name = nil
  6603. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6604. }
  6605. // SetTemplateCode sets the "template_code" field.
  6606. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6607. m.template_code = &s
  6608. }
  6609. // TemplateCode returns the value of the "template_code" field in the mutation.
  6610. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6611. v := m.template_code
  6612. if v == nil {
  6613. return
  6614. }
  6615. return *v, true
  6616. }
  6617. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6618. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6620. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6621. if !m.op.Is(OpUpdateOne) {
  6622. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6623. }
  6624. if m.id == nil || m.oldValue == nil {
  6625. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6626. }
  6627. oldValue, err := m.oldValue(ctx)
  6628. if err != nil {
  6629. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6630. }
  6631. return oldValue.TemplateCode, nil
  6632. }
  6633. // ClearTemplateCode clears the value of the "template_code" field.
  6634. func (m *BatchMsgMutation) ClearTemplateCode() {
  6635. m.template_code = nil
  6636. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6637. }
  6638. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6639. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6640. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6641. return ok
  6642. }
  6643. // ResetTemplateCode resets all changes to the "template_code" field.
  6644. func (m *BatchMsgMutation) ResetTemplateCode() {
  6645. m.template_code = nil
  6646. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6647. }
  6648. // SetLang sets the "lang" field.
  6649. func (m *BatchMsgMutation) SetLang(s string) {
  6650. m.lang = &s
  6651. }
  6652. // Lang returns the value of the "lang" field in the mutation.
  6653. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6654. v := m.lang
  6655. if v == nil {
  6656. return
  6657. }
  6658. return *v, true
  6659. }
  6660. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6661. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6663. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6664. if !m.op.Is(OpUpdateOne) {
  6665. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6666. }
  6667. if m.id == nil || m.oldValue == nil {
  6668. return v, errors.New("OldLang requires an ID field in the mutation")
  6669. }
  6670. oldValue, err := m.oldValue(ctx)
  6671. if err != nil {
  6672. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6673. }
  6674. return oldValue.Lang, nil
  6675. }
  6676. // ClearLang clears the value of the "lang" field.
  6677. func (m *BatchMsgMutation) ClearLang() {
  6678. m.lang = nil
  6679. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6680. }
  6681. // LangCleared returns if the "lang" field was cleared in this mutation.
  6682. func (m *BatchMsgMutation) LangCleared() bool {
  6683. _, ok := m.clearedFields[batchmsg.FieldLang]
  6684. return ok
  6685. }
  6686. // ResetLang resets all changes to the "lang" field.
  6687. func (m *BatchMsgMutation) ResetLang() {
  6688. m.lang = nil
  6689. delete(m.clearedFields, batchmsg.FieldLang)
  6690. }
  6691. // Where appends a list predicates to the BatchMsgMutation builder.
  6692. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6693. m.predicates = append(m.predicates, ps...)
  6694. }
  6695. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6696. // users can use type-assertion to append predicates that do not depend on any generated package.
  6697. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6698. p := make([]predicate.BatchMsg, len(ps))
  6699. for i := range ps {
  6700. p[i] = ps[i]
  6701. }
  6702. m.Where(p...)
  6703. }
  6704. // Op returns the operation name.
  6705. func (m *BatchMsgMutation) Op() Op {
  6706. return m.op
  6707. }
  6708. // SetOp allows setting the mutation operation.
  6709. func (m *BatchMsgMutation) SetOp(op Op) {
  6710. m.op = op
  6711. }
  6712. // Type returns the node type of this mutation (BatchMsg).
  6713. func (m *BatchMsgMutation) Type() string {
  6714. return m.typ
  6715. }
  6716. // Fields returns all fields that were changed during this mutation. Note that in
  6717. // order to get all numeric fields that were incremented/decremented, call
  6718. // AddedFields().
  6719. func (m *BatchMsgMutation) Fields() []string {
  6720. fields := make([]string, 0, 24)
  6721. if m.created_at != nil {
  6722. fields = append(fields, batchmsg.FieldCreatedAt)
  6723. }
  6724. if m.updated_at != nil {
  6725. fields = append(fields, batchmsg.FieldUpdatedAt)
  6726. }
  6727. if m.deleted_at != nil {
  6728. fields = append(fields, batchmsg.FieldDeletedAt)
  6729. }
  6730. if m.status != nil {
  6731. fields = append(fields, batchmsg.FieldStatus)
  6732. }
  6733. if m.batch_no != nil {
  6734. fields = append(fields, batchmsg.FieldBatchNo)
  6735. }
  6736. if m.task_name != nil {
  6737. fields = append(fields, batchmsg.FieldTaskName)
  6738. }
  6739. if m.fromwxid != nil {
  6740. fields = append(fields, batchmsg.FieldFromwxid)
  6741. }
  6742. if m.msg != nil {
  6743. fields = append(fields, batchmsg.FieldMsg)
  6744. }
  6745. if m.tag != nil {
  6746. fields = append(fields, batchmsg.FieldTag)
  6747. }
  6748. if m.tagids != nil {
  6749. fields = append(fields, batchmsg.FieldTagids)
  6750. }
  6751. if m.total != nil {
  6752. fields = append(fields, batchmsg.FieldTotal)
  6753. }
  6754. if m.success != nil {
  6755. fields = append(fields, batchmsg.FieldSuccess)
  6756. }
  6757. if m.fail != nil {
  6758. fields = append(fields, batchmsg.FieldFail)
  6759. }
  6760. if m.start_time != nil {
  6761. fields = append(fields, batchmsg.FieldStartTime)
  6762. }
  6763. if m.stop_time != nil {
  6764. fields = append(fields, batchmsg.FieldStopTime)
  6765. }
  6766. if m.send_time != nil {
  6767. fields = append(fields, batchmsg.FieldSendTime)
  6768. }
  6769. if m._type != nil {
  6770. fields = append(fields, batchmsg.FieldType)
  6771. }
  6772. if m.organization_id != nil {
  6773. fields = append(fields, batchmsg.FieldOrganizationID)
  6774. }
  6775. if m.ctype != nil {
  6776. fields = append(fields, batchmsg.FieldCtype)
  6777. }
  6778. if m.cc != nil {
  6779. fields = append(fields, batchmsg.FieldCc)
  6780. }
  6781. if m.phone != nil {
  6782. fields = append(fields, batchmsg.FieldPhone)
  6783. }
  6784. if m.template_name != nil {
  6785. fields = append(fields, batchmsg.FieldTemplateName)
  6786. }
  6787. if m.template_code != nil {
  6788. fields = append(fields, batchmsg.FieldTemplateCode)
  6789. }
  6790. if m.lang != nil {
  6791. fields = append(fields, batchmsg.FieldLang)
  6792. }
  6793. return fields
  6794. }
  6795. // Field returns the value of a field with the given name. The second boolean
  6796. // return value indicates that this field was not set, or was not defined in the
  6797. // schema.
  6798. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6799. switch name {
  6800. case batchmsg.FieldCreatedAt:
  6801. return m.CreatedAt()
  6802. case batchmsg.FieldUpdatedAt:
  6803. return m.UpdatedAt()
  6804. case batchmsg.FieldDeletedAt:
  6805. return m.DeletedAt()
  6806. case batchmsg.FieldStatus:
  6807. return m.Status()
  6808. case batchmsg.FieldBatchNo:
  6809. return m.BatchNo()
  6810. case batchmsg.FieldTaskName:
  6811. return m.TaskName()
  6812. case batchmsg.FieldFromwxid:
  6813. return m.Fromwxid()
  6814. case batchmsg.FieldMsg:
  6815. return m.Msg()
  6816. case batchmsg.FieldTag:
  6817. return m.Tag()
  6818. case batchmsg.FieldTagids:
  6819. return m.Tagids()
  6820. case batchmsg.FieldTotal:
  6821. return m.Total()
  6822. case batchmsg.FieldSuccess:
  6823. return m.Success()
  6824. case batchmsg.FieldFail:
  6825. return m.Fail()
  6826. case batchmsg.FieldStartTime:
  6827. return m.StartTime()
  6828. case batchmsg.FieldStopTime:
  6829. return m.StopTime()
  6830. case batchmsg.FieldSendTime:
  6831. return m.SendTime()
  6832. case batchmsg.FieldType:
  6833. return m.GetType()
  6834. case batchmsg.FieldOrganizationID:
  6835. return m.OrganizationID()
  6836. case batchmsg.FieldCtype:
  6837. return m.Ctype()
  6838. case batchmsg.FieldCc:
  6839. return m.Cc()
  6840. case batchmsg.FieldPhone:
  6841. return m.Phone()
  6842. case batchmsg.FieldTemplateName:
  6843. return m.TemplateName()
  6844. case batchmsg.FieldTemplateCode:
  6845. return m.TemplateCode()
  6846. case batchmsg.FieldLang:
  6847. return m.Lang()
  6848. }
  6849. return nil, false
  6850. }
  6851. // OldField returns the old value of the field from the database. An error is
  6852. // returned if the mutation operation is not UpdateOne, or the query to the
  6853. // database failed.
  6854. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6855. switch name {
  6856. case batchmsg.FieldCreatedAt:
  6857. return m.OldCreatedAt(ctx)
  6858. case batchmsg.FieldUpdatedAt:
  6859. return m.OldUpdatedAt(ctx)
  6860. case batchmsg.FieldDeletedAt:
  6861. return m.OldDeletedAt(ctx)
  6862. case batchmsg.FieldStatus:
  6863. return m.OldStatus(ctx)
  6864. case batchmsg.FieldBatchNo:
  6865. return m.OldBatchNo(ctx)
  6866. case batchmsg.FieldTaskName:
  6867. return m.OldTaskName(ctx)
  6868. case batchmsg.FieldFromwxid:
  6869. return m.OldFromwxid(ctx)
  6870. case batchmsg.FieldMsg:
  6871. return m.OldMsg(ctx)
  6872. case batchmsg.FieldTag:
  6873. return m.OldTag(ctx)
  6874. case batchmsg.FieldTagids:
  6875. return m.OldTagids(ctx)
  6876. case batchmsg.FieldTotal:
  6877. return m.OldTotal(ctx)
  6878. case batchmsg.FieldSuccess:
  6879. return m.OldSuccess(ctx)
  6880. case batchmsg.FieldFail:
  6881. return m.OldFail(ctx)
  6882. case batchmsg.FieldStartTime:
  6883. return m.OldStartTime(ctx)
  6884. case batchmsg.FieldStopTime:
  6885. return m.OldStopTime(ctx)
  6886. case batchmsg.FieldSendTime:
  6887. return m.OldSendTime(ctx)
  6888. case batchmsg.FieldType:
  6889. return m.OldType(ctx)
  6890. case batchmsg.FieldOrganizationID:
  6891. return m.OldOrganizationID(ctx)
  6892. case batchmsg.FieldCtype:
  6893. return m.OldCtype(ctx)
  6894. case batchmsg.FieldCc:
  6895. return m.OldCc(ctx)
  6896. case batchmsg.FieldPhone:
  6897. return m.OldPhone(ctx)
  6898. case batchmsg.FieldTemplateName:
  6899. return m.OldTemplateName(ctx)
  6900. case batchmsg.FieldTemplateCode:
  6901. return m.OldTemplateCode(ctx)
  6902. case batchmsg.FieldLang:
  6903. return m.OldLang(ctx)
  6904. }
  6905. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6906. }
  6907. // SetField sets the value of a field with the given name. It returns an error if
  6908. // the field is not defined in the schema, or if the type mismatched the field
  6909. // type.
  6910. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6911. switch name {
  6912. case batchmsg.FieldCreatedAt:
  6913. v, ok := value.(time.Time)
  6914. if !ok {
  6915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6916. }
  6917. m.SetCreatedAt(v)
  6918. return nil
  6919. case batchmsg.FieldUpdatedAt:
  6920. v, ok := value.(time.Time)
  6921. if !ok {
  6922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6923. }
  6924. m.SetUpdatedAt(v)
  6925. return nil
  6926. case batchmsg.FieldDeletedAt:
  6927. v, ok := value.(time.Time)
  6928. if !ok {
  6929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6930. }
  6931. m.SetDeletedAt(v)
  6932. return nil
  6933. case batchmsg.FieldStatus:
  6934. v, ok := value.(uint8)
  6935. if !ok {
  6936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6937. }
  6938. m.SetStatus(v)
  6939. return nil
  6940. case batchmsg.FieldBatchNo:
  6941. v, ok := value.(string)
  6942. if !ok {
  6943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6944. }
  6945. m.SetBatchNo(v)
  6946. return nil
  6947. case batchmsg.FieldTaskName:
  6948. v, ok := value.(string)
  6949. if !ok {
  6950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6951. }
  6952. m.SetTaskName(v)
  6953. return nil
  6954. case batchmsg.FieldFromwxid:
  6955. v, ok := value.(string)
  6956. if !ok {
  6957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6958. }
  6959. m.SetFromwxid(v)
  6960. return nil
  6961. case batchmsg.FieldMsg:
  6962. v, ok := value.(string)
  6963. if !ok {
  6964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6965. }
  6966. m.SetMsg(v)
  6967. return nil
  6968. case batchmsg.FieldTag:
  6969. v, ok := value.(string)
  6970. if !ok {
  6971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6972. }
  6973. m.SetTag(v)
  6974. return nil
  6975. case batchmsg.FieldTagids:
  6976. v, ok := value.(string)
  6977. if !ok {
  6978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6979. }
  6980. m.SetTagids(v)
  6981. return nil
  6982. case batchmsg.FieldTotal:
  6983. v, ok := value.(int32)
  6984. if !ok {
  6985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6986. }
  6987. m.SetTotal(v)
  6988. return nil
  6989. case batchmsg.FieldSuccess:
  6990. v, ok := value.(int32)
  6991. if !ok {
  6992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6993. }
  6994. m.SetSuccess(v)
  6995. return nil
  6996. case batchmsg.FieldFail:
  6997. v, ok := value.(int32)
  6998. if !ok {
  6999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7000. }
  7001. m.SetFail(v)
  7002. return nil
  7003. case batchmsg.FieldStartTime:
  7004. v, ok := value.(time.Time)
  7005. if !ok {
  7006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7007. }
  7008. m.SetStartTime(v)
  7009. return nil
  7010. case batchmsg.FieldStopTime:
  7011. v, ok := value.(time.Time)
  7012. if !ok {
  7013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7014. }
  7015. m.SetStopTime(v)
  7016. return nil
  7017. case batchmsg.FieldSendTime:
  7018. v, ok := value.(time.Time)
  7019. if !ok {
  7020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7021. }
  7022. m.SetSendTime(v)
  7023. return nil
  7024. case batchmsg.FieldType:
  7025. v, ok := value.(int32)
  7026. if !ok {
  7027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7028. }
  7029. m.SetType(v)
  7030. return nil
  7031. case batchmsg.FieldOrganizationID:
  7032. v, ok := value.(uint64)
  7033. if !ok {
  7034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7035. }
  7036. m.SetOrganizationID(v)
  7037. return nil
  7038. case batchmsg.FieldCtype:
  7039. v, ok := value.(uint64)
  7040. if !ok {
  7041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7042. }
  7043. m.SetCtype(v)
  7044. return nil
  7045. case batchmsg.FieldCc:
  7046. v, ok := value.(string)
  7047. if !ok {
  7048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7049. }
  7050. m.SetCc(v)
  7051. return nil
  7052. case batchmsg.FieldPhone:
  7053. v, ok := value.(string)
  7054. if !ok {
  7055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7056. }
  7057. m.SetPhone(v)
  7058. return nil
  7059. case batchmsg.FieldTemplateName:
  7060. v, ok := value.(string)
  7061. if !ok {
  7062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7063. }
  7064. m.SetTemplateName(v)
  7065. return nil
  7066. case batchmsg.FieldTemplateCode:
  7067. v, ok := value.(string)
  7068. if !ok {
  7069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7070. }
  7071. m.SetTemplateCode(v)
  7072. return nil
  7073. case batchmsg.FieldLang:
  7074. v, ok := value.(string)
  7075. if !ok {
  7076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7077. }
  7078. m.SetLang(v)
  7079. return nil
  7080. }
  7081. return fmt.Errorf("unknown BatchMsg field %s", name)
  7082. }
  7083. // AddedFields returns all numeric fields that were incremented/decremented during
  7084. // this mutation.
  7085. func (m *BatchMsgMutation) AddedFields() []string {
  7086. var fields []string
  7087. if m.addstatus != nil {
  7088. fields = append(fields, batchmsg.FieldStatus)
  7089. }
  7090. if m.addtotal != nil {
  7091. fields = append(fields, batchmsg.FieldTotal)
  7092. }
  7093. if m.addsuccess != nil {
  7094. fields = append(fields, batchmsg.FieldSuccess)
  7095. }
  7096. if m.addfail != nil {
  7097. fields = append(fields, batchmsg.FieldFail)
  7098. }
  7099. if m.add_type != nil {
  7100. fields = append(fields, batchmsg.FieldType)
  7101. }
  7102. if m.addorganization_id != nil {
  7103. fields = append(fields, batchmsg.FieldOrganizationID)
  7104. }
  7105. if m.addctype != nil {
  7106. fields = append(fields, batchmsg.FieldCtype)
  7107. }
  7108. return fields
  7109. }
  7110. // AddedField returns the numeric value that was incremented/decremented on a field
  7111. // with the given name. The second boolean return value indicates that this field
  7112. // was not set, or was not defined in the schema.
  7113. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7114. switch name {
  7115. case batchmsg.FieldStatus:
  7116. return m.AddedStatus()
  7117. case batchmsg.FieldTotal:
  7118. return m.AddedTotal()
  7119. case batchmsg.FieldSuccess:
  7120. return m.AddedSuccess()
  7121. case batchmsg.FieldFail:
  7122. return m.AddedFail()
  7123. case batchmsg.FieldType:
  7124. return m.AddedType()
  7125. case batchmsg.FieldOrganizationID:
  7126. return m.AddedOrganizationID()
  7127. case batchmsg.FieldCtype:
  7128. return m.AddedCtype()
  7129. }
  7130. return nil, false
  7131. }
  7132. // AddField adds the value to the field with the given name. It returns an error if
  7133. // the field is not defined in the schema, or if the type mismatched the field
  7134. // type.
  7135. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7136. switch name {
  7137. case batchmsg.FieldStatus:
  7138. v, ok := value.(int8)
  7139. if !ok {
  7140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7141. }
  7142. m.AddStatus(v)
  7143. return nil
  7144. case batchmsg.FieldTotal:
  7145. v, ok := value.(int32)
  7146. if !ok {
  7147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7148. }
  7149. m.AddTotal(v)
  7150. return nil
  7151. case batchmsg.FieldSuccess:
  7152. v, ok := value.(int32)
  7153. if !ok {
  7154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7155. }
  7156. m.AddSuccess(v)
  7157. return nil
  7158. case batchmsg.FieldFail:
  7159. v, ok := value.(int32)
  7160. if !ok {
  7161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7162. }
  7163. m.AddFail(v)
  7164. return nil
  7165. case batchmsg.FieldType:
  7166. v, ok := value.(int32)
  7167. if !ok {
  7168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7169. }
  7170. m.AddType(v)
  7171. return nil
  7172. case batchmsg.FieldOrganizationID:
  7173. v, ok := value.(int64)
  7174. if !ok {
  7175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7176. }
  7177. m.AddOrganizationID(v)
  7178. return nil
  7179. case batchmsg.FieldCtype:
  7180. v, ok := value.(int64)
  7181. if !ok {
  7182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7183. }
  7184. m.AddCtype(v)
  7185. return nil
  7186. }
  7187. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7188. }
  7189. // ClearedFields returns all nullable fields that were cleared during this
  7190. // mutation.
  7191. func (m *BatchMsgMutation) ClearedFields() []string {
  7192. var fields []string
  7193. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7194. fields = append(fields, batchmsg.FieldDeletedAt)
  7195. }
  7196. if m.FieldCleared(batchmsg.FieldStatus) {
  7197. fields = append(fields, batchmsg.FieldStatus)
  7198. }
  7199. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7200. fields = append(fields, batchmsg.FieldBatchNo)
  7201. }
  7202. if m.FieldCleared(batchmsg.FieldTaskName) {
  7203. fields = append(fields, batchmsg.FieldTaskName)
  7204. }
  7205. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7206. fields = append(fields, batchmsg.FieldFromwxid)
  7207. }
  7208. if m.FieldCleared(batchmsg.FieldMsg) {
  7209. fields = append(fields, batchmsg.FieldMsg)
  7210. }
  7211. if m.FieldCleared(batchmsg.FieldTag) {
  7212. fields = append(fields, batchmsg.FieldTag)
  7213. }
  7214. if m.FieldCleared(batchmsg.FieldTagids) {
  7215. fields = append(fields, batchmsg.FieldTagids)
  7216. }
  7217. if m.FieldCleared(batchmsg.FieldTotal) {
  7218. fields = append(fields, batchmsg.FieldTotal)
  7219. }
  7220. if m.FieldCleared(batchmsg.FieldSuccess) {
  7221. fields = append(fields, batchmsg.FieldSuccess)
  7222. }
  7223. if m.FieldCleared(batchmsg.FieldFail) {
  7224. fields = append(fields, batchmsg.FieldFail)
  7225. }
  7226. if m.FieldCleared(batchmsg.FieldStartTime) {
  7227. fields = append(fields, batchmsg.FieldStartTime)
  7228. }
  7229. if m.FieldCleared(batchmsg.FieldStopTime) {
  7230. fields = append(fields, batchmsg.FieldStopTime)
  7231. }
  7232. if m.FieldCleared(batchmsg.FieldSendTime) {
  7233. fields = append(fields, batchmsg.FieldSendTime)
  7234. }
  7235. if m.FieldCleared(batchmsg.FieldType) {
  7236. fields = append(fields, batchmsg.FieldType)
  7237. }
  7238. if m.FieldCleared(batchmsg.FieldCc) {
  7239. fields = append(fields, batchmsg.FieldCc)
  7240. }
  7241. if m.FieldCleared(batchmsg.FieldPhone) {
  7242. fields = append(fields, batchmsg.FieldPhone)
  7243. }
  7244. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7245. fields = append(fields, batchmsg.FieldTemplateName)
  7246. }
  7247. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7248. fields = append(fields, batchmsg.FieldTemplateCode)
  7249. }
  7250. if m.FieldCleared(batchmsg.FieldLang) {
  7251. fields = append(fields, batchmsg.FieldLang)
  7252. }
  7253. return fields
  7254. }
  7255. // FieldCleared returns a boolean indicating if a field with the given name was
  7256. // cleared in this mutation.
  7257. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7258. _, ok := m.clearedFields[name]
  7259. return ok
  7260. }
  7261. // ClearField clears the value of the field with the given name. It returns an
  7262. // error if the field is not defined in the schema.
  7263. func (m *BatchMsgMutation) ClearField(name string) error {
  7264. switch name {
  7265. case batchmsg.FieldDeletedAt:
  7266. m.ClearDeletedAt()
  7267. return nil
  7268. case batchmsg.FieldStatus:
  7269. m.ClearStatus()
  7270. return nil
  7271. case batchmsg.FieldBatchNo:
  7272. m.ClearBatchNo()
  7273. return nil
  7274. case batchmsg.FieldTaskName:
  7275. m.ClearTaskName()
  7276. return nil
  7277. case batchmsg.FieldFromwxid:
  7278. m.ClearFromwxid()
  7279. return nil
  7280. case batchmsg.FieldMsg:
  7281. m.ClearMsg()
  7282. return nil
  7283. case batchmsg.FieldTag:
  7284. m.ClearTag()
  7285. return nil
  7286. case batchmsg.FieldTagids:
  7287. m.ClearTagids()
  7288. return nil
  7289. case batchmsg.FieldTotal:
  7290. m.ClearTotal()
  7291. return nil
  7292. case batchmsg.FieldSuccess:
  7293. m.ClearSuccess()
  7294. return nil
  7295. case batchmsg.FieldFail:
  7296. m.ClearFail()
  7297. return nil
  7298. case batchmsg.FieldStartTime:
  7299. m.ClearStartTime()
  7300. return nil
  7301. case batchmsg.FieldStopTime:
  7302. m.ClearStopTime()
  7303. return nil
  7304. case batchmsg.FieldSendTime:
  7305. m.ClearSendTime()
  7306. return nil
  7307. case batchmsg.FieldType:
  7308. m.ClearType()
  7309. return nil
  7310. case batchmsg.FieldCc:
  7311. m.ClearCc()
  7312. return nil
  7313. case batchmsg.FieldPhone:
  7314. m.ClearPhone()
  7315. return nil
  7316. case batchmsg.FieldTemplateName:
  7317. m.ClearTemplateName()
  7318. return nil
  7319. case batchmsg.FieldTemplateCode:
  7320. m.ClearTemplateCode()
  7321. return nil
  7322. case batchmsg.FieldLang:
  7323. m.ClearLang()
  7324. return nil
  7325. }
  7326. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7327. }
  7328. // ResetField resets all changes in the mutation for the field with the given name.
  7329. // It returns an error if the field is not defined in the schema.
  7330. func (m *BatchMsgMutation) ResetField(name string) error {
  7331. switch name {
  7332. case batchmsg.FieldCreatedAt:
  7333. m.ResetCreatedAt()
  7334. return nil
  7335. case batchmsg.FieldUpdatedAt:
  7336. m.ResetUpdatedAt()
  7337. return nil
  7338. case batchmsg.FieldDeletedAt:
  7339. m.ResetDeletedAt()
  7340. return nil
  7341. case batchmsg.FieldStatus:
  7342. m.ResetStatus()
  7343. return nil
  7344. case batchmsg.FieldBatchNo:
  7345. m.ResetBatchNo()
  7346. return nil
  7347. case batchmsg.FieldTaskName:
  7348. m.ResetTaskName()
  7349. return nil
  7350. case batchmsg.FieldFromwxid:
  7351. m.ResetFromwxid()
  7352. return nil
  7353. case batchmsg.FieldMsg:
  7354. m.ResetMsg()
  7355. return nil
  7356. case batchmsg.FieldTag:
  7357. m.ResetTag()
  7358. return nil
  7359. case batchmsg.FieldTagids:
  7360. m.ResetTagids()
  7361. return nil
  7362. case batchmsg.FieldTotal:
  7363. m.ResetTotal()
  7364. return nil
  7365. case batchmsg.FieldSuccess:
  7366. m.ResetSuccess()
  7367. return nil
  7368. case batchmsg.FieldFail:
  7369. m.ResetFail()
  7370. return nil
  7371. case batchmsg.FieldStartTime:
  7372. m.ResetStartTime()
  7373. return nil
  7374. case batchmsg.FieldStopTime:
  7375. m.ResetStopTime()
  7376. return nil
  7377. case batchmsg.FieldSendTime:
  7378. m.ResetSendTime()
  7379. return nil
  7380. case batchmsg.FieldType:
  7381. m.ResetType()
  7382. return nil
  7383. case batchmsg.FieldOrganizationID:
  7384. m.ResetOrganizationID()
  7385. return nil
  7386. case batchmsg.FieldCtype:
  7387. m.ResetCtype()
  7388. return nil
  7389. case batchmsg.FieldCc:
  7390. m.ResetCc()
  7391. return nil
  7392. case batchmsg.FieldPhone:
  7393. m.ResetPhone()
  7394. return nil
  7395. case batchmsg.FieldTemplateName:
  7396. m.ResetTemplateName()
  7397. return nil
  7398. case batchmsg.FieldTemplateCode:
  7399. m.ResetTemplateCode()
  7400. return nil
  7401. case batchmsg.FieldLang:
  7402. m.ResetLang()
  7403. return nil
  7404. }
  7405. return fmt.Errorf("unknown BatchMsg field %s", name)
  7406. }
  7407. // AddedEdges returns all edge names that were set/added in this mutation.
  7408. func (m *BatchMsgMutation) AddedEdges() []string {
  7409. edges := make([]string, 0, 0)
  7410. return edges
  7411. }
  7412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7413. // name in this mutation.
  7414. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7415. return nil
  7416. }
  7417. // RemovedEdges returns all edge names that were removed in this mutation.
  7418. func (m *BatchMsgMutation) RemovedEdges() []string {
  7419. edges := make([]string, 0, 0)
  7420. return edges
  7421. }
  7422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7423. // the given name in this mutation.
  7424. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7425. return nil
  7426. }
  7427. // ClearedEdges returns all edge names that were cleared in this mutation.
  7428. func (m *BatchMsgMutation) ClearedEdges() []string {
  7429. edges := make([]string, 0, 0)
  7430. return edges
  7431. }
  7432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7433. // was cleared in this mutation.
  7434. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7435. return false
  7436. }
  7437. // ClearEdge clears the value of the edge with the given name. It returns an error
  7438. // if that edge is not defined in the schema.
  7439. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7440. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7441. }
  7442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7443. // It returns an error if the edge is not defined in the schema.
  7444. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7445. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7446. }
  7447. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7448. type CategoryMutation struct {
  7449. config
  7450. op Op
  7451. typ string
  7452. id *uint64
  7453. created_at *time.Time
  7454. updated_at *time.Time
  7455. deleted_at *time.Time
  7456. name *string
  7457. organization_id *uint64
  7458. addorganization_id *int64
  7459. clearedFields map[string]struct{}
  7460. done bool
  7461. oldValue func(context.Context) (*Category, error)
  7462. predicates []predicate.Category
  7463. }
  7464. var _ ent.Mutation = (*CategoryMutation)(nil)
  7465. // categoryOption allows management of the mutation configuration using functional options.
  7466. type categoryOption func(*CategoryMutation)
  7467. // newCategoryMutation creates new mutation for the Category entity.
  7468. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7469. m := &CategoryMutation{
  7470. config: c,
  7471. op: op,
  7472. typ: TypeCategory,
  7473. clearedFields: make(map[string]struct{}),
  7474. }
  7475. for _, opt := range opts {
  7476. opt(m)
  7477. }
  7478. return m
  7479. }
  7480. // withCategoryID sets the ID field of the mutation.
  7481. func withCategoryID(id uint64) categoryOption {
  7482. return func(m *CategoryMutation) {
  7483. var (
  7484. err error
  7485. once sync.Once
  7486. value *Category
  7487. )
  7488. m.oldValue = func(ctx context.Context) (*Category, error) {
  7489. once.Do(func() {
  7490. if m.done {
  7491. err = errors.New("querying old values post mutation is not allowed")
  7492. } else {
  7493. value, err = m.Client().Category.Get(ctx, id)
  7494. }
  7495. })
  7496. return value, err
  7497. }
  7498. m.id = &id
  7499. }
  7500. }
  7501. // withCategory sets the old Category of the mutation.
  7502. func withCategory(node *Category) categoryOption {
  7503. return func(m *CategoryMutation) {
  7504. m.oldValue = func(context.Context) (*Category, error) {
  7505. return node, nil
  7506. }
  7507. m.id = &node.ID
  7508. }
  7509. }
  7510. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7511. // executed in a transaction (ent.Tx), a transactional client is returned.
  7512. func (m CategoryMutation) Client() *Client {
  7513. client := &Client{config: m.config}
  7514. client.init()
  7515. return client
  7516. }
  7517. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7518. // it returns an error otherwise.
  7519. func (m CategoryMutation) Tx() (*Tx, error) {
  7520. if _, ok := m.driver.(*txDriver); !ok {
  7521. return nil, errors.New("ent: mutation is not running in a transaction")
  7522. }
  7523. tx := &Tx{config: m.config}
  7524. tx.init()
  7525. return tx, nil
  7526. }
  7527. // SetID sets the value of the id field. Note that this
  7528. // operation is only accepted on creation of Category entities.
  7529. func (m *CategoryMutation) SetID(id uint64) {
  7530. m.id = &id
  7531. }
  7532. // ID returns the ID value in the mutation. Note that the ID is only available
  7533. // if it was provided to the builder or after it was returned from the database.
  7534. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7535. if m.id == nil {
  7536. return
  7537. }
  7538. return *m.id, true
  7539. }
  7540. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7541. // That means, if the mutation is applied within a transaction with an isolation level such
  7542. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7543. // or updated by the mutation.
  7544. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7545. switch {
  7546. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7547. id, exists := m.ID()
  7548. if exists {
  7549. return []uint64{id}, nil
  7550. }
  7551. fallthrough
  7552. case m.op.Is(OpUpdate | OpDelete):
  7553. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7554. default:
  7555. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7556. }
  7557. }
  7558. // SetCreatedAt sets the "created_at" field.
  7559. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7560. m.created_at = &t
  7561. }
  7562. // CreatedAt returns the value of the "created_at" field in the mutation.
  7563. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7564. v := m.created_at
  7565. if v == nil {
  7566. return
  7567. }
  7568. return *v, true
  7569. }
  7570. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7571. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7573. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7574. if !m.op.Is(OpUpdateOne) {
  7575. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7576. }
  7577. if m.id == nil || m.oldValue == nil {
  7578. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7579. }
  7580. oldValue, err := m.oldValue(ctx)
  7581. if err != nil {
  7582. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7583. }
  7584. return oldValue.CreatedAt, nil
  7585. }
  7586. // ResetCreatedAt resets all changes to the "created_at" field.
  7587. func (m *CategoryMutation) ResetCreatedAt() {
  7588. m.created_at = nil
  7589. }
  7590. // SetUpdatedAt sets the "updated_at" field.
  7591. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7592. m.updated_at = &t
  7593. }
  7594. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7595. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7596. v := m.updated_at
  7597. if v == nil {
  7598. return
  7599. }
  7600. return *v, true
  7601. }
  7602. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7603. // If the Category 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 *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7606. if !m.op.Is(OpUpdateOne) {
  7607. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7608. }
  7609. if m.id == nil || m.oldValue == nil {
  7610. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  7615. }
  7616. return oldValue.UpdatedAt, nil
  7617. }
  7618. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7619. func (m *CategoryMutation) ResetUpdatedAt() {
  7620. m.updated_at = nil
  7621. }
  7622. // SetDeletedAt sets the "deleted_at" field.
  7623. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7624. m.deleted_at = &t
  7625. }
  7626. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7627. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7628. v := m.deleted_at
  7629. if v == nil {
  7630. return
  7631. }
  7632. return *v, true
  7633. }
  7634. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7635. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7637. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7638. if !m.op.Is(OpUpdateOne) {
  7639. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7640. }
  7641. if m.id == nil || m.oldValue == nil {
  7642. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7643. }
  7644. oldValue, err := m.oldValue(ctx)
  7645. if err != nil {
  7646. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7647. }
  7648. return oldValue.DeletedAt, nil
  7649. }
  7650. // ClearDeletedAt clears the value of the "deleted_at" field.
  7651. func (m *CategoryMutation) ClearDeletedAt() {
  7652. m.deleted_at = nil
  7653. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7654. }
  7655. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7656. func (m *CategoryMutation) DeletedAtCleared() bool {
  7657. _, ok := m.clearedFields[category.FieldDeletedAt]
  7658. return ok
  7659. }
  7660. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7661. func (m *CategoryMutation) ResetDeletedAt() {
  7662. m.deleted_at = nil
  7663. delete(m.clearedFields, category.FieldDeletedAt)
  7664. }
  7665. // SetName sets the "name" field.
  7666. func (m *CategoryMutation) SetName(s string) {
  7667. m.name = &s
  7668. }
  7669. // Name returns the value of the "name" field in the mutation.
  7670. func (m *CategoryMutation) Name() (r string, exists bool) {
  7671. v := m.name
  7672. if v == nil {
  7673. return
  7674. }
  7675. return *v, true
  7676. }
  7677. // OldName returns the old "name" field's value of the Category entity.
  7678. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7680. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7681. if !m.op.Is(OpUpdateOne) {
  7682. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7683. }
  7684. if m.id == nil || m.oldValue == nil {
  7685. return v, errors.New("OldName requires an ID field in the mutation")
  7686. }
  7687. oldValue, err := m.oldValue(ctx)
  7688. if err != nil {
  7689. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7690. }
  7691. return oldValue.Name, nil
  7692. }
  7693. // ResetName resets all changes to the "name" field.
  7694. func (m *CategoryMutation) ResetName() {
  7695. m.name = nil
  7696. }
  7697. // SetOrganizationID sets the "organization_id" field.
  7698. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7699. m.organization_id = &u
  7700. m.addorganization_id = nil
  7701. }
  7702. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7703. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7704. v := m.organization_id
  7705. if v == nil {
  7706. return
  7707. }
  7708. return *v, true
  7709. }
  7710. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7711. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7713. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7714. if !m.op.Is(OpUpdateOne) {
  7715. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7716. }
  7717. if m.id == nil || m.oldValue == nil {
  7718. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7719. }
  7720. oldValue, err := m.oldValue(ctx)
  7721. if err != nil {
  7722. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7723. }
  7724. return oldValue.OrganizationID, nil
  7725. }
  7726. // AddOrganizationID adds u to the "organization_id" field.
  7727. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7728. if m.addorganization_id != nil {
  7729. *m.addorganization_id += u
  7730. } else {
  7731. m.addorganization_id = &u
  7732. }
  7733. }
  7734. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7735. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7736. v := m.addorganization_id
  7737. if v == nil {
  7738. return
  7739. }
  7740. return *v, true
  7741. }
  7742. // ResetOrganizationID resets all changes to the "organization_id" field.
  7743. func (m *CategoryMutation) ResetOrganizationID() {
  7744. m.organization_id = nil
  7745. m.addorganization_id = nil
  7746. }
  7747. // Where appends a list predicates to the CategoryMutation builder.
  7748. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7749. m.predicates = append(m.predicates, ps...)
  7750. }
  7751. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7752. // users can use type-assertion to append predicates that do not depend on any generated package.
  7753. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7754. p := make([]predicate.Category, len(ps))
  7755. for i := range ps {
  7756. p[i] = ps[i]
  7757. }
  7758. m.Where(p...)
  7759. }
  7760. // Op returns the operation name.
  7761. func (m *CategoryMutation) Op() Op {
  7762. return m.op
  7763. }
  7764. // SetOp allows setting the mutation operation.
  7765. func (m *CategoryMutation) SetOp(op Op) {
  7766. m.op = op
  7767. }
  7768. // Type returns the node type of this mutation (Category).
  7769. func (m *CategoryMutation) Type() string {
  7770. return m.typ
  7771. }
  7772. // Fields returns all fields that were changed during this mutation. Note that in
  7773. // order to get all numeric fields that were incremented/decremented, call
  7774. // AddedFields().
  7775. func (m *CategoryMutation) Fields() []string {
  7776. fields := make([]string, 0, 5)
  7777. if m.created_at != nil {
  7778. fields = append(fields, category.FieldCreatedAt)
  7779. }
  7780. if m.updated_at != nil {
  7781. fields = append(fields, category.FieldUpdatedAt)
  7782. }
  7783. if m.deleted_at != nil {
  7784. fields = append(fields, category.FieldDeletedAt)
  7785. }
  7786. if m.name != nil {
  7787. fields = append(fields, category.FieldName)
  7788. }
  7789. if m.organization_id != nil {
  7790. fields = append(fields, category.FieldOrganizationID)
  7791. }
  7792. return fields
  7793. }
  7794. // Field returns the value of a field with the given name. The second boolean
  7795. // return value indicates that this field was not set, or was not defined in the
  7796. // schema.
  7797. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7798. switch name {
  7799. case category.FieldCreatedAt:
  7800. return m.CreatedAt()
  7801. case category.FieldUpdatedAt:
  7802. return m.UpdatedAt()
  7803. case category.FieldDeletedAt:
  7804. return m.DeletedAt()
  7805. case category.FieldName:
  7806. return m.Name()
  7807. case category.FieldOrganizationID:
  7808. return m.OrganizationID()
  7809. }
  7810. return nil, false
  7811. }
  7812. // OldField returns the old value of the field from the database. An error is
  7813. // returned if the mutation operation is not UpdateOne, or the query to the
  7814. // database failed.
  7815. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7816. switch name {
  7817. case category.FieldCreatedAt:
  7818. return m.OldCreatedAt(ctx)
  7819. case category.FieldUpdatedAt:
  7820. return m.OldUpdatedAt(ctx)
  7821. case category.FieldDeletedAt:
  7822. return m.OldDeletedAt(ctx)
  7823. case category.FieldName:
  7824. return m.OldName(ctx)
  7825. case category.FieldOrganizationID:
  7826. return m.OldOrganizationID(ctx)
  7827. }
  7828. return nil, fmt.Errorf("unknown Category field %s", name)
  7829. }
  7830. // SetField sets the value of a field with the given name. It returns an error if
  7831. // the field is not defined in the schema, or if the type mismatched the field
  7832. // type.
  7833. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7834. switch name {
  7835. case category.FieldCreatedAt:
  7836. v, ok := value.(time.Time)
  7837. if !ok {
  7838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7839. }
  7840. m.SetCreatedAt(v)
  7841. return nil
  7842. case category.FieldUpdatedAt:
  7843. v, ok := value.(time.Time)
  7844. if !ok {
  7845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7846. }
  7847. m.SetUpdatedAt(v)
  7848. return nil
  7849. case category.FieldDeletedAt:
  7850. v, ok := value.(time.Time)
  7851. if !ok {
  7852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7853. }
  7854. m.SetDeletedAt(v)
  7855. return nil
  7856. case category.FieldName:
  7857. v, ok := value.(string)
  7858. if !ok {
  7859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7860. }
  7861. m.SetName(v)
  7862. return nil
  7863. case category.FieldOrganizationID:
  7864. v, ok := value.(uint64)
  7865. if !ok {
  7866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7867. }
  7868. m.SetOrganizationID(v)
  7869. return nil
  7870. }
  7871. return fmt.Errorf("unknown Category field %s", name)
  7872. }
  7873. // AddedFields returns all numeric fields that were incremented/decremented during
  7874. // this mutation.
  7875. func (m *CategoryMutation) AddedFields() []string {
  7876. var fields []string
  7877. if m.addorganization_id != nil {
  7878. fields = append(fields, category.FieldOrganizationID)
  7879. }
  7880. return fields
  7881. }
  7882. // AddedField returns the numeric value that was incremented/decremented on a field
  7883. // with the given name. The second boolean return value indicates that this field
  7884. // was not set, or was not defined in the schema.
  7885. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7886. switch name {
  7887. case category.FieldOrganizationID:
  7888. return m.AddedOrganizationID()
  7889. }
  7890. return nil, false
  7891. }
  7892. // AddField adds the value to the field with the given name. It returns an error if
  7893. // the field is not defined in the schema, or if the type mismatched the field
  7894. // type.
  7895. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7896. switch name {
  7897. case category.FieldOrganizationID:
  7898. v, ok := value.(int64)
  7899. if !ok {
  7900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7901. }
  7902. m.AddOrganizationID(v)
  7903. return nil
  7904. }
  7905. return fmt.Errorf("unknown Category numeric field %s", name)
  7906. }
  7907. // ClearedFields returns all nullable fields that were cleared during this
  7908. // mutation.
  7909. func (m *CategoryMutation) ClearedFields() []string {
  7910. var fields []string
  7911. if m.FieldCleared(category.FieldDeletedAt) {
  7912. fields = append(fields, category.FieldDeletedAt)
  7913. }
  7914. return fields
  7915. }
  7916. // FieldCleared returns a boolean indicating if a field with the given name was
  7917. // cleared in this mutation.
  7918. func (m *CategoryMutation) FieldCleared(name string) bool {
  7919. _, ok := m.clearedFields[name]
  7920. return ok
  7921. }
  7922. // ClearField clears the value of the field with the given name. It returns an
  7923. // error if the field is not defined in the schema.
  7924. func (m *CategoryMutation) ClearField(name string) error {
  7925. switch name {
  7926. case category.FieldDeletedAt:
  7927. m.ClearDeletedAt()
  7928. return nil
  7929. }
  7930. return fmt.Errorf("unknown Category nullable field %s", name)
  7931. }
  7932. // ResetField resets all changes in the mutation for the field with the given name.
  7933. // It returns an error if the field is not defined in the schema.
  7934. func (m *CategoryMutation) ResetField(name string) error {
  7935. switch name {
  7936. case category.FieldCreatedAt:
  7937. m.ResetCreatedAt()
  7938. return nil
  7939. case category.FieldUpdatedAt:
  7940. m.ResetUpdatedAt()
  7941. return nil
  7942. case category.FieldDeletedAt:
  7943. m.ResetDeletedAt()
  7944. return nil
  7945. case category.FieldName:
  7946. m.ResetName()
  7947. return nil
  7948. case category.FieldOrganizationID:
  7949. m.ResetOrganizationID()
  7950. return nil
  7951. }
  7952. return fmt.Errorf("unknown Category field %s", name)
  7953. }
  7954. // AddedEdges returns all edge names that were set/added in this mutation.
  7955. func (m *CategoryMutation) AddedEdges() []string {
  7956. edges := make([]string, 0, 0)
  7957. return edges
  7958. }
  7959. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7960. // name in this mutation.
  7961. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7962. return nil
  7963. }
  7964. // RemovedEdges returns all edge names that were removed in this mutation.
  7965. func (m *CategoryMutation) RemovedEdges() []string {
  7966. edges := make([]string, 0, 0)
  7967. return edges
  7968. }
  7969. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7970. // the given name in this mutation.
  7971. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7972. return nil
  7973. }
  7974. // ClearedEdges returns all edge names that were cleared in this mutation.
  7975. func (m *CategoryMutation) ClearedEdges() []string {
  7976. edges := make([]string, 0, 0)
  7977. return edges
  7978. }
  7979. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7980. // was cleared in this mutation.
  7981. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7982. return false
  7983. }
  7984. // ClearEdge clears the value of the edge with the given name. It returns an error
  7985. // if that edge is not defined in the schema.
  7986. func (m *CategoryMutation) ClearEdge(name string) error {
  7987. return fmt.Errorf("unknown Category unique edge %s", name)
  7988. }
  7989. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7990. // It returns an error if the edge is not defined in the schema.
  7991. func (m *CategoryMutation) ResetEdge(name string) error {
  7992. return fmt.Errorf("unknown Category edge %s", name)
  7993. }
  7994. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7995. type ChatRecordsMutation struct {
  7996. config
  7997. op Op
  7998. typ string
  7999. id *uint64
  8000. created_at *time.Time
  8001. updated_at *time.Time
  8002. deleted_at *time.Time
  8003. content *string
  8004. content_type *uint8
  8005. addcontent_type *int8
  8006. session_id *uint64
  8007. addsession_id *int64
  8008. user_id *uint64
  8009. adduser_id *int64
  8010. bot_id *uint64
  8011. addbot_id *int64
  8012. bot_type *uint8
  8013. addbot_type *int8
  8014. clearedFields map[string]struct{}
  8015. done bool
  8016. oldValue func(context.Context) (*ChatRecords, error)
  8017. predicates []predicate.ChatRecords
  8018. }
  8019. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8020. // chatrecordsOption allows management of the mutation configuration using functional options.
  8021. type chatrecordsOption func(*ChatRecordsMutation)
  8022. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8023. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8024. m := &ChatRecordsMutation{
  8025. config: c,
  8026. op: op,
  8027. typ: TypeChatRecords,
  8028. clearedFields: make(map[string]struct{}),
  8029. }
  8030. for _, opt := range opts {
  8031. opt(m)
  8032. }
  8033. return m
  8034. }
  8035. // withChatRecordsID sets the ID field of the mutation.
  8036. func withChatRecordsID(id uint64) chatrecordsOption {
  8037. return func(m *ChatRecordsMutation) {
  8038. var (
  8039. err error
  8040. once sync.Once
  8041. value *ChatRecords
  8042. )
  8043. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8044. once.Do(func() {
  8045. if m.done {
  8046. err = errors.New("querying old values post mutation is not allowed")
  8047. } else {
  8048. value, err = m.Client().ChatRecords.Get(ctx, id)
  8049. }
  8050. })
  8051. return value, err
  8052. }
  8053. m.id = &id
  8054. }
  8055. }
  8056. // withChatRecords sets the old ChatRecords of the mutation.
  8057. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8058. return func(m *ChatRecordsMutation) {
  8059. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8060. return node, nil
  8061. }
  8062. m.id = &node.ID
  8063. }
  8064. }
  8065. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8066. // executed in a transaction (ent.Tx), a transactional client is returned.
  8067. func (m ChatRecordsMutation) Client() *Client {
  8068. client := &Client{config: m.config}
  8069. client.init()
  8070. return client
  8071. }
  8072. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8073. // it returns an error otherwise.
  8074. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8075. if _, ok := m.driver.(*txDriver); !ok {
  8076. return nil, errors.New("ent: mutation is not running in a transaction")
  8077. }
  8078. tx := &Tx{config: m.config}
  8079. tx.init()
  8080. return tx, nil
  8081. }
  8082. // SetID sets the value of the id field. Note that this
  8083. // operation is only accepted on creation of ChatRecords entities.
  8084. func (m *ChatRecordsMutation) SetID(id uint64) {
  8085. m.id = &id
  8086. }
  8087. // ID returns the ID value in the mutation. Note that the ID is only available
  8088. // if it was provided to the builder or after it was returned from the database.
  8089. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8090. if m.id == nil {
  8091. return
  8092. }
  8093. return *m.id, true
  8094. }
  8095. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8096. // That means, if the mutation is applied within a transaction with an isolation level such
  8097. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8098. // or updated by the mutation.
  8099. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8100. switch {
  8101. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8102. id, exists := m.ID()
  8103. if exists {
  8104. return []uint64{id}, nil
  8105. }
  8106. fallthrough
  8107. case m.op.Is(OpUpdate | OpDelete):
  8108. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8109. default:
  8110. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8111. }
  8112. }
  8113. // SetCreatedAt sets the "created_at" field.
  8114. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8115. m.created_at = &t
  8116. }
  8117. // CreatedAt returns the value of the "created_at" field in the mutation.
  8118. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8119. v := m.created_at
  8120. if v == nil {
  8121. return
  8122. }
  8123. return *v, true
  8124. }
  8125. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8126. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8128. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8129. if !m.op.Is(OpUpdateOne) {
  8130. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8131. }
  8132. if m.id == nil || m.oldValue == nil {
  8133. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8134. }
  8135. oldValue, err := m.oldValue(ctx)
  8136. if err != nil {
  8137. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8138. }
  8139. return oldValue.CreatedAt, nil
  8140. }
  8141. // ResetCreatedAt resets all changes to the "created_at" field.
  8142. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8143. m.created_at = nil
  8144. }
  8145. // SetUpdatedAt sets the "updated_at" field.
  8146. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8147. m.updated_at = &t
  8148. }
  8149. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8150. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8151. v := m.updated_at
  8152. if v == nil {
  8153. return
  8154. }
  8155. return *v, true
  8156. }
  8157. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8158. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8160. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8161. if !m.op.Is(OpUpdateOne) {
  8162. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8163. }
  8164. if m.id == nil || m.oldValue == nil {
  8165. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8166. }
  8167. oldValue, err := m.oldValue(ctx)
  8168. if err != nil {
  8169. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8170. }
  8171. return oldValue.UpdatedAt, nil
  8172. }
  8173. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8174. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8175. m.updated_at = nil
  8176. }
  8177. // SetDeletedAt sets the "deleted_at" field.
  8178. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8179. m.deleted_at = &t
  8180. }
  8181. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8182. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8183. v := m.deleted_at
  8184. if v == nil {
  8185. return
  8186. }
  8187. return *v, true
  8188. }
  8189. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8190. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8192. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8193. if !m.op.Is(OpUpdateOne) {
  8194. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8195. }
  8196. if m.id == nil || m.oldValue == nil {
  8197. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8198. }
  8199. oldValue, err := m.oldValue(ctx)
  8200. if err != nil {
  8201. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8202. }
  8203. return oldValue.DeletedAt, nil
  8204. }
  8205. // ClearDeletedAt clears the value of the "deleted_at" field.
  8206. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8207. m.deleted_at = nil
  8208. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8209. }
  8210. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8211. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8212. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8213. return ok
  8214. }
  8215. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8216. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8217. m.deleted_at = nil
  8218. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8219. }
  8220. // SetContent sets the "content" field.
  8221. func (m *ChatRecordsMutation) SetContent(s string) {
  8222. m.content = &s
  8223. }
  8224. // Content returns the value of the "content" field in the mutation.
  8225. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8226. v := m.content
  8227. if v == nil {
  8228. return
  8229. }
  8230. return *v, true
  8231. }
  8232. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8233. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8235. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8236. if !m.op.Is(OpUpdateOne) {
  8237. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8238. }
  8239. if m.id == nil || m.oldValue == nil {
  8240. return v, errors.New("OldContent requires an ID field in the mutation")
  8241. }
  8242. oldValue, err := m.oldValue(ctx)
  8243. if err != nil {
  8244. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8245. }
  8246. return oldValue.Content, nil
  8247. }
  8248. // ResetContent resets all changes to the "content" field.
  8249. func (m *ChatRecordsMutation) ResetContent() {
  8250. m.content = nil
  8251. }
  8252. // SetContentType sets the "content_type" field.
  8253. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8254. m.content_type = &u
  8255. m.addcontent_type = nil
  8256. }
  8257. // ContentType returns the value of the "content_type" field in the mutation.
  8258. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8259. v := m.content_type
  8260. if v == nil {
  8261. return
  8262. }
  8263. return *v, true
  8264. }
  8265. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8266. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8268. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8269. if !m.op.Is(OpUpdateOne) {
  8270. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8271. }
  8272. if m.id == nil || m.oldValue == nil {
  8273. return v, errors.New("OldContentType requires an ID field in the mutation")
  8274. }
  8275. oldValue, err := m.oldValue(ctx)
  8276. if err != nil {
  8277. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8278. }
  8279. return oldValue.ContentType, nil
  8280. }
  8281. // AddContentType adds u to the "content_type" field.
  8282. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8283. if m.addcontent_type != nil {
  8284. *m.addcontent_type += u
  8285. } else {
  8286. m.addcontent_type = &u
  8287. }
  8288. }
  8289. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8290. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8291. v := m.addcontent_type
  8292. if v == nil {
  8293. return
  8294. }
  8295. return *v, true
  8296. }
  8297. // ResetContentType resets all changes to the "content_type" field.
  8298. func (m *ChatRecordsMutation) ResetContentType() {
  8299. m.content_type = nil
  8300. m.addcontent_type = nil
  8301. }
  8302. // SetSessionID sets the "session_id" field.
  8303. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8304. m.session_id = &u
  8305. m.addsession_id = nil
  8306. }
  8307. // SessionID returns the value of the "session_id" field in the mutation.
  8308. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8309. v := m.session_id
  8310. if v == nil {
  8311. return
  8312. }
  8313. return *v, true
  8314. }
  8315. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8316. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8318. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8319. if !m.op.Is(OpUpdateOne) {
  8320. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8321. }
  8322. if m.id == nil || m.oldValue == nil {
  8323. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8324. }
  8325. oldValue, err := m.oldValue(ctx)
  8326. if err != nil {
  8327. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8328. }
  8329. return oldValue.SessionID, nil
  8330. }
  8331. // AddSessionID adds u to the "session_id" field.
  8332. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8333. if m.addsession_id != nil {
  8334. *m.addsession_id += u
  8335. } else {
  8336. m.addsession_id = &u
  8337. }
  8338. }
  8339. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8340. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8341. v := m.addsession_id
  8342. if v == nil {
  8343. return
  8344. }
  8345. return *v, true
  8346. }
  8347. // ResetSessionID resets all changes to the "session_id" field.
  8348. func (m *ChatRecordsMutation) ResetSessionID() {
  8349. m.session_id = nil
  8350. m.addsession_id = nil
  8351. }
  8352. // SetUserID sets the "user_id" field.
  8353. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8354. m.user_id = &u
  8355. m.adduser_id = nil
  8356. }
  8357. // UserID returns the value of the "user_id" field in the mutation.
  8358. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8359. v := m.user_id
  8360. if v == nil {
  8361. return
  8362. }
  8363. return *v, true
  8364. }
  8365. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8366. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8368. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8369. if !m.op.Is(OpUpdateOne) {
  8370. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8371. }
  8372. if m.id == nil || m.oldValue == nil {
  8373. return v, errors.New("OldUserID requires an ID field in the mutation")
  8374. }
  8375. oldValue, err := m.oldValue(ctx)
  8376. if err != nil {
  8377. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8378. }
  8379. return oldValue.UserID, nil
  8380. }
  8381. // AddUserID adds u to the "user_id" field.
  8382. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8383. if m.adduser_id != nil {
  8384. *m.adduser_id += u
  8385. } else {
  8386. m.adduser_id = &u
  8387. }
  8388. }
  8389. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8390. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8391. v := m.adduser_id
  8392. if v == nil {
  8393. return
  8394. }
  8395. return *v, true
  8396. }
  8397. // ResetUserID resets all changes to the "user_id" field.
  8398. func (m *ChatRecordsMutation) ResetUserID() {
  8399. m.user_id = nil
  8400. m.adduser_id = nil
  8401. }
  8402. // SetBotID sets the "bot_id" field.
  8403. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8404. m.bot_id = &u
  8405. m.addbot_id = nil
  8406. }
  8407. // BotID returns the value of the "bot_id" field in the mutation.
  8408. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8409. v := m.bot_id
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8416. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8418. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8419. if !m.op.Is(OpUpdateOne) {
  8420. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8421. }
  8422. if m.id == nil || m.oldValue == nil {
  8423. return v, errors.New("OldBotID requires an ID field in the mutation")
  8424. }
  8425. oldValue, err := m.oldValue(ctx)
  8426. if err != nil {
  8427. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8428. }
  8429. return oldValue.BotID, nil
  8430. }
  8431. // AddBotID adds u to the "bot_id" field.
  8432. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8433. if m.addbot_id != nil {
  8434. *m.addbot_id += u
  8435. } else {
  8436. m.addbot_id = &u
  8437. }
  8438. }
  8439. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8440. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8441. v := m.addbot_id
  8442. if v == nil {
  8443. return
  8444. }
  8445. return *v, true
  8446. }
  8447. // ResetBotID resets all changes to the "bot_id" field.
  8448. func (m *ChatRecordsMutation) ResetBotID() {
  8449. m.bot_id = nil
  8450. m.addbot_id = nil
  8451. }
  8452. // SetBotType sets the "bot_type" field.
  8453. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8454. m.bot_type = &u
  8455. m.addbot_type = nil
  8456. }
  8457. // BotType returns the value of the "bot_type" field in the mutation.
  8458. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8459. v := m.bot_type
  8460. if v == nil {
  8461. return
  8462. }
  8463. return *v, true
  8464. }
  8465. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8466. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8468. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8469. if !m.op.Is(OpUpdateOne) {
  8470. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8471. }
  8472. if m.id == nil || m.oldValue == nil {
  8473. return v, errors.New("OldBotType requires an ID field in the mutation")
  8474. }
  8475. oldValue, err := m.oldValue(ctx)
  8476. if err != nil {
  8477. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8478. }
  8479. return oldValue.BotType, nil
  8480. }
  8481. // AddBotType adds u to the "bot_type" field.
  8482. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8483. if m.addbot_type != nil {
  8484. *m.addbot_type += u
  8485. } else {
  8486. m.addbot_type = &u
  8487. }
  8488. }
  8489. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8490. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8491. v := m.addbot_type
  8492. if v == nil {
  8493. return
  8494. }
  8495. return *v, true
  8496. }
  8497. // ResetBotType resets all changes to the "bot_type" field.
  8498. func (m *ChatRecordsMutation) ResetBotType() {
  8499. m.bot_type = nil
  8500. m.addbot_type = nil
  8501. }
  8502. // Where appends a list predicates to the ChatRecordsMutation builder.
  8503. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8504. m.predicates = append(m.predicates, ps...)
  8505. }
  8506. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8507. // users can use type-assertion to append predicates that do not depend on any generated package.
  8508. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8509. p := make([]predicate.ChatRecords, len(ps))
  8510. for i := range ps {
  8511. p[i] = ps[i]
  8512. }
  8513. m.Where(p...)
  8514. }
  8515. // Op returns the operation name.
  8516. func (m *ChatRecordsMutation) Op() Op {
  8517. return m.op
  8518. }
  8519. // SetOp allows setting the mutation operation.
  8520. func (m *ChatRecordsMutation) SetOp(op Op) {
  8521. m.op = op
  8522. }
  8523. // Type returns the node type of this mutation (ChatRecords).
  8524. func (m *ChatRecordsMutation) Type() string {
  8525. return m.typ
  8526. }
  8527. // Fields returns all fields that were changed during this mutation. Note that in
  8528. // order to get all numeric fields that were incremented/decremented, call
  8529. // AddedFields().
  8530. func (m *ChatRecordsMutation) Fields() []string {
  8531. fields := make([]string, 0, 9)
  8532. if m.created_at != nil {
  8533. fields = append(fields, chatrecords.FieldCreatedAt)
  8534. }
  8535. if m.updated_at != nil {
  8536. fields = append(fields, chatrecords.FieldUpdatedAt)
  8537. }
  8538. if m.deleted_at != nil {
  8539. fields = append(fields, chatrecords.FieldDeletedAt)
  8540. }
  8541. if m.content != nil {
  8542. fields = append(fields, chatrecords.FieldContent)
  8543. }
  8544. if m.content_type != nil {
  8545. fields = append(fields, chatrecords.FieldContentType)
  8546. }
  8547. if m.session_id != nil {
  8548. fields = append(fields, chatrecords.FieldSessionID)
  8549. }
  8550. if m.user_id != nil {
  8551. fields = append(fields, chatrecords.FieldUserID)
  8552. }
  8553. if m.bot_id != nil {
  8554. fields = append(fields, chatrecords.FieldBotID)
  8555. }
  8556. if m.bot_type != nil {
  8557. fields = append(fields, chatrecords.FieldBotType)
  8558. }
  8559. return fields
  8560. }
  8561. // Field returns the value of a field with the given name. The second boolean
  8562. // return value indicates that this field was not set, or was not defined in the
  8563. // schema.
  8564. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8565. switch name {
  8566. case chatrecords.FieldCreatedAt:
  8567. return m.CreatedAt()
  8568. case chatrecords.FieldUpdatedAt:
  8569. return m.UpdatedAt()
  8570. case chatrecords.FieldDeletedAt:
  8571. return m.DeletedAt()
  8572. case chatrecords.FieldContent:
  8573. return m.Content()
  8574. case chatrecords.FieldContentType:
  8575. return m.ContentType()
  8576. case chatrecords.FieldSessionID:
  8577. return m.SessionID()
  8578. case chatrecords.FieldUserID:
  8579. return m.UserID()
  8580. case chatrecords.FieldBotID:
  8581. return m.BotID()
  8582. case chatrecords.FieldBotType:
  8583. return m.BotType()
  8584. }
  8585. return nil, false
  8586. }
  8587. // OldField returns the old value of the field from the database. An error is
  8588. // returned if the mutation operation is not UpdateOne, or the query to the
  8589. // database failed.
  8590. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8591. switch name {
  8592. case chatrecords.FieldCreatedAt:
  8593. return m.OldCreatedAt(ctx)
  8594. case chatrecords.FieldUpdatedAt:
  8595. return m.OldUpdatedAt(ctx)
  8596. case chatrecords.FieldDeletedAt:
  8597. return m.OldDeletedAt(ctx)
  8598. case chatrecords.FieldContent:
  8599. return m.OldContent(ctx)
  8600. case chatrecords.FieldContentType:
  8601. return m.OldContentType(ctx)
  8602. case chatrecords.FieldSessionID:
  8603. return m.OldSessionID(ctx)
  8604. case chatrecords.FieldUserID:
  8605. return m.OldUserID(ctx)
  8606. case chatrecords.FieldBotID:
  8607. return m.OldBotID(ctx)
  8608. case chatrecords.FieldBotType:
  8609. return m.OldBotType(ctx)
  8610. }
  8611. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8612. }
  8613. // SetField sets the value of a field with the given name. It returns an error if
  8614. // the field is not defined in the schema, or if the type mismatched the field
  8615. // type.
  8616. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8617. switch name {
  8618. case chatrecords.FieldCreatedAt:
  8619. v, ok := value.(time.Time)
  8620. if !ok {
  8621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8622. }
  8623. m.SetCreatedAt(v)
  8624. return nil
  8625. case chatrecords.FieldUpdatedAt:
  8626. v, ok := value.(time.Time)
  8627. if !ok {
  8628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8629. }
  8630. m.SetUpdatedAt(v)
  8631. return nil
  8632. case chatrecords.FieldDeletedAt:
  8633. v, ok := value.(time.Time)
  8634. if !ok {
  8635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8636. }
  8637. m.SetDeletedAt(v)
  8638. return nil
  8639. case chatrecords.FieldContent:
  8640. v, ok := value.(string)
  8641. if !ok {
  8642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8643. }
  8644. m.SetContent(v)
  8645. return nil
  8646. case chatrecords.FieldContentType:
  8647. v, ok := value.(uint8)
  8648. if !ok {
  8649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8650. }
  8651. m.SetContentType(v)
  8652. return nil
  8653. case chatrecords.FieldSessionID:
  8654. v, ok := value.(uint64)
  8655. if !ok {
  8656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8657. }
  8658. m.SetSessionID(v)
  8659. return nil
  8660. case chatrecords.FieldUserID:
  8661. v, ok := value.(uint64)
  8662. if !ok {
  8663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8664. }
  8665. m.SetUserID(v)
  8666. return nil
  8667. case chatrecords.FieldBotID:
  8668. v, ok := value.(uint64)
  8669. if !ok {
  8670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8671. }
  8672. m.SetBotID(v)
  8673. return nil
  8674. case chatrecords.FieldBotType:
  8675. v, ok := value.(uint8)
  8676. if !ok {
  8677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8678. }
  8679. m.SetBotType(v)
  8680. return nil
  8681. }
  8682. return fmt.Errorf("unknown ChatRecords field %s", name)
  8683. }
  8684. // AddedFields returns all numeric fields that were incremented/decremented during
  8685. // this mutation.
  8686. func (m *ChatRecordsMutation) AddedFields() []string {
  8687. var fields []string
  8688. if m.addcontent_type != nil {
  8689. fields = append(fields, chatrecords.FieldContentType)
  8690. }
  8691. if m.addsession_id != nil {
  8692. fields = append(fields, chatrecords.FieldSessionID)
  8693. }
  8694. if m.adduser_id != nil {
  8695. fields = append(fields, chatrecords.FieldUserID)
  8696. }
  8697. if m.addbot_id != nil {
  8698. fields = append(fields, chatrecords.FieldBotID)
  8699. }
  8700. if m.addbot_type != nil {
  8701. fields = append(fields, chatrecords.FieldBotType)
  8702. }
  8703. return fields
  8704. }
  8705. // AddedField returns the numeric value that was incremented/decremented on a field
  8706. // with the given name. The second boolean return value indicates that this field
  8707. // was not set, or was not defined in the schema.
  8708. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8709. switch name {
  8710. case chatrecords.FieldContentType:
  8711. return m.AddedContentType()
  8712. case chatrecords.FieldSessionID:
  8713. return m.AddedSessionID()
  8714. case chatrecords.FieldUserID:
  8715. return m.AddedUserID()
  8716. case chatrecords.FieldBotID:
  8717. return m.AddedBotID()
  8718. case chatrecords.FieldBotType:
  8719. return m.AddedBotType()
  8720. }
  8721. return nil, false
  8722. }
  8723. // AddField adds the value to the field with the given name. It returns an error if
  8724. // the field is not defined in the schema, or if the type mismatched the field
  8725. // type.
  8726. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8727. switch name {
  8728. case chatrecords.FieldContentType:
  8729. v, ok := value.(int8)
  8730. if !ok {
  8731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8732. }
  8733. m.AddContentType(v)
  8734. return nil
  8735. case chatrecords.FieldSessionID:
  8736. v, ok := value.(int64)
  8737. if !ok {
  8738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8739. }
  8740. m.AddSessionID(v)
  8741. return nil
  8742. case chatrecords.FieldUserID:
  8743. v, ok := value.(int64)
  8744. if !ok {
  8745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8746. }
  8747. m.AddUserID(v)
  8748. return nil
  8749. case chatrecords.FieldBotID:
  8750. v, ok := value.(int64)
  8751. if !ok {
  8752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8753. }
  8754. m.AddBotID(v)
  8755. return nil
  8756. case chatrecords.FieldBotType:
  8757. v, ok := value.(int8)
  8758. if !ok {
  8759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8760. }
  8761. m.AddBotType(v)
  8762. return nil
  8763. }
  8764. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8765. }
  8766. // ClearedFields returns all nullable fields that were cleared during this
  8767. // mutation.
  8768. func (m *ChatRecordsMutation) ClearedFields() []string {
  8769. var fields []string
  8770. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8771. fields = append(fields, chatrecords.FieldDeletedAt)
  8772. }
  8773. return fields
  8774. }
  8775. // FieldCleared returns a boolean indicating if a field with the given name was
  8776. // cleared in this mutation.
  8777. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8778. _, ok := m.clearedFields[name]
  8779. return ok
  8780. }
  8781. // ClearField clears the value of the field with the given name. It returns an
  8782. // error if the field is not defined in the schema.
  8783. func (m *ChatRecordsMutation) ClearField(name string) error {
  8784. switch name {
  8785. case chatrecords.FieldDeletedAt:
  8786. m.ClearDeletedAt()
  8787. return nil
  8788. }
  8789. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8790. }
  8791. // ResetField resets all changes in the mutation for the field with the given name.
  8792. // It returns an error if the field is not defined in the schema.
  8793. func (m *ChatRecordsMutation) ResetField(name string) error {
  8794. switch name {
  8795. case chatrecords.FieldCreatedAt:
  8796. m.ResetCreatedAt()
  8797. return nil
  8798. case chatrecords.FieldUpdatedAt:
  8799. m.ResetUpdatedAt()
  8800. return nil
  8801. case chatrecords.FieldDeletedAt:
  8802. m.ResetDeletedAt()
  8803. return nil
  8804. case chatrecords.FieldContent:
  8805. m.ResetContent()
  8806. return nil
  8807. case chatrecords.FieldContentType:
  8808. m.ResetContentType()
  8809. return nil
  8810. case chatrecords.FieldSessionID:
  8811. m.ResetSessionID()
  8812. return nil
  8813. case chatrecords.FieldUserID:
  8814. m.ResetUserID()
  8815. return nil
  8816. case chatrecords.FieldBotID:
  8817. m.ResetBotID()
  8818. return nil
  8819. case chatrecords.FieldBotType:
  8820. m.ResetBotType()
  8821. return nil
  8822. }
  8823. return fmt.Errorf("unknown ChatRecords field %s", name)
  8824. }
  8825. // AddedEdges returns all edge names that were set/added in this mutation.
  8826. func (m *ChatRecordsMutation) AddedEdges() []string {
  8827. edges := make([]string, 0, 0)
  8828. return edges
  8829. }
  8830. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8831. // name in this mutation.
  8832. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8833. return nil
  8834. }
  8835. // RemovedEdges returns all edge names that were removed in this mutation.
  8836. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8837. edges := make([]string, 0, 0)
  8838. return edges
  8839. }
  8840. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8841. // the given name in this mutation.
  8842. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8843. return nil
  8844. }
  8845. // ClearedEdges returns all edge names that were cleared in this mutation.
  8846. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8847. edges := make([]string, 0, 0)
  8848. return edges
  8849. }
  8850. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8851. // was cleared in this mutation.
  8852. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8853. return false
  8854. }
  8855. // ClearEdge clears the value of the edge with the given name. It returns an error
  8856. // if that edge is not defined in the schema.
  8857. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8858. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8859. }
  8860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8861. // It returns an error if the edge is not defined in the schema.
  8862. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8863. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8864. }
  8865. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8866. type ChatSessionMutation struct {
  8867. config
  8868. op Op
  8869. typ string
  8870. id *uint64
  8871. created_at *time.Time
  8872. updated_at *time.Time
  8873. deleted_at *time.Time
  8874. name *string
  8875. user_id *uint64
  8876. adduser_id *int64
  8877. bot_id *uint64
  8878. addbot_id *int64
  8879. bot_type *uint8
  8880. addbot_type *int8
  8881. clearedFields map[string]struct{}
  8882. done bool
  8883. oldValue func(context.Context) (*ChatSession, error)
  8884. predicates []predicate.ChatSession
  8885. }
  8886. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8887. // chatsessionOption allows management of the mutation configuration using functional options.
  8888. type chatsessionOption func(*ChatSessionMutation)
  8889. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8890. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8891. m := &ChatSessionMutation{
  8892. config: c,
  8893. op: op,
  8894. typ: TypeChatSession,
  8895. clearedFields: make(map[string]struct{}),
  8896. }
  8897. for _, opt := range opts {
  8898. opt(m)
  8899. }
  8900. return m
  8901. }
  8902. // withChatSessionID sets the ID field of the mutation.
  8903. func withChatSessionID(id uint64) chatsessionOption {
  8904. return func(m *ChatSessionMutation) {
  8905. var (
  8906. err error
  8907. once sync.Once
  8908. value *ChatSession
  8909. )
  8910. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8911. once.Do(func() {
  8912. if m.done {
  8913. err = errors.New("querying old values post mutation is not allowed")
  8914. } else {
  8915. value, err = m.Client().ChatSession.Get(ctx, id)
  8916. }
  8917. })
  8918. return value, err
  8919. }
  8920. m.id = &id
  8921. }
  8922. }
  8923. // withChatSession sets the old ChatSession of the mutation.
  8924. func withChatSession(node *ChatSession) chatsessionOption {
  8925. return func(m *ChatSessionMutation) {
  8926. m.oldValue = func(context.Context) (*ChatSession, error) {
  8927. return node, nil
  8928. }
  8929. m.id = &node.ID
  8930. }
  8931. }
  8932. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8933. // executed in a transaction (ent.Tx), a transactional client is returned.
  8934. func (m ChatSessionMutation) Client() *Client {
  8935. client := &Client{config: m.config}
  8936. client.init()
  8937. return client
  8938. }
  8939. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8940. // it returns an error otherwise.
  8941. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8942. if _, ok := m.driver.(*txDriver); !ok {
  8943. return nil, errors.New("ent: mutation is not running in a transaction")
  8944. }
  8945. tx := &Tx{config: m.config}
  8946. tx.init()
  8947. return tx, nil
  8948. }
  8949. // SetID sets the value of the id field. Note that this
  8950. // operation is only accepted on creation of ChatSession entities.
  8951. func (m *ChatSessionMutation) SetID(id uint64) {
  8952. m.id = &id
  8953. }
  8954. // ID returns the ID value in the mutation. Note that the ID is only available
  8955. // if it was provided to the builder or after it was returned from the database.
  8956. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8957. if m.id == nil {
  8958. return
  8959. }
  8960. return *m.id, true
  8961. }
  8962. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8963. // That means, if the mutation is applied within a transaction with an isolation level such
  8964. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8965. // or updated by the mutation.
  8966. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8967. switch {
  8968. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8969. id, exists := m.ID()
  8970. if exists {
  8971. return []uint64{id}, nil
  8972. }
  8973. fallthrough
  8974. case m.op.Is(OpUpdate | OpDelete):
  8975. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8976. default:
  8977. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8978. }
  8979. }
  8980. // SetCreatedAt sets the "created_at" field.
  8981. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8982. m.created_at = &t
  8983. }
  8984. // CreatedAt returns the value of the "created_at" field in the mutation.
  8985. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8986. v := m.created_at
  8987. if v == nil {
  8988. return
  8989. }
  8990. return *v, true
  8991. }
  8992. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8993. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8995. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8996. if !m.op.Is(OpUpdateOne) {
  8997. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8998. }
  8999. if m.id == nil || m.oldValue == nil {
  9000. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9001. }
  9002. oldValue, err := m.oldValue(ctx)
  9003. if err != nil {
  9004. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9005. }
  9006. return oldValue.CreatedAt, nil
  9007. }
  9008. // ResetCreatedAt resets all changes to the "created_at" field.
  9009. func (m *ChatSessionMutation) ResetCreatedAt() {
  9010. m.created_at = nil
  9011. }
  9012. // SetUpdatedAt sets the "updated_at" field.
  9013. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9014. m.updated_at = &t
  9015. }
  9016. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9017. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9018. v := m.updated_at
  9019. if v == nil {
  9020. return
  9021. }
  9022. return *v, true
  9023. }
  9024. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9025. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9027. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9028. if !m.op.Is(OpUpdateOne) {
  9029. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9030. }
  9031. if m.id == nil || m.oldValue == nil {
  9032. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9033. }
  9034. oldValue, err := m.oldValue(ctx)
  9035. if err != nil {
  9036. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9037. }
  9038. return oldValue.UpdatedAt, nil
  9039. }
  9040. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9041. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9042. m.updated_at = nil
  9043. }
  9044. // SetDeletedAt sets the "deleted_at" field.
  9045. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9046. m.deleted_at = &t
  9047. }
  9048. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9049. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9050. v := m.deleted_at
  9051. if v == nil {
  9052. return
  9053. }
  9054. return *v, true
  9055. }
  9056. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9057. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9059. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9060. if !m.op.Is(OpUpdateOne) {
  9061. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9062. }
  9063. if m.id == nil || m.oldValue == nil {
  9064. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9065. }
  9066. oldValue, err := m.oldValue(ctx)
  9067. if err != nil {
  9068. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9069. }
  9070. return oldValue.DeletedAt, nil
  9071. }
  9072. // ClearDeletedAt clears the value of the "deleted_at" field.
  9073. func (m *ChatSessionMutation) ClearDeletedAt() {
  9074. m.deleted_at = nil
  9075. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9076. }
  9077. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9078. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9079. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9080. return ok
  9081. }
  9082. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9083. func (m *ChatSessionMutation) ResetDeletedAt() {
  9084. m.deleted_at = nil
  9085. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9086. }
  9087. // SetName sets the "name" field.
  9088. func (m *ChatSessionMutation) SetName(s string) {
  9089. m.name = &s
  9090. }
  9091. // Name returns the value of the "name" field in the mutation.
  9092. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9093. v := m.name
  9094. if v == nil {
  9095. return
  9096. }
  9097. return *v, true
  9098. }
  9099. // OldName returns the old "name" field's value of the ChatSession entity.
  9100. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9102. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9103. if !m.op.Is(OpUpdateOne) {
  9104. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9105. }
  9106. if m.id == nil || m.oldValue == nil {
  9107. return v, errors.New("OldName requires an ID field in the mutation")
  9108. }
  9109. oldValue, err := m.oldValue(ctx)
  9110. if err != nil {
  9111. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9112. }
  9113. return oldValue.Name, nil
  9114. }
  9115. // ResetName resets all changes to the "name" field.
  9116. func (m *ChatSessionMutation) ResetName() {
  9117. m.name = nil
  9118. }
  9119. // SetUserID sets the "user_id" field.
  9120. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9121. m.user_id = &u
  9122. m.adduser_id = nil
  9123. }
  9124. // UserID returns the value of the "user_id" field in the mutation.
  9125. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9126. v := m.user_id
  9127. if v == nil {
  9128. return
  9129. }
  9130. return *v, true
  9131. }
  9132. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9133. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9135. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9136. if !m.op.Is(OpUpdateOne) {
  9137. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9138. }
  9139. if m.id == nil || m.oldValue == nil {
  9140. return v, errors.New("OldUserID requires an ID field in the mutation")
  9141. }
  9142. oldValue, err := m.oldValue(ctx)
  9143. if err != nil {
  9144. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9145. }
  9146. return oldValue.UserID, nil
  9147. }
  9148. // AddUserID adds u to the "user_id" field.
  9149. func (m *ChatSessionMutation) AddUserID(u int64) {
  9150. if m.adduser_id != nil {
  9151. *m.adduser_id += u
  9152. } else {
  9153. m.adduser_id = &u
  9154. }
  9155. }
  9156. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9157. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9158. v := m.adduser_id
  9159. if v == nil {
  9160. return
  9161. }
  9162. return *v, true
  9163. }
  9164. // ResetUserID resets all changes to the "user_id" field.
  9165. func (m *ChatSessionMutation) ResetUserID() {
  9166. m.user_id = nil
  9167. m.adduser_id = nil
  9168. }
  9169. // SetBotID sets the "bot_id" field.
  9170. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9171. m.bot_id = &u
  9172. m.addbot_id = nil
  9173. }
  9174. // BotID returns the value of the "bot_id" field in the mutation.
  9175. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9176. v := m.bot_id
  9177. if v == nil {
  9178. return
  9179. }
  9180. return *v, true
  9181. }
  9182. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9183. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9185. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9186. if !m.op.Is(OpUpdateOne) {
  9187. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9188. }
  9189. if m.id == nil || m.oldValue == nil {
  9190. return v, errors.New("OldBotID requires an ID field in the mutation")
  9191. }
  9192. oldValue, err := m.oldValue(ctx)
  9193. if err != nil {
  9194. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9195. }
  9196. return oldValue.BotID, nil
  9197. }
  9198. // AddBotID adds u to the "bot_id" field.
  9199. func (m *ChatSessionMutation) AddBotID(u int64) {
  9200. if m.addbot_id != nil {
  9201. *m.addbot_id += u
  9202. } else {
  9203. m.addbot_id = &u
  9204. }
  9205. }
  9206. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9207. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9208. v := m.addbot_id
  9209. if v == nil {
  9210. return
  9211. }
  9212. return *v, true
  9213. }
  9214. // ResetBotID resets all changes to the "bot_id" field.
  9215. func (m *ChatSessionMutation) ResetBotID() {
  9216. m.bot_id = nil
  9217. m.addbot_id = nil
  9218. }
  9219. // SetBotType sets the "bot_type" field.
  9220. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9221. m.bot_type = &u
  9222. m.addbot_type = nil
  9223. }
  9224. // BotType returns the value of the "bot_type" field in the mutation.
  9225. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9226. v := m.bot_type
  9227. if v == nil {
  9228. return
  9229. }
  9230. return *v, true
  9231. }
  9232. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9233. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9235. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9236. if !m.op.Is(OpUpdateOne) {
  9237. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9238. }
  9239. if m.id == nil || m.oldValue == nil {
  9240. return v, errors.New("OldBotType requires an ID field in the mutation")
  9241. }
  9242. oldValue, err := m.oldValue(ctx)
  9243. if err != nil {
  9244. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9245. }
  9246. return oldValue.BotType, nil
  9247. }
  9248. // AddBotType adds u to the "bot_type" field.
  9249. func (m *ChatSessionMutation) AddBotType(u int8) {
  9250. if m.addbot_type != nil {
  9251. *m.addbot_type += u
  9252. } else {
  9253. m.addbot_type = &u
  9254. }
  9255. }
  9256. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9257. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9258. v := m.addbot_type
  9259. if v == nil {
  9260. return
  9261. }
  9262. return *v, true
  9263. }
  9264. // ResetBotType resets all changes to the "bot_type" field.
  9265. func (m *ChatSessionMutation) ResetBotType() {
  9266. m.bot_type = nil
  9267. m.addbot_type = nil
  9268. }
  9269. // Where appends a list predicates to the ChatSessionMutation builder.
  9270. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9271. m.predicates = append(m.predicates, ps...)
  9272. }
  9273. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9274. // users can use type-assertion to append predicates that do not depend on any generated package.
  9275. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9276. p := make([]predicate.ChatSession, len(ps))
  9277. for i := range ps {
  9278. p[i] = ps[i]
  9279. }
  9280. m.Where(p...)
  9281. }
  9282. // Op returns the operation name.
  9283. func (m *ChatSessionMutation) Op() Op {
  9284. return m.op
  9285. }
  9286. // SetOp allows setting the mutation operation.
  9287. func (m *ChatSessionMutation) SetOp(op Op) {
  9288. m.op = op
  9289. }
  9290. // Type returns the node type of this mutation (ChatSession).
  9291. func (m *ChatSessionMutation) Type() string {
  9292. return m.typ
  9293. }
  9294. // Fields returns all fields that were changed during this mutation. Note that in
  9295. // order to get all numeric fields that were incremented/decremented, call
  9296. // AddedFields().
  9297. func (m *ChatSessionMutation) Fields() []string {
  9298. fields := make([]string, 0, 7)
  9299. if m.created_at != nil {
  9300. fields = append(fields, chatsession.FieldCreatedAt)
  9301. }
  9302. if m.updated_at != nil {
  9303. fields = append(fields, chatsession.FieldUpdatedAt)
  9304. }
  9305. if m.deleted_at != nil {
  9306. fields = append(fields, chatsession.FieldDeletedAt)
  9307. }
  9308. if m.name != nil {
  9309. fields = append(fields, chatsession.FieldName)
  9310. }
  9311. if m.user_id != nil {
  9312. fields = append(fields, chatsession.FieldUserID)
  9313. }
  9314. if m.bot_id != nil {
  9315. fields = append(fields, chatsession.FieldBotID)
  9316. }
  9317. if m.bot_type != nil {
  9318. fields = append(fields, chatsession.FieldBotType)
  9319. }
  9320. return fields
  9321. }
  9322. // Field returns the value of a field with the given name. The second boolean
  9323. // return value indicates that this field was not set, or was not defined in the
  9324. // schema.
  9325. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9326. switch name {
  9327. case chatsession.FieldCreatedAt:
  9328. return m.CreatedAt()
  9329. case chatsession.FieldUpdatedAt:
  9330. return m.UpdatedAt()
  9331. case chatsession.FieldDeletedAt:
  9332. return m.DeletedAt()
  9333. case chatsession.FieldName:
  9334. return m.Name()
  9335. case chatsession.FieldUserID:
  9336. return m.UserID()
  9337. case chatsession.FieldBotID:
  9338. return m.BotID()
  9339. case chatsession.FieldBotType:
  9340. return m.BotType()
  9341. }
  9342. return nil, false
  9343. }
  9344. // OldField returns the old value of the field from the database. An error is
  9345. // returned if the mutation operation is not UpdateOne, or the query to the
  9346. // database failed.
  9347. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9348. switch name {
  9349. case chatsession.FieldCreatedAt:
  9350. return m.OldCreatedAt(ctx)
  9351. case chatsession.FieldUpdatedAt:
  9352. return m.OldUpdatedAt(ctx)
  9353. case chatsession.FieldDeletedAt:
  9354. return m.OldDeletedAt(ctx)
  9355. case chatsession.FieldName:
  9356. return m.OldName(ctx)
  9357. case chatsession.FieldUserID:
  9358. return m.OldUserID(ctx)
  9359. case chatsession.FieldBotID:
  9360. return m.OldBotID(ctx)
  9361. case chatsession.FieldBotType:
  9362. return m.OldBotType(ctx)
  9363. }
  9364. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9365. }
  9366. // SetField sets the value of a field with the given name. It returns an error if
  9367. // the field is not defined in the schema, or if the type mismatched the field
  9368. // type.
  9369. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9370. switch name {
  9371. case chatsession.FieldCreatedAt:
  9372. v, ok := value.(time.Time)
  9373. if !ok {
  9374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9375. }
  9376. m.SetCreatedAt(v)
  9377. return nil
  9378. case chatsession.FieldUpdatedAt:
  9379. v, ok := value.(time.Time)
  9380. if !ok {
  9381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9382. }
  9383. m.SetUpdatedAt(v)
  9384. return nil
  9385. case chatsession.FieldDeletedAt:
  9386. v, ok := value.(time.Time)
  9387. if !ok {
  9388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9389. }
  9390. m.SetDeletedAt(v)
  9391. return nil
  9392. case chatsession.FieldName:
  9393. v, ok := value.(string)
  9394. if !ok {
  9395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9396. }
  9397. m.SetName(v)
  9398. return nil
  9399. case chatsession.FieldUserID:
  9400. v, ok := value.(uint64)
  9401. if !ok {
  9402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9403. }
  9404. m.SetUserID(v)
  9405. return nil
  9406. case chatsession.FieldBotID:
  9407. v, ok := value.(uint64)
  9408. if !ok {
  9409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9410. }
  9411. m.SetBotID(v)
  9412. return nil
  9413. case chatsession.FieldBotType:
  9414. v, ok := value.(uint8)
  9415. if !ok {
  9416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9417. }
  9418. m.SetBotType(v)
  9419. return nil
  9420. }
  9421. return fmt.Errorf("unknown ChatSession field %s", name)
  9422. }
  9423. // AddedFields returns all numeric fields that were incremented/decremented during
  9424. // this mutation.
  9425. func (m *ChatSessionMutation) AddedFields() []string {
  9426. var fields []string
  9427. if m.adduser_id != nil {
  9428. fields = append(fields, chatsession.FieldUserID)
  9429. }
  9430. if m.addbot_id != nil {
  9431. fields = append(fields, chatsession.FieldBotID)
  9432. }
  9433. if m.addbot_type != nil {
  9434. fields = append(fields, chatsession.FieldBotType)
  9435. }
  9436. return fields
  9437. }
  9438. // AddedField returns the numeric value that was incremented/decremented on a field
  9439. // with the given name. The second boolean return value indicates that this field
  9440. // was not set, or was not defined in the schema.
  9441. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9442. switch name {
  9443. case chatsession.FieldUserID:
  9444. return m.AddedUserID()
  9445. case chatsession.FieldBotID:
  9446. return m.AddedBotID()
  9447. case chatsession.FieldBotType:
  9448. return m.AddedBotType()
  9449. }
  9450. return nil, false
  9451. }
  9452. // AddField adds the value to the field with the given name. It returns an error if
  9453. // the field is not defined in the schema, or if the type mismatched the field
  9454. // type.
  9455. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9456. switch name {
  9457. case chatsession.FieldUserID:
  9458. v, ok := value.(int64)
  9459. if !ok {
  9460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9461. }
  9462. m.AddUserID(v)
  9463. return nil
  9464. case chatsession.FieldBotID:
  9465. v, ok := value.(int64)
  9466. if !ok {
  9467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9468. }
  9469. m.AddBotID(v)
  9470. return nil
  9471. case chatsession.FieldBotType:
  9472. v, ok := value.(int8)
  9473. if !ok {
  9474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9475. }
  9476. m.AddBotType(v)
  9477. return nil
  9478. }
  9479. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9480. }
  9481. // ClearedFields returns all nullable fields that were cleared during this
  9482. // mutation.
  9483. func (m *ChatSessionMutation) ClearedFields() []string {
  9484. var fields []string
  9485. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9486. fields = append(fields, chatsession.FieldDeletedAt)
  9487. }
  9488. return fields
  9489. }
  9490. // FieldCleared returns a boolean indicating if a field with the given name was
  9491. // cleared in this mutation.
  9492. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9493. _, ok := m.clearedFields[name]
  9494. return ok
  9495. }
  9496. // ClearField clears the value of the field with the given name. It returns an
  9497. // error if the field is not defined in the schema.
  9498. func (m *ChatSessionMutation) ClearField(name string) error {
  9499. switch name {
  9500. case chatsession.FieldDeletedAt:
  9501. m.ClearDeletedAt()
  9502. return nil
  9503. }
  9504. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9505. }
  9506. // ResetField resets all changes in the mutation for the field with the given name.
  9507. // It returns an error if the field is not defined in the schema.
  9508. func (m *ChatSessionMutation) ResetField(name string) error {
  9509. switch name {
  9510. case chatsession.FieldCreatedAt:
  9511. m.ResetCreatedAt()
  9512. return nil
  9513. case chatsession.FieldUpdatedAt:
  9514. m.ResetUpdatedAt()
  9515. return nil
  9516. case chatsession.FieldDeletedAt:
  9517. m.ResetDeletedAt()
  9518. return nil
  9519. case chatsession.FieldName:
  9520. m.ResetName()
  9521. return nil
  9522. case chatsession.FieldUserID:
  9523. m.ResetUserID()
  9524. return nil
  9525. case chatsession.FieldBotID:
  9526. m.ResetBotID()
  9527. return nil
  9528. case chatsession.FieldBotType:
  9529. m.ResetBotType()
  9530. return nil
  9531. }
  9532. return fmt.Errorf("unknown ChatSession field %s", name)
  9533. }
  9534. // AddedEdges returns all edge names that were set/added in this mutation.
  9535. func (m *ChatSessionMutation) AddedEdges() []string {
  9536. edges := make([]string, 0, 0)
  9537. return edges
  9538. }
  9539. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9540. // name in this mutation.
  9541. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9542. return nil
  9543. }
  9544. // RemovedEdges returns all edge names that were removed in this mutation.
  9545. func (m *ChatSessionMutation) RemovedEdges() []string {
  9546. edges := make([]string, 0, 0)
  9547. return edges
  9548. }
  9549. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9550. // the given name in this mutation.
  9551. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9552. return nil
  9553. }
  9554. // ClearedEdges returns all edge names that were cleared in this mutation.
  9555. func (m *ChatSessionMutation) ClearedEdges() []string {
  9556. edges := make([]string, 0, 0)
  9557. return edges
  9558. }
  9559. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9560. // was cleared in this mutation.
  9561. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9562. return false
  9563. }
  9564. // ClearEdge clears the value of the edge with the given name. It returns an error
  9565. // if that edge is not defined in the schema.
  9566. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9567. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9568. }
  9569. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9570. // It returns an error if the edge is not defined in the schema.
  9571. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9572. return fmt.Errorf("unknown ChatSession edge %s", name)
  9573. }
  9574. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9575. type ContactMutation struct {
  9576. config
  9577. op Op
  9578. typ string
  9579. id *uint64
  9580. created_at *time.Time
  9581. updated_at *time.Time
  9582. status *uint8
  9583. addstatus *int8
  9584. deleted_at *time.Time
  9585. wx_wxid *string
  9586. _type *int
  9587. add_type *int
  9588. wxid *string
  9589. account *string
  9590. nickname *string
  9591. markname *string
  9592. headimg *string
  9593. sex *int
  9594. addsex *int
  9595. starrole *string
  9596. dontseeit *int
  9597. adddontseeit *int
  9598. dontseeme *int
  9599. adddontseeme *int
  9600. lag *string
  9601. gid *string
  9602. gname *string
  9603. v3 *string
  9604. organization_id *uint64
  9605. addorganization_id *int64
  9606. ctype *uint64
  9607. addctype *int64
  9608. cage *int
  9609. addcage *int
  9610. cname *string
  9611. carea *string
  9612. cbirthday *string
  9613. cbirtharea *string
  9614. cidcard_no *string
  9615. ctitle *string
  9616. cc *string
  9617. phone *string
  9618. clearedFields map[string]struct{}
  9619. contact_relationships map[uint64]struct{}
  9620. removedcontact_relationships map[uint64]struct{}
  9621. clearedcontact_relationships bool
  9622. contact_fields map[uint64]struct{}
  9623. removedcontact_fields map[uint64]struct{}
  9624. clearedcontact_fields bool
  9625. contact_messages map[uint64]struct{}
  9626. removedcontact_messages map[uint64]struct{}
  9627. clearedcontact_messages bool
  9628. done bool
  9629. oldValue func(context.Context) (*Contact, error)
  9630. predicates []predicate.Contact
  9631. }
  9632. var _ ent.Mutation = (*ContactMutation)(nil)
  9633. // contactOption allows management of the mutation configuration using functional options.
  9634. type contactOption func(*ContactMutation)
  9635. // newContactMutation creates new mutation for the Contact entity.
  9636. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9637. m := &ContactMutation{
  9638. config: c,
  9639. op: op,
  9640. typ: TypeContact,
  9641. clearedFields: make(map[string]struct{}),
  9642. }
  9643. for _, opt := range opts {
  9644. opt(m)
  9645. }
  9646. return m
  9647. }
  9648. // withContactID sets the ID field of the mutation.
  9649. func withContactID(id uint64) contactOption {
  9650. return func(m *ContactMutation) {
  9651. var (
  9652. err error
  9653. once sync.Once
  9654. value *Contact
  9655. )
  9656. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9657. once.Do(func() {
  9658. if m.done {
  9659. err = errors.New("querying old values post mutation is not allowed")
  9660. } else {
  9661. value, err = m.Client().Contact.Get(ctx, id)
  9662. }
  9663. })
  9664. return value, err
  9665. }
  9666. m.id = &id
  9667. }
  9668. }
  9669. // withContact sets the old Contact of the mutation.
  9670. func withContact(node *Contact) contactOption {
  9671. return func(m *ContactMutation) {
  9672. m.oldValue = func(context.Context) (*Contact, error) {
  9673. return node, nil
  9674. }
  9675. m.id = &node.ID
  9676. }
  9677. }
  9678. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9679. // executed in a transaction (ent.Tx), a transactional client is returned.
  9680. func (m ContactMutation) Client() *Client {
  9681. client := &Client{config: m.config}
  9682. client.init()
  9683. return client
  9684. }
  9685. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9686. // it returns an error otherwise.
  9687. func (m ContactMutation) Tx() (*Tx, error) {
  9688. if _, ok := m.driver.(*txDriver); !ok {
  9689. return nil, errors.New("ent: mutation is not running in a transaction")
  9690. }
  9691. tx := &Tx{config: m.config}
  9692. tx.init()
  9693. return tx, nil
  9694. }
  9695. // SetID sets the value of the id field. Note that this
  9696. // operation is only accepted on creation of Contact entities.
  9697. func (m *ContactMutation) SetID(id uint64) {
  9698. m.id = &id
  9699. }
  9700. // ID returns the ID value in the mutation. Note that the ID is only available
  9701. // if it was provided to the builder or after it was returned from the database.
  9702. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9703. if m.id == nil {
  9704. return
  9705. }
  9706. return *m.id, true
  9707. }
  9708. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9709. // That means, if the mutation is applied within a transaction with an isolation level such
  9710. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9711. // or updated by the mutation.
  9712. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9713. switch {
  9714. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9715. id, exists := m.ID()
  9716. if exists {
  9717. return []uint64{id}, nil
  9718. }
  9719. fallthrough
  9720. case m.op.Is(OpUpdate | OpDelete):
  9721. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9722. default:
  9723. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9724. }
  9725. }
  9726. // SetCreatedAt sets the "created_at" field.
  9727. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9728. m.created_at = &t
  9729. }
  9730. // CreatedAt returns the value of the "created_at" field in the mutation.
  9731. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9732. v := m.created_at
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9751. }
  9752. return oldValue.CreatedAt, nil
  9753. }
  9754. // ResetCreatedAt resets all changes to the "created_at" field.
  9755. func (m *ContactMutation) ResetCreatedAt() {
  9756. m.created_at = nil
  9757. }
  9758. // SetUpdatedAt sets the "updated_at" field.
  9759. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9760. m.updated_at = &t
  9761. }
  9762. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9763. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9764. v := m.updated_at
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9771. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9773. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9774. if !m.op.Is(OpUpdateOne) {
  9775. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9776. }
  9777. if m.id == nil || m.oldValue == nil {
  9778. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9779. }
  9780. oldValue, err := m.oldValue(ctx)
  9781. if err != nil {
  9782. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9783. }
  9784. return oldValue.UpdatedAt, nil
  9785. }
  9786. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9787. func (m *ContactMutation) ResetUpdatedAt() {
  9788. m.updated_at = nil
  9789. }
  9790. // SetStatus sets the "status" field.
  9791. func (m *ContactMutation) SetStatus(u uint8) {
  9792. m.status = &u
  9793. m.addstatus = nil
  9794. }
  9795. // Status returns the value of the "status" field in the mutation.
  9796. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9797. v := m.status
  9798. if v == nil {
  9799. return
  9800. }
  9801. return *v, true
  9802. }
  9803. // OldStatus returns the old "status" field's value of the Contact entity.
  9804. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9806. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9807. if !m.op.Is(OpUpdateOne) {
  9808. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9809. }
  9810. if m.id == nil || m.oldValue == nil {
  9811. return v, errors.New("OldStatus requires an ID field in the mutation")
  9812. }
  9813. oldValue, err := m.oldValue(ctx)
  9814. if err != nil {
  9815. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9816. }
  9817. return oldValue.Status, nil
  9818. }
  9819. // AddStatus adds u to the "status" field.
  9820. func (m *ContactMutation) AddStatus(u int8) {
  9821. if m.addstatus != nil {
  9822. *m.addstatus += u
  9823. } else {
  9824. m.addstatus = &u
  9825. }
  9826. }
  9827. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9828. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9829. v := m.addstatus
  9830. if v == nil {
  9831. return
  9832. }
  9833. return *v, true
  9834. }
  9835. // ClearStatus clears the value of the "status" field.
  9836. func (m *ContactMutation) ClearStatus() {
  9837. m.status = nil
  9838. m.addstatus = nil
  9839. m.clearedFields[contact.FieldStatus] = struct{}{}
  9840. }
  9841. // StatusCleared returns if the "status" field was cleared in this mutation.
  9842. func (m *ContactMutation) StatusCleared() bool {
  9843. _, ok := m.clearedFields[contact.FieldStatus]
  9844. return ok
  9845. }
  9846. // ResetStatus resets all changes to the "status" field.
  9847. func (m *ContactMutation) ResetStatus() {
  9848. m.status = nil
  9849. m.addstatus = nil
  9850. delete(m.clearedFields, contact.FieldStatus)
  9851. }
  9852. // SetDeletedAt sets the "deleted_at" field.
  9853. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9854. m.deleted_at = &t
  9855. }
  9856. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9857. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9858. v := m.deleted_at
  9859. if v == nil {
  9860. return
  9861. }
  9862. return *v, true
  9863. }
  9864. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9867. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9868. if !m.op.Is(OpUpdateOne) {
  9869. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9870. }
  9871. if m.id == nil || m.oldValue == nil {
  9872. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9873. }
  9874. oldValue, err := m.oldValue(ctx)
  9875. if err != nil {
  9876. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9877. }
  9878. return oldValue.DeletedAt, nil
  9879. }
  9880. // ClearDeletedAt clears the value of the "deleted_at" field.
  9881. func (m *ContactMutation) ClearDeletedAt() {
  9882. m.deleted_at = nil
  9883. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9884. }
  9885. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9886. func (m *ContactMutation) DeletedAtCleared() bool {
  9887. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9888. return ok
  9889. }
  9890. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9891. func (m *ContactMutation) ResetDeletedAt() {
  9892. m.deleted_at = nil
  9893. delete(m.clearedFields, contact.FieldDeletedAt)
  9894. }
  9895. // SetWxWxid sets the "wx_wxid" field.
  9896. func (m *ContactMutation) SetWxWxid(s string) {
  9897. m.wx_wxid = &s
  9898. }
  9899. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9900. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9901. v := m.wx_wxid
  9902. if v == nil {
  9903. return
  9904. }
  9905. return *v, true
  9906. }
  9907. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9908. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9910. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9911. if !m.op.Is(OpUpdateOne) {
  9912. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9913. }
  9914. if m.id == nil || m.oldValue == nil {
  9915. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9916. }
  9917. oldValue, err := m.oldValue(ctx)
  9918. if err != nil {
  9919. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9920. }
  9921. return oldValue.WxWxid, nil
  9922. }
  9923. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9924. func (m *ContactMutation) ResetWxWxid() {
  9925. m.wx_wxid = nil
  9926. }
  9927. // SetType sets the "type" field.
  9928. func (m *ContactMutation) SetType(i int) {
  9929. m._type = &i
  9930. m.add_type = nil
  9931. }
  9932. // GetType returns the value of the "type" field in the mutation.
  9933. func (m *ContactMutation) GetType() (r int, exists bool) {
  9934. v := m._type
  9935. if v == nil {
  9936. return
  9937. }
  9938. return *v, true
  9939. }
  9940. // OldType returns the old "type" field's value of the Contact entity.
  9941. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9943. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9944. if !m.op.Is(OpUpdateOne) {
  9945. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9946. }
  9947. if m.id == nil || m.oldValue == nil {
  9948. return v, errors.New("OldType requires an ID field in the mutation")
  9949. }
  9950. oldValue, err := m.oldValue(ctx)
  9951. if err != nil {
  9952. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9953. }
  9954. return oldValue.Type, nil
  9955. }
  9956. // AddType adds i to the "type" field.
  9957. func (m *ContactMutation) AddType(i int) {
  9958. if m.add_type != nil {
  9959. *m.add_type += i
  9960. } else {
  9961. m.add_type = &i
  9962. }
  9963. }
  9964. // AddedType returns the value that was added to the "type" field in this mutation.
  9965. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9966. v := m.add_type
  9967. if v == nil {
  9968. return
  9969. }
  9970. return *v, true
  9971. }
  9972. // ClearType clears the value of the "type" field.
  9973. func (m *ContactMutation) ClearType() {
  9974. m._type = nil
  9975. m.add_type = nil
  9976. m.clearedFields[contact.FieldType] = struct{}{}
  9977. }
  9978. // TypeCleared returns if the "type" field was cleared in this mutation.
  9979. func (m *ContactMutation) TypeCleared() bool {
  9980. _, ok := m.clearedFields[contact.FieldType]
  9981. return ok
  9982. }
  9983. // ResetType resets all changes to the "type" field.
  9984. func (m *ContactMutation) ResetType() {
  9985. m._type = nil
  9986. m.add_type = nil
  9987. delete(m.clearedFields, contact.FieldType)
  9988. }
  9989. // SetWxid sets the "wxid" field.
  9990. func (m *ContactMutation) SetWxid(s string) {
  9991. m.wxid = &s
  9992. }
  9993. // Wxid returns the value of the "wxid" field in the mutation.
  9994. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9995. v := m.wxid
  9996. if v == nil {
  9997. return
  9998. }
  9999. return *v, true
  10000. }
  10001. // OldWxid returns the old "wxid" field's value of the Contact entity.
  10002. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10004. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  10005. if !m.op.Is(OpUpdateOne) {
  10006. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  10007. }
  10008. if m.id == nil || m.oldValue == nil {
  10009. return v, errors.New("OldWxid requires an ID field in the mutation")
  10010. }
  10011. oldValue, err := m.oldValue(ctx)
  10012. if err != nil {
  10013. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  10014. }
  10015. return oldValue.Wxid, nil
  10016. }
  10017. // ResetWxid resets all changes to the "wxid" field.
  10018. func (m *ContactMutation) ResetWxid() {
  10019. m.wxid = nil
  10020. }
  10021. // SetAccount sets the "account" field.
  10022. func (m *ContactMutation) SetAccount(s string) {
  10023. m.account = &s
  10024. }
  10025. // Account returns the value of the "account" field in the mutation.
  10026. func (m *ContactMutation) Account() (r string, exists bool) {
  10027. v := m.account
  10028. if v == nil {
  10029. return
  10030. }
  10031. return *v, true
  10032. }
  10033. // OldAccount returns the old "account" field's value of the Contact entity.
  10034. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10036. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  10037. if !m.op.Is(OpUpdateOne) {
  10038. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  10039. }
  10040. if m.id == nil || m.oldValue == nil {
  10041. return v, errors.New("OldAccount requires an ID field in the mutation")
  10042. }
  10043. oldValue, err := m.oldValue(ctx)
  10044. if err != nil {
  10045. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  10046. }
  10047. return oldValue.Account, nil
  10048. }
  10049. // ResetAccount resets all changes to the "account" field.
  10050. func (m *ContactMutation) ResetAccount() {
  10051. m.account = nil
  10052. }
  10053. // SetNickname sets the "nickname" field.
  10054. func (m *ContactMutation) SetNickname(s string) {
  10055. m.nickname = &s
  10056. }
  10057. // Nickname returns the value of the "nickname" field in the mutation.
  10058. func (m *ContactMutation) Nickname() (r string, exists bool) {
  10059. v := m.nickname
  10060. if v == nil {
  10061. return
  10062. }
  10063. return *v, true
  10064. }
  10065. // OldNickname returns the old "nickname" field's value of the Contact entity.
  10066. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10068. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  10069. if !m.op.Is(OpUpdateOne) {
  10070. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  10071. }
  10072. if m.id == nil || m.oldValue == nil {
  10073. return v, errors.New("OldNickname requires an ID field in the mutation")
  10074. }
  10075. oldValue, err := m.oldValue(ctx)
  10076. if err != nil {
  10077. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  10078. }
  10079. return oldValue.Nickname, nil
  10080. }
  10081. // ResetNickname resets all changes to the "nickname" field.
  10082. func (m *ContactMutation) ResetNickname() {
  10083. m.nickname = nil
  10084. }
  10085. // SetMarkname sets the "markname" field.
  10086. func (m *ContactMutation) SetMarkname(s string) {
  10087. m.markname = &s
  10088. }
  10089. // Markname returns the value of the "markname" field in the mutation.
  10090. func (m *ContactMutation) Markname() (r string, exists bool) {
  10091. v := m.markname
  10092. if v == nil {
  10093. return
  10094. }
  10095. return *v, true
  10096. }
  10097. // OldMarkname returns the old "markname" field's value of the Contact entity.
  10098. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10100. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  10101. if !m.op.Is(OpUpdateOne) {
  10102. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  10103. }
  10104. if m.id == nil || m.oldValue == nil {
  10105. return v, errors.New("OldMarkname requires an ID field in the mutation")
  10106. }
  10107. oldValue, err := m.oldValue(ctx)
  10108. if err != nil {
  10109. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  10110. }
  10111. return oldValue.Markname, nil
  10112. }
  10113. // ResetMarkname resets all changes to the "markname" field.
  10114. func (m *ContactMutation) ResetMarkname() {
  10115. m.markname = nil
  10116. }
  10117. // SetHeadimg sets the "headimg" field.
  10118. func (m *ContactMutation) SetHeadimg(s string) {
  10119. m.headimg = &s
  10120. }
  10121. // Headimg returns the value of the "headimg" field in the mutation.
  10122. func (m *ContactMutation) Headimg() (r string, exists bool) {
  10123. v := m.headimg
  10124. if v == nil {
  10125. return
  10126. }
  10127. return *v, true
  10128. }
  10129. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  10130. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10132. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  10133. if !m.op.Is(OpUpdateOne) {
  10134. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  10135. }
  10136. if m.id == nil || m.oldValue == nil {
  10137. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  10138. }
  10139. oldValue, err := m.oldValue(ctx)
  10140. if err != nil {
  10141. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  10142. }
  10143. return oldValue.Headimg, nil
  10144. }
  10145. // ResetHeadimg resets all changes to the "headimg" field.
  10146. func (m *ContactMutation) ResetHeadimg() {
  10147. m.headimg = nil
  10148. }
  10149. // SetSex sets the "sex" field.
  10150. func (m *ContactMutation) SetSex(i int) {
  10151. m.sex = &i
  10152. m.addsex = nil
  10153. }
  10154. // Sex returns the value of the "sex" field in the mutation.
  10155. func (m *ContactMutation) Sex() (r int, exists bool) {
  10156. v := m.sex
  10157. if v == nil {
  10158. return
  10159. }
  10160. return *v, true
  10161. }
  10162. // OldSex returns the old "sex" field's value of the Contact entity.
  10163. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10165. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  10166. if !m.op.Is(OpUpdateOne) {
  10167. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  10168. }
  10169. if m.id == nil || m.oldValue == nil {
  10170. return v, errors.New("OldSex requires an ID field in the mutation")
  10171. }
  10172. oldValue, err := m.oldValue(ctx)
  10173. if err != nil {
  10174. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  10175. }
  10176. return oldValue.Sex, nil
  10177. }
  10178. // AddSex adds i to the "sex" field.
  10179. func (m *ContactMutation) AddSex(i int) {
  10180. if m.addsex != nil {
  10181. *m.addsex += i
  10182. } else {
  10183. m.addsex = &i
  10184. }
  10185. }
  10186. // AddedSex returns the value that was added to the "sex" field in this mutation.
  10187. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  10188. v := m.addsex
  10189. if v == nil {
  10190. return
  10191. }
  10192. return *v, true
  10193. }
  10194. // ResetSex resets all changes to the "sex" field.
  10195. func (m *ContactMutation) ResetSex() {
  10196. m.sex = nil
  10197. m.addsex = nil
  10198. }
  10199. // SetStarrole sets the "starrole" field.
  10200. func (m *ContactMutation) SetStarrole(s string) {
  10201. m.starrole = &s
  10202. }
  10203. // Starrole returns the value of the "starrole" field in the mutation.
  10204. func (m *ContactMutation) Starrole() (r string, exists bool) {
  10205. v := m.starrole
  10206. if v == nil {
  10207. return
  10208. }
  10209. return *v, true
  10210. }
  10211. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  10212. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10214. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  10215. if !m.op.Is(OpUpdateOne) {
  10216. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  10217. }
  10218. if m.id == nil || m.oldValue == nil {
  10219. return v, errors.New("OldStarrole requires an ID field in the mutation")
  10220. }
  10221. oldValue, err := m.oldValue(ctx)
  10222. if err != nil {
  10223. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  10224. }
  10225. return oldValue.Starrole, nil
  10226. }
  10227. // ResetStarrole resets all changes to the "starrole" field.
  10228. func (m *ContactMutation) ResetStarrole() {
  10229. m.starrole = nil
  10230. }
  10231. // SetDontseeit sets the "dontseeit" field.
  10232. func (m *ContactMutation) SetDontseeit(i int) {
  10233. m.dontseeit = &i
  10234. m.adddontseeit = nil
  10235. }
  10236. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  10237. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  10238. v := m.dontseeit
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  10245. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10247. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10253. }
  10254. oldValue, err := m.oldValue(ctx)
  10255. if err != nil {
  10256. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  10257. }
  10258. return oldValue.Dontseeit, nil
  10259. }
  10260. // AddDontseeit adds i to the "dontseeit" field.
  10261. func (m *ContactMutation) AddDontseeit(i int) {
  10262. if m.adddontseeit != nil {
  10263. *m.adddontseeit += i
  10264. } else {
  10265. m.adddontseeit = &i
  10266. }
  10267. }
  10268. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  10269. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  10270. v := m.adddontseeit
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // ResetDontseeit resets all changes to the "dontseeit" field.
  10277. func (m *ContactMutation) ResetDontseeit() {
  10278. m.dontseeit = nil
  10279. m.adddontseeit = nil
  10280. }
  10281. // SetDontseeme sets the "dontseeme" field.
  10282. func (m *ContactMutation) SetDontseeme(i int) {
  10283. m.dontseeme = &i
  10284. m.adddontseeme = nil
  10285. }
  10286. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  10287. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  10288. v := m.dontseeme
  10289. if v == nil {
  10290. return
  10291. }
  10292. return *v, true
  10293. }
  10294. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  10295. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10297. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  10298. if !m.op.Is(OpUpdateOne) {
  10299. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  10300. }
  10301. if m.id == nil || m.oldValue == nil {
  10302. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  10303. }
  10304. oldValue, err := m.oldValue(ctx)
  10305. if err != nil {
  10306. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  10307. }
  10308. return oldValue.Dontseeme, nil
  10309. }
  10310. // AddDontseeme adds i to the "dontseeme" field.
  10311. func (m *ContactMutation) AddDontseeme(i int) {
  10312. if m.adddontseeme != nil {
  10313. *m.adddontseeme += i
  10314. } else {
  10315. m.adddontseeme = &i
  10316. }
  10317. }
  10318. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10319. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10320. v := m.adddontseeme
  10321. if v == nil {
  10322. return
  10323. }
  10324. return *v, true
  10325. }
  10326. // ResetDontseeme resets all changes to the "dontseeme" field.
  10327. func (m *ContactMutation) ResetDontseeme() {
  10328. m.dontseeme = nil
  10329. m.adddontseeme = nil
  10330. }
  10331. // SetLag sets the "lag" field.
  10332. func (m *ContactMutation) SetLag(s string) {
  10333. m.lag = &s
  10334. }
  10335. // Lag returns the value of the "lag" field in the mutation.
  10336. func (m *ContactMutation) Lag() (r string, exists bool) {
  10337. v := m.lag
  10338. if v == nil {
  10339. return
  10340. }
  10341. return *v, true
  10342. }
  10343. // OldLag returns the old "lag" field's value of the Contact entity.
  10344. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10346. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10347. if !m.op.Is(OpUpdateOne) {
  10348. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10349. }
  10350. if m.id == nil || m.oldValue == nil {
  10351. return v, errors.New("OldLag requires an ID field in the mutation")
  10352. }
  10353. oldValue, err := m.oldValue(ctx)
  10354. if err != nil {
  10355. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10356. }
  10357. return oldValue.Lag, nil
  10358. }
  10359. // ResetLag resets all changes to the "lag" field.
  10360. func (m *ContactMutation) ResetLag() {
  10361. m.lag = nil
  10362. }
  10363. // SetGid sets the "gid" field.
  10364. func (m *ContactMutation) SetGid(s string) {
  10365. m.gid = &s
  10366. }
  10367. // Gid returns the value of the "gid" field in the mutation.
  10368. func (m *ContactMutation) Gid() (r string, exists bool) {
  10369. v := m.gid
  10370. if v == nil {
  10371. return
  10372. }
  10373. return *v, true
  10374. }
  10375. // OldGid returns the old "gid" field's value of the Contact entity.
  10376. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10378. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10379. if !m.op.Is(OpUpdateOne) {
  10380. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10381. }
  10382. if m.id == nil || m.oldValue == nil {
  10383. return v, errors.New("OldGid requires an ID field in the mutation")
  10384. }
  10385. oldValue, err := m.oldValue(ctx)
  10386. if err != nil {
  10387. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10388. }
  10389. return oldValue.Gid, nil
  10390. }
  10391. // ResetGid resets all changes to the "gid" field.
  10392. func (m *ContactMutation) ResetGid() {
  10393. m.gid = nil
  10394. }
  10395. // SetGname sets the "gname" field.
  10396. func (m *ContactMutation) SetGname(s string) {
  10397. m.gname = &s
  10398. }
  10399. // Gname returns the value of the "gname" field in the mutation.
  10400. func (m *ContactMutation) Gname() (r string, exists bool) {
  10401. v := m.gname
  10402. if v == nil {
  10403. return
  10404. }
  10405. return *v, true
  10406. }
  10407. // OldGname returns the old "gname" field's value of the Contact entity.
  10408. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10410. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10411. if !m.op.Is(OpUpdateOne) {
  10412. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10413. }
  10414. if m.id == nil || m.oldValue == nil {
  10415. return v, errors.New("OldGname requires an ID field in the mutation")
  10416. }
  10417. oldValue, err := m.oldValue(ctx)
  10418. if err != nil {
  10419. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10420. }
  10421. return oldValue.Gname, nil
  10422. }
  10423. // ResetGname resets all changes to the "gname" field.
  10424. func (m *ContactMutation) ResetGname() {
  10425. m.gname = nil
  10426. }
  10427. // SetV3 sets the "v3" field.
  10428. func (m *ContactMutation) SetV3(s string) {
  10429. m.v3 = &s
  10430. }
  10431. // V3 returns the value of the "v3" field in the mutation.
  10432. func (m *ContactMutation) V3() (r string, exists bool) {
  10433. v := m.v3
  10434. if v == nil {
  10435. return
  10436. }
  10437. return *v, true
  10438. }
  10439. // OldV3 returns the old "v3" field's value of the Contact entity.
  10440. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10442. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10443. if !m.op.Is(OpUpdateOne) {
  10444. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10445. }
  10446. if m.id == nil || m.oldValue == nil {
  10447. return v, errors.New("OldV3 requires an ID field in the mutation")
  10448. }
  10449. oldValue, err := m.oldValue(ctx)
  10450. if err != nil {
  10451. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10452. }
  10453. return oldValue.V3, nil
  10454. }
  10455. // ResetV3 resets all changes to the "v3" field.
  10456. func (m *ContactMutation) ResetV3() {
  10457. m.v3 = nil
  10458. }
  10459. // SetOrganizationID sets the "organization_id" field.
  10460. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10461. m.organization_id = &u
  10462. m.addorganization_id = nil
  10463. }
  10464. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10465. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10466. v := m.organization_id
  10467. if v == nil {
  10468. return
  10469. }
  10470. return *v, true
  10471. }
  10472. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10473. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10475. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10476. if !m.op.Is(OpUpdateOne) {
  10477. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10478. }
  10479. if m.id == nil || m.oldValue == nil {
  10480. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10481. }
  10482. oldValue, err := m.oldValue(ctx)
  10483. if err != nil {
  10484. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10485. }
  10486. return oldValue.OrganizationID, nil
  10487. }
  10488. // AddOrganizationID adds u to the "organization_id" field.
  10489. func (m *ContactMutation) AddOrganizationID(u int64) {
  10490. if m.addorganization_id != nil {
  10491. *m.addorganization_id += u
  10492. } else {
  10493. m.addorganization_id = &u
  10494. }
  10495. }
  10496. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10497. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10498. v := m.addorganization_id
  10499. if v == nil {
  10500. return
  10501. }
  10502. return *v, true
  10503. }
  10504. // ClearOrganizationID clears the value of the "organization_id" field.
  10505. func (m *ContactMutation) ClearOrganizationID() {
  10506. m.organization_id = nil
  10507. m.addorganization_id = nil
  10508. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10509. }
  10510. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10511. func (m *ContactMutation) OrganizationIDCleared() bool {
  10512. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10513. return ok
  10514. }
  10515. // ResetOrganizationID resets all changes to the "organization_id" field.
  10516. func (m *ContactMutation) ResetOrganizationID() {
  10517. m.organization_id = nil
  10518. m.addorganization_id = nil
  10519. delete(m.clearedFields, contact.FieldOrganizationID)
  10520. }
  10521. // SetCtype sets the "ctype" field.
  10522. func (m *ContactMutation) SetCtype(u uint64) {
  10523. m.ctype = &u
  10524. m.addctype = nil
  10525. }
  10526. // Ctype returns the value of the "ctype" field in the mutation.
  10527. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10528. v := m.ctype
  10529. if v == nil {
  10530. return
  10531. }
  10532. return *v, true
  10533. }
  10534. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10535. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10537. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10538. if !m.op.Is(OpUpdateOne) {
  10539. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10540. }
  10541. if m.id == nil || m.oldValue == nil {
  10542. return v, errors.New("OldCtype requires an ID field in the mutation")
  10543. }
  10544. oldValue, err := m.oldValue(ctx)
  10545. if err != nil {
  10546. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10547. }
  10548. return oldValue.Ctype, nil
  10549. }
  10550. // AddCtype adds u to the "ctype" field.
  10551. func (m *ContactMutation) AddCtype(u int64) {
  10552. if m.addctype != nil {
  10553. *m.addctype += u
  10554. } else {
  10555. m.addctype = &u
  10556. }
  10557. }
  10558. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10559. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10560. v := m.addctype
  10561. if v == nil {
  10562. return
  10563. }
  10564. return *v, true
  10565. }
  10566. // ResetCtype resets all changes to the "ctype" field.
  10567. func (m *ContactMutation) ResetCtype() {
  10568. m.ctype = nil
  10569. m.addctype = nil
  10570. }
  10571. // SetCage sets the "cage" field.
  10572. func (m *ContactMutation) SetCage(i int) {
  10573. m.cage = &i
  10574. m.addcage = nil
  10575. }
  10576. // Cage returns the value of the "cage" field in the mutation.
  10577. func (m *ContactMutation) Cage() (r int, exists bool) {
  10578. v := m.cage
  10579. if v == nil {
  10580. return
  10581. }
  10582. return *v, true
  10583. }
  10584. // OldCage returns the old "cage" field's value of the Contact entity.
  10585. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10587. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10588. if !m.op.Is(OpUpdateOne) {
  10589. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10590. }
  10591. if m.id == nil || m.oldValue == nil {
  10592. return v, errors.New("OldCage requires an ID field in the mutation")
  10593. }
  10594. oldValue, err := m.oldValue(ctx)
  10595. if err != nil {
  10596. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10597. }
  10598. return oldValue.Cage, nil
  10599. }
  10600. // AddCage adds i to the "cage" field.
  10601. func (m *ContactMutation) AddCage(i int) {
  10602. if m.addcage != nil {
  10603. *m.addcage += i
  10604. } else {
  10605. m.addcage = &i
  10606. }
  10607. }
  10608. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10609. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10610. v := m.addcage
  10611. if v == nil {
  10612. return
  10613. }
  10614. return *v, true
  10615. }
  10616. // ResetCage resets all changes to the "cage" field.
  10617. func (m *ContactMutation) ResetCage() {
  10618. m.cage = nil
  10619. m.addcage = nil
  10620. }
  10621. // SetCname sets the "cname" field.
  10622. func (m *ContactMutation) SetCname(s string) {
  10623. m.cname = &s
  10624. }
  10625. // Cname returns the value of the "cname" field in the mutation.
  10626. func (m *ContactMutation) Cname() (r string, exists bool) {
  10627. v := m.cname
  10628. if v == nil {
  10629. return
  10630. }
  10631. return *v, true
  10632. }
  10633. // OldCname returns the old "cname" field's value of the Contact entity.
  10634. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10636. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10637. if !m.op.Is(OpUpdateOne) {
  10638. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10639. }
  10640. if m.id == nil || m.oldValue == nil {
  10641. return v, errors.New("OldCname requires an ID field in the mutation")
  10642. }
  10643. oldValue, err := m.oldValue(ctx)
  10644. if err != nil {
  10645. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10646. }
  10647. return oldValue.Cname, nil
  10648. }
  10649. // ResetCname resets all changes to the "cname" field.
  10650. func (m *ContactMutation) ResetCname() {
  10651. m.cname = nil
  10652. }
  10653. // SetCarea sets the "carea" field.
  10654. func (m *ContactMutation) SetCarea(s string) {
  10655. m.carea = &s
  10656. }
  10657. // Carea returns the value of the "carea" field in the mutation.
  10658. func (m *ContactMutation) Carea() (r string, exists bool) {
  10659. v := m.carea
  10660. if v == nil {
  10661. return
  10662. }
  10663. return *v, true
  10664. }
  10665. // OldCarea returns the old "carea" field's value of the Contact entity.
  10666. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10668. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10669. if !m.op.Is(OpUpdateOne) {
  10670. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10671. }
  10672. if m.id == nil || m.oldValue == nil {
  10673. return v, errors.New("OldCarea requires an ID field in the mutation")
  10674. }
  10675. oldValue, err := m.oldValue(ctx)
  10676. if err != nil {
  10677. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10678. }
  10679. return oldValue.Carea, nil
  10680. }
  10681. // ResetCarea resets all changes to the "carea" field.
  10682. func (m *ContactMutation) ResetCarea() {
  10683. m.carea = nil
  10684. }
  10685. // SetCbirthday sets the "cbirthday" field.
  10686. func (m *ContactMutation) SetCbirthday(s string) {
  10687. m.cbirthday = &s
  10688. }
  10689. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10690. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10691. v := m.cbirthday
  10692. if v == nil {
  10693. return
  10694. }
  10695. return *v, true
  10696. }
  10697. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10698. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10700. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10701. if !m.op.Is(OpUpdateOne) {
  10702. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10703. }
  10704. if m.id == nil || m.oldValue == nil {
  10705. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10706. }
  10707. oldValue, err := m.oldValue(ctx)
  10708. if err != nil {
  10709. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10710. }
  10711. return oldValue.Cbirthday, nil
  10712. }
  10713. // ResetCbirthday resets all changes to the "cbirthday" field.
  10714. func (m *ContactMutation) ResetCbirthday() {
  10715. m.cbirthday = nil
  10716. }
  10717. // SetCbirtharea sets the "cbirtharea" field.
  10718. func (m *ContactMutation) SetCbirtharea(s string) {
  10719. m.cbirtharea = &s
  10720. }
  10721. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10722. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10723. v := m.cbirtharea
  10724. if v == nil {
  10725. return
  10726. }
  10727. return *v, true
  10728. }
  10729. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10730. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10732. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10733. if !m.op.Is(OpUpdateOne) {
  10734. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10735. }
  10736. if m.id == nil || m.oldValue == nil {
  10737. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10738. }
  10739. oldValue, err := m.oldValue(ctx)
  10740. if err != nil {
  10741. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10742. }
  10743. return oldValue.Cbirtharea, nil
  10744. }
  10745. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10746. func (m *ContactMutation) ResetCbirtharea() {
  10747. m.cbirtharea = nil
  10748. }
  10749. // SetCidcardNo sets the "cidcard_no" field.
  10750. func (m *ContactMutation) SetCidcardNo(s string) {
  10751. m.cidcard_no = &s
  10752. }
  10753. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10754. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10755. v := m.cidcard_no
  10756. if v == nil {
  10757. return
  10758. }
  10759. return *v, true
  10760. }
  10761. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10762. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10764. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10765. if !m.op.Is(OpUpdateOne) {
  10766. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10767. }
  10768. if m.id == nil || m.oldValue == nil {
  10769. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10770. }
  10771. oldValue, err := m.oldValue(ctx)
  10772. if err != nil {
  10773. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10774. }
  10775. return oldValue.CidcardNo, nil
  10776. }
  10777. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10778. func (m *ContactMutation) ResetCidcardNo() {
  10779. m.cidcard_no = nil
  10780. }
  10781. // SetCtitle sets the "ctitle" field.
  10782. func (m *ContactMutation) SetCtitle(s string) {
  10783. m.ctitle = &s
  10784. }
  10785. // Ctitle returns the value of the "ctitle" field in the mutation.
  10786. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10787. v := m.ctitle
  10788. if v == nil {
  10789. return
  10790. }
  10791. return *v, true
  10792. }
  10793. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10794. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10796. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10797. if !m.op.Is(OpUpdateOne) {
  10798. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10799. }
  10800. if m.id == nil || m.oldValue == nil {
  10801. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10802. }
  10803. oldValue, err := m.oldValue(ctx)
  10804. if err != nil {
  10805. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10806. }
  10807. return oldValue.Ctitle, nil
  10808. }
  10809. // ResetCtitle resets all changes to the "ctitle" field.
  10810. func (m *ContactMutation) ResetCtitle() {
  10811. m.ctitle = nil
  10812. }
  10813. // SetCc sets the "cc" field.
  10814. func (m *ContactMutation) SetCc(s string) {
  10815. m.cc = &s
  10816. }
  10817. // Cc returns the value of the "cc" field in the mutation.
  10818. func (m *ContactMutation) Cc() (r string, exists bool) {
  10819. v := m.cc
  10820. if v == nil {
  10821. return
  10822. }
  10823. return *v, true
  10824. }
  10825. // OldCc returns the old "cc" field's value of the Contact entity.
  10826. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10828. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10829. if !m.op.Is(OpUpdateOne) {
  10830. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10831. }
  10832. if m.id == nil || m.oldValue == nil {
  10833. return v, errors.New("OldCc requires an ID field in the mutation")
  10834. }
  10835. oldValue, err := m.oldValue(ctx)
  10836. if err != nil {
  10837. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10838. }
  10839. return oldValue.Cc, nil
  10840. }
  10841. // ResetCc resets all changes to the "cc" field.
  10842. func (m *ContactMutation) ResetCc() {
  10843. m.cc = nil
  10844. }
  10845. // SetPhone sets the "phone" field.
  10846. func (m *ContactMutation) SetPhone(s string) {
  10847. m.phone = &s
  10848. }
  10849. // Phone returns the value of the "phone" field in the mutation.
  10850. func (m *ContactMutation) Phone() (r string, exists bool) {
  10851. v := m.phone
  10852. if v == nil {
  10853. return
  10854. }
  10855. return *v, true
  10856. }
  10857. // OldPhone returns the old "phone" field's value of the Contact entity.
  10858. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10860. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10861. if !m.op.Is(OpUpdateOne) {
  10862. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10863. }
  10864. if m.id == nil || m.oldValue == nil {
  10865. return v, errors.New("OldPhone requires an ID field in the mutation")
  10866. }
  10867. oldValue, err := m.oldValue(ctx)
  10868. if err != nil {
  10869. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10870. }
  10871. return oldValue.Phone, nil
  10872. }
  10873. // ResetPhone resets all changes to the "phone" field.
  10874. func (m *ContactMutation) ResetPhone() {
  10875. m.phone = nil
  10876. }
  10877. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10878. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10879. if m.contact_relationships == nil {
  10880. m.contact_relationships = make(map[uint64]struct{})
  10881. }
  10882. for i := range ids {
  10883. m.contact_relationships[ids[i]] = struct{}{}
  10884. }
  10885. }
  10886. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10887. func (m *ContactMutation) ClearContactRelationships() {
  10888. m.clearedcontact_relationships = true
  10889. }
  10890. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10891. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10892. return m.clearedcontact_relationships
  10893. }
  10894. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10895. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10896. if m.removedcontact_relationships == nil {
  10897. m.removedcontact_relationships = make(map[uint64]struct{})
  10898. }
  10899. for i := range ids {
  10900. delete(m.contact_relationships, ids[i])
  10901. m.removedcontact_relationships[ids[i]] = struct{}{}
  10902. }
  10903. }
  10904. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10905. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10906. for id := range m.removedcontact_relationships {
  10907. ids = append(ids, id)
  10908. }
  10909. return
  10910. }
  10911. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10912. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10913. for id := range m.contact_relationships {
  10914. ids = append(ids, id)
  10915. }
  10916. return
  10917. }
  10918. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10919. func (m *ContactMutation) ResetContactRelationships() {
  10920. m.contact_relationships = nil
  10921. m.clearedcontact_relationships = false
  10922. m.removedcontact_relationships = nil
  10923. }
  10924. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  10925. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  10926. if m.contact_fields == nil {
  10927. m.contact_fields = make(map[uint64]struct{})
  10928. }
  10929. for i := range ids {
  10930. m.contact_fields[ids[i]] = struct{}{}
  10931. }
  10932. }
  10933. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  10934. func (m *ContactMutation) ClearContactFields() {
  10935. m.clearedcontact_fields = true
  10936. }
  10937. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  10938. func (m *ContactMutation) ContactFieldsCleared() bool {
  10939. return m.clearedcontact_fields
  10940. }
  10941. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  10942. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  10943. if m.removedcontact_fields == nil {
  10944. m.removedcontact_fields = make(map[uint64]struct{})
  10945. }
  10946. for i := range ids {
  10947. delete(m.contact_fields, ids[i])
  10948. m.removedcontact_fields[ids[i]] = struct{}{}
  10949. }
  10950. }
  10951. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  10952. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  10953. for id := range m.removedcontact_fields {
  10954. ids = append(ids, id)
  10955. }
  10956. return
  10957. }
  10958. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  10959. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  10960. for id := range m.contact_fields {
  10961. ids = append(ids, id)
  10962. }
  10963. return
  10964. }
  10965. // ResetContactFields resets all changes to the "contact_fields" edge.
  10966. func (m *ContactMutation) ResetContactFields() {
  10967. m.contact_fields = nil
  10968. m.clearedcontact_fields = false
  10969. m.removedcontact_fields = nil
  10970. }
  10971. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10972. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10973. if m.contact_messages == nil {
  10974. m.contact_messages = make(map[uint64]struct{})
  10975. }
  10976. for i := range ids {
  10977. m.contact_messages[ids[i]] = struct{}{}
  10978. }
  10979. }
  10980. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10981. func (m *ContactMutation) ClearContactMessages() {
  10982. m.clearedcontact_messages = true
  10983. }
  10984. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10985. func (m *ContactMutation) ContactMessagesCleared() bool {
  10986. return m.clearedcontact_messages
  10987. }
  10988. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10989. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10990. if m.removedcontact_messages == nil {
  10991. m.removedcontact_messages = make(map[uint64]struct{})
  10992. }
  10993. for i := range ids {
  10994. delete(m.contact_messages, ids[i])
  10995. m.removedcontact_messages[ids[i]] = struct{}{}
  10996. }
  10997. }
  10998. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10999. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  11000. for id := range m.removedcontact_messages {
  11001. ids = append(ids, id)
  11002. }
  11003. return
  11004. }
  11005. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  11006. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  11007. for id := range m.contact_messages {
  11008. ids = append(ids, id)
  11009. }
  11010. return
  11011. }
  11012. // ResetContactMessages resets all changes to the "contact_messages" edge.
  11013. func (m *ContactMutation) ResetContactMessages() {
  11014. m.contact_messages = nil
  11015. m.clearedcontact_messages = false
  11016. m.removedcontact_messages = nil
  11017. }
  11018. // Where appends a list predicates to the ContactMutation builder.
  11019. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  11020. m.predicates = append(m.predicates, ps...)
  11021. }
  11022. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  11023. // users can use type-assertion to append predicates that do not depend on any generated package.
  11024. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  11025. p := make([]predicate.Contact, len(ps))
  11026. for i := range ps {
  11027. p[i] = ps[i]
  11028. }
  11029. m.Where(p...)
  11030. }
  11031. // Op returns the operation name.
  11032. func (m *ContactMutation) Op() Op {
  11033. return m.op
  11034. }
  11035. // SetOp allows setting the mutation operation.
  11036. func (m *ContactMutation) SetOp(op Op) {
  11037. m.op = op
  11038. }
  11039. // Type returns the node type of this mutation (Contact).
  11040. func (m *ContactMutation) Type() string {
  11041. return m.typ
  11042. }
  11043. // Fields returns all fields that were changed during this mutation. Note that in
  11044. // order to get all numeric fields that were incremented/decremented, call
  11045. // AddedFields().
  11046. func (m *ContactMutation) Fields() []string {
  11047. fields := make([]string, 0, 30)
  11048. if m.created_at != nil {
  11049. fields = append(fields, contact.FieldCreatedAt)
  11050. }
  11051. if m.updated_at != nil {
  11052. fields = append(fields, contact.FieldUpdatedAt)
  11053. }
  11054. if m.status != nil {
  11055. fields = append(fields, contact.FieldStatus)
  11056. }
  11057. if m.deleted_at != nil {
  11058. fields = append(fields, contact.FieldDeletedAt)
  11059. }
  11060. if m.wx_wxid != nil {
  11061. fields = append(fields, contact.FieldWxWxid)
  11062. }
  11063. if m._type != nil {
  11064. fields = append(fields, contact.FieldType)
  11065. }
  11066. if m.wxid != nil {
  11067. fields = append(fields, contact.FieldWxid)
  11068. }
  11069. if m.account != nil {
  11070. fields = append(fields, contact.FieldAccount)
  11071. }
  11072. if m.nickname != nil {
  11073. fields = append(fields, contact.FieldNickname)
  11074. }
  11075. if m.markname != nil {
  11076. fields = append(fields, contact.FieldMarkname)
  11077. }
  11078. if m.headimg != nil {
  11079. fields = append(fields, contact.FieldHeadimg)
  11080. }
  11081. if m.sex != nil {
  11082. fields = append(fields, contact.FieldSex)
  11083. }
  11084. if m.starrole != nil {
  11085. fields = append(fields, contact.FieldStarrole)
  11086. }
  11087. if m.dontseeit != nil {
  11088. fields = append(fields, contact.FieldDontseeit)
  11089. }
  11090. if m.dontseeme != nil {
  11091. fields = append(fields, contact.FieldDontseeme)
  11092. }
  11093. if m.lag != nil {
  11094. fields = append(fields, contact.FieldLag)
  11095. }
  11096. if m.gid != nil {
  11097. fields = append(fields, contact.FieldGid)
  11098. }
  11099. if m.gname != nil {
  11100. fields = append(fields, contact.FieldGname)
  11101. }
  11102. if m.v3 != nil {
  11103. fields = append(fields, contact.FieldV3)
  11104. }
  11105. if m.organization_id != nil {
  11106. fields = append(fields, contact.FieldOrganizationID)
  11107. }
  11108. if m.ctype != nil {
  11109. fields = append(fields, contact.FieldCtype)
  11110. }
  11111. if m.cage != nil {
  11112. fields = append(fields, contact.FieldCage)
  11113. }
  11114. if m.cname != nil {
  11115. fields = append(fields, contact.FieldCname)
  11116. }
  11117. if m.carea != nil {
  11118. fields = append(fields, contact.FieldCarea)
  11119. }
  11120. if m.cbirthday != nil {
  11121. fields = append(fields, contact.FieldCbirthday)
  11122. }
  11123. if m.cbirtharea != nil {
  11124. fields = append(fields, contact.FieldCbirtharea)
  11125. }
  11126. if m.cidcard_no != nil {
  11127. fields = append(fields, contact.FieldCidcardNo)
  11128. }
  11129. if m.ctitle != nil {
  11130. fields = append(fields, contact.FieldCtitle)
  11131. }
  11132. if m.cc != nil {
  11133. fields = append(fields, contact.FieldCc)
  11134. }
  11135. if m.phone != nil {
  11136. fields = append(fields, contact.FieldPhone)
  11137. }
  11138. return fields
  11139. }
  11140. // Field returns the value of a field with the given name. The second boolean
  11141. // return value indicates that this field was not set, or was not defined in the
  11142. // schema.
  11143. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  11144. switch name {
  11145. case contact.FieldCreatedAt:
  11146. return m.CreatedAt()
  11147. case contact.FieldUpdatedAt:
  11148. return m.UpdatedAt()
  11149. case contact.FieldStatus:
  11150. return m.Status()
  11151. case contact.FieldDeletedAt:
  11152. return m.DeletedAt()
  11153. case contact.FieldWxWxid:
  11154. return m.WxWxid()
  11155. case contact.FieldType:
  11156. return m.GetType()
  11157. case contact.FieldWxid:
  11158. return m.Wxid()
  11159. case contact.FieldAccount:
  11160. return m.Account()
  11161. case contact.FieldNickname:
  11162. return m.Nickname()
  11163. case contact.FieldMarkname:
  11164. return m.Markname()
  11165. case contact.FieldHeadimg:
  11166. return m.Headimg()
  11167. case contact.FieldSex:
  11168. return m.Sex()
  11169. case contact.FieldStarrole:
  11170. return m.Starrole()
  11171. case contact.FieldDontseeit:
  11172. return m.Dontseeit()
  11173. case contact.FieldDontseeme:
  11174. return m.Dontseeme()
  11175. case contact.FieldLag:
  11176. return m.Lag()
  11177. case contact.FieldGid:
  11178. return m.Gid()
  11179. case contact.FieldGname:
  11180. return m.Gname()
  11181. case contact.FieldV3:
  11182. return m.V3()
  11183. case contact.FieldOrganizationID:
  11184. return m.OrganizationID()
  11185. case contact.FieldCtype:
  11186. return m.Ctype()
  11187. case contact.FieldCage:
  11188. return m.Cage()
  11189. case contact.FieldCname:
  11190. return m.Cname()
  11191. case contact.FieldCarea:
  11192. return m.Carea()
  11193. case contact.FieldCbirthday:
  11194. return m.Cbirthday()
  11195. case contact.FieldCbirtharea:
  11196. return m.Cbirtharea()
  11197. case contact.FieldCidcardNo:
  11198. return m.CidcardNo()
  11199. case contact.FieldCtitle:
  11200. return m.Ctitle()
  11201. case contact.FieldCc:
  11202. return m.Cc()
  11203. case contact.FieldPhone:
  11204. return m.Phone()
  11205. }
  11206. return nil, false
  11207. }
  11208. // OldField returns the old value of the field from the database. An error is
  11209. // returned if the mutation operation is not UpdateOne, or the query to the
  11210. // database failed.
  11211. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11212. switch name {
  11213. case contact.FieldCreatedAt:
  11214. return m.OldCreatedAt(ctx)
  11215. case contact.FieldUpdatedAt:
  11216. return m.OldUpdatedAt(ctx)
  11217. case contact.FieldStatus:
  11218. return m.OldStatus(ctx)
  11219. case contact.FieldDeletedAt:
  11220. return m.OldDeletedAt(ctx)
  11221. case contact.FieldWxWxid:
  11222. return m.OldWxWxid(ctx)
  11223. case contact.FieldType:
  11224. return m.OldType(ctx)
  11225. case contact.FieldWxid:
  11226. return m.OldWxid(ctx)
  11227. case contact.FieldAccount:
  11228. return m.OldAccount(ctx)
  11229. case contact.FieldNickname:
  11230. return m.OldNickname(ctx)
  11231. case contact.FieldMarkname:
  11232. return m.OldMarkname(ctx)
  11233. case contact.FieldHeadimg:
  11234. return m.OldHeadimg(ctx)
  11235. case contact.FieldSex:
  11236. return m.OldSex(ctx)
  11237. case contact.FieldStarrole:
  11238. return m.OldStarrole(ctx)
  11239. case contact.FieldDontseeit:
  11240. return m.OldDontseeit(ctx)
  11241. case contact.FieldDontseeme:
  11242. return m.OldDontseeme(ctx)
  11243. case contact.FieldLag:
  11244. return m.OldLag(ctx)
  11245. case contact.FieldGid:
  11246. return m.OldGid(ctx)
  11247. case contact.FieldGname:
  11248. return m.OldGname(ctx)
  11249. case contact.FieldV3:
  11250. return m.OldV3(ctx)
  11251. case contact.FieldOrganizationID:
  11252. return m.OldOrganizationID(ctx)
  11253. case contact.FieldCtype:
  11254. return m.OldCtype(ctx)
  11255. case contact.FieldCage:
  11256. return m.OldCage(ctx)
  11257. case contact.FieldCname:
  11258. return m.OldCname(ctx)
  11259. case contact.FieldCarea:
  11260. return m.OldCarea(ctx)
  11261. case contact.FieldCbirthday:
  11262. return m.OldCbirthday(ctx)
  11263. case contact.FieldCbirtharea:
  11264. return m.OldCbirtharea(ctx)
  11265. case contact.FieldCidcardNo:
  11266. return m.OldCidcardNo(ctx)
  11267. case contact.FieldCtitle:
  11268. return m.OldCtitle(ctx)
  11269. case contact.FieldCc:
  11270. return m.OldCc(ctx)
  11271. case contact.FieldPhone:
  11272. return m.OldPhone(ctx)
  11273. }
  11274. return nil, fmt.Errorf("unknown Contact field %s", name)
  11275. }
  11276. // SetField sets the value of a field with the given name. It returns an error if
  11277. // the field is not defined in the schema, or if the type mismatched the field
  11278. // type.
  11279. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  11280. switch name {
  11281. case contact.FieldCreatedAt:
  11282. v, ok := value.(time.Time)
  11283. if !ok {
  11284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11285. }
  11286. m.SetCreatedAt(v)
  11287. return nil
  11288. case contact.FieldUpdatedAt:
  11289. v, ok := value.(time.Time)
  11290. if !ok {
  11291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11292. }
  11293. m.SetUpdatedAt(v)
  11294. return nil
  11295. case contact.FieldStatus:
  11296. v, ok := value.(uint8)
  11297. if !ok {
  11298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11299. }
  11300. m.SetStatus(v)
  11301. return nil
  11302. case contact.FieldDeletedAt:
  11303. v, ok := value.(time.Time)
  11304. if !ok {
  11305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11306. }
  11307. m.SetDeletedAt(v)
  11308. return nil
  11309. case contact.FieldWxWxid:
  11310. v, ok := value.(string)
  11311. if !ok {
  11312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11313. }
  11314. m.SetWxWxid(v)
  11315. return nil
  11316. case contact.FieldType:
  11317. v, ok := value.(int)
  11318. if !ok {
  11319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11320. }
  11321. m.SetType(v)
  11322. return nil
  11323. case contact.FieldWxid:
  11324. v, ok := value.(string)
  11325. if !ok {
  11326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11327. }
  11328. m.SetWxid(v)
  11329. return nil
  11330. case contact.FieldAccount:
  11331. v, ok := value.(string)
  11332. if !ok {
  11333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11334. }
  11335. m.SetAccount(v)
  11336. return nil
  11337. case contact.FieldNickname:
  11338. v, ok := value.(string)
  11339. if !ok {
  11340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11341. }
  11342. m.SetNickname(v)
  11343. return nil
  11344. case contact.FieldMarkname:
  11345. v, ok := value.(string)
  11346. if !ok {
  11347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11348. }
  11349. m.SetMarkname(v)
  11350. return nil
  11351. case contact.FieldHeadimg:
  11352. v, ok := value.(string)
  11353. if !ok {
  11354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11355. }
  11356. m.SetHeadimg(v)
  11357. return nil
  11358. case contact.FieldSex:
  11359. v, ok := value.(int)
  11360. if !ok {
  11361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11362. }
  11363. m.SetSex(v)
  11364. return nil
  11365. case contact.FieldStarrole:
  11366. v, ok := value.(string)
  11367. if !ok {
  11368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11369. }
  11370. m.SetStarrole(v)
  11371. return nil
  11372. case contact.FieldDontseeit:
  11373. v, ok := value.(int)
  11374. if !ok {
  11375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11376. }
  11377. m.SetDontseeit(v)
  11378. return nil
  11379. case contact.FieldDontseeme:
  11380. v, ok := value.(int)
  11381. if !ok {
  11382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11383. }
  11384. m.SetDontseeme(v)
  11385. return nil
  11386. case contact.FieldLag:
  11387. v, ok := value.(string)
  11388. if !ok {
  11389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11390. }
  11391. m.SetLag(v)
  11392. return nil
  11393. case contact.FieldGid:
  11394. v, ok := value.(string)
  11395. if !ok {
  11396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11397. }
  11398. m.SetGid(v)
  11399. return nil
  11400. case contact.FieldGname:
  11401. v, ok := value.(string)
  11402. if !ok {
  11403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11404. }
  11405. m.SetGname(v)
  11406. return nil
  11407. case contact.FieldV3:
  11408. v, ok := value.(string)
  11409. if !ok {
  11410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11411. }
  11412. m.SetV3(v)
  11413. return nil
  11414. case contact.FieldOrganizationID:
  11415. v, ok := value.(uint64)
  11416. if !ok {
  11417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11418. }
  11419. m.SetOrganizationID(v)
  11420. return nil
  11421. case contact.FieldCtype:
  11422. v, ok := value.(uint64)
  11423. if !ok {
  11424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11425. }
  11426. m.SetCtype(v)
  11427. return nil
  11428. case contact.FieldCage:
  11429. v, ok := value.(int)
  11430. if !ok {
  11431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11432. }
  11433. m.SetCage(v)
  11434. return nil
  11435. case contact.FieldCname:
  11436. v, ok := value.(string)
  11437. if !ok {
  11438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11439. }
  11440. m.SetCname(v)
  11441. return nil
  11442. case contact.FieldCarea:
  11443. v, ok := value.(string)
  11444. if !ok {
  11445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11446. }
  11447. m.SetCarea(v)
  11448. return nil
  11449. case contact.FieldCbirthday:
  11450. v, ok := value.(string)
  11451. if !ok {
  11452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11453. }
  11454. m.SetCbirthday(v)
  11455. return nil
  11456. case contact.FieldCbirtharea:
  11457. v, ok := value.(string)
  11458. if !ok {
  11459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11460. }
  11461. m.SetCbirtharea(v)
  11462. return nil
  11463. case contact.FieldCidcardNo:
  11464. v, ok := value.(string)
  11465. if !ok {
  11466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11467. }
  11468. m.SetCidcardNo(v)
  11469. return nil
  11470. case contact.FieldCtitle:
  11471. v, ok := value.(string)
  11472. if !ok {
  11473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11474. }
  11475. m.SetCtitle(v)
  11476. return nil
  11477. case contact.FieldCc:
  11478. v, ok := value.(string)
  11479. if !ok {
  11480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11481. }
  11482. m.SetCc(v)
  11483. return nil
  11484. case contact.FieldPhone:
  11485. v, ok := value.(string)
  11486. if !ok {
  11487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11488. }
  11489. m.SetPhone(v)
  11490. return nil
  11491. }
  11492. return fmt.Errorf("unknown Contact field %s", name)
  11493. }
  11494. // AddedFields returns all numeric fields that were incremented/decremented during
  11495. // this mutation.
  11496. func (m *ContactMutation) AddedFields() []string {
  11497. var fields []string
  11498. if m.addstatus != nil {
  11499. fields = append(fields, contact.FieldStatus)
  11500. }
  11501. if m.add_type != nil {
  11502. fields = append(fields, contact.FieldType)
  11503. }
  11504. if m.addsex != nil {
  11505. fields = append(fields, contact.FieldSex)
  11506. }
  11507. if m.adddontseeit != nil {
  11508. fields = append(fields, contact.FieldDontseeit)
  11509. }
  11510. if m.adddontseeme != nil {
  11511. fields = append(fields, contact.FieldDontseeme)
  11512. }
  11513. if m.addorganization_id != nil {
  11514. fields = append(fields, contact.FieldOrganizationID)
  11515. }
  11516. if m.addctype != nil {
  11517. fields = append(fields, contact.FieldCtype)
  11518. }
  11519. if m.addcage != nil {
  11520. fields = append(fields, contact.FieldCage)
  11521. }
  11522. return fields
  11523. }
  11524. // AddedField returns the numeric value that was incremented/decremented on a field
  11525. // with the given name. The second boolean return value indicates that this field
  11526. // was not set, or was not defined in the schema.
  11527. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11528. switch name {
  11529. case contact.FieldStatus:
  11530. return m.AddedStatus()
  11531. case contact.FieldType:
  11532. return m.AddedType()
  11533. case contact.FieldSex:
  11534. return m.AddedSex()
  11535. case contact.FieldDontseeit:
  11536. return m.AddedDontseeit()
  11537. case contact.FieldDontseeme:
  11538. return m.AddedDontseeme()
  11539. case contact.FieldOrganizationID:
  11540. return m.AddedOrganizationID()
  11541. case contact.FieldCtype:
  11542. return m.AddedCtype()
  11543. case contact.FieldCage:
  11544. return m.AddedCage()
  11545. }
  11546. return nil, false
  11547. }
  11548. // AddField adds the value to the field with the given name. It returns an error if
  11549. // the field is not defined in the schema, or if the type mismatched the field
  11550. // type.
  11551. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11552. switch name {
  11553. case contact.FieldStatus:
  11554. v, ok := value.(int8)
  11555. if !ok {
  11556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11557. }
  11558. m.AddStatus(v)
  11559. return nil
  11560. case contact.FieldType:
  11561. v, ok := value.(int)
  11562. if !ok {
  11563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11564. }
  11565. m.AddType(v)
  11566. return nil
  11567. case contact.FieldSex:
  11568. v, ok := value.(int)
  11569. if !ok {
  11570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11571. }
  11572. m.AddSex(v)
  11573. return nil
  11574. case contact.FieldDontseeit:
  11575. v, ok := value.(int)
  11576. if !ok {
  11577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11578. }
  11579. m.AddDontseeit(v)
  11580. return nil
  11581. case contact.FieldDontseeme:
  11582. v, ok := value.(int)
  11583. if !ok {
  11584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11585. }
  11586. m.AddDontseeme(v)
  11587. return nil
  11588. case contact.FieldOrganizationID:
  11589. v, ok := value.(int64)
  11590. if !ok {
  11591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11592. }
  11593. m.AddOrganizationID(v)
  11594. return nil
  11595. case contact.FieldCtype:
  11596. v, ok := value.(int64)
  11597. if !ok {
  11598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11599. }
  11600. m.AddCtype(v)
  11601. return nil
  11602. case contact.FieldCage:
  11603. v, ok := value.(int)
  11604. if !ok {
  11605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11606. }
  11607. m.AddCage(v)
  11608. return nil
  11609. }
  11610. return fmt.Errorf("unknown Contact numeric field %s", name)
  11611. }
  11612. // ClearedFields returns all nullable fields that were cleared during this
  11613. // mutation.
  11614. func (m *ContactMutation) ClearedFields() []string {
  11615. var fields []string
  11616. if m.FieldCleared(contact.FieldStatus) {
  11617. fields = append(fields, contact.FieldStatus)
  11618. }
  11619. if m.FieldCleared(contact.FieldDeletedAt) {
  11620. fields = append(fields, contact.FieldDeletedAt)
  11621. }
  11622. if m.FieldCleared(contact.FieldType) {
  11623. fields = append(fields, contact.FieldType)
  11624. }
  11625. if m.FieldCleared(contact.FieldOrganizationID) {
  11626. fields = append(fields, contact.FieldOrganizationID)
  11627. }
  11628. return fields
  11629. }
  11630. // FieldCleared returns a boolean indicating if a field with the given name was
  11631. // cleared in this mutation.
  11632. func (m *ContactMutation) FieldCleared(name string) bool {
  11633. _, ok := m.clearedFields[name]
  11634. return ok
  11635. }
  11636. // ClearField clears the value of the field with the given name. It returns an
  11637. // error if the field is not defined in the schema.
  11638. func (m *ContactMutation) ClearField(name string) error {
  11639. switch name {
  11640. case contact.FieldStatus:
  11641. m.ClearStatus()
  11642. return nil
  11643. case contact.FieldDeletedAt:
  11644. m.ClearDeletedAt()
  11645. return nil
  11646. case contact.FieldType:
  11647. m.ClearType()
  11648. return nil
  11649. case contact.FieldOrganizationID:
  11650. m.ClearOrganizationID()
  11651. return nil
  11652. }
  11653. return fmt.Errorf("unknown Contact nullable field %s", name)
  11654. }
  11655. // ResetField resets all changes in the mutation for the field with the given name.
  11656. // It returns an error if the field is not defined in the schema.
  11657. func (m *ContactMutation) ResetField(name string) error {
  11658. switch name {
  11659. case contact.FieldCreatedAt:
  11660. m.ResetCreatedAt()
  11661. return nil
  11662. case contact.FieldUpdatedAt:
  11663. m.ResetUpdatedAt()
  11664. return nil
  11665. case contact.FieldStatus:
  11666. m.ResetStatus()
  11667. return nil
  11668. case contact.FieldDeletedAt:
  11669. m.ResetDeletedAt()
  11670. return nil
  11671. case contact.FieldWxWxid:
  11672. m.ResetWxWxid()
  11673. return nil
  11674. case contact.FieldType:
  11675. m.ResetType()
  11676. return nil
  11677. case contact.FieldWxid:
  11678. m.ResetWxid()
  11679. return nil
  11680. case contact.FieldAccount:
  11681. m.ResetAccount()
  11682. return nil
  11683. case contact.FieldNickname:
  11684. m.ResetNickname()
  11685. return nil
  11686. case contact.FieldMarkname:
  11687. m.ResetMarkname()
  11688. return nil
  11689. case contact.FieldHeadimg:
  11690. m.ResetHeadimg()
  11691. return nil
  11692. case contact.FieldSex:
  11693. m.ResetSex()
  11694. return nil
  11695. case contact.FieldStarrole:
  11696. m.ResetStarrole()
  11697. return nil
  11698. case contact.FieldDontseeit:
  11699. m.ResetDontseeit()
  11700. return nil
  11701. case contact.FieldDontseeme:
  11702. m.ResetDontseeme()
  11703. return nil
  11704. case contact.FieldLag:
  11705. m.ResetLag()
  11706. return nil
  11707. case contact.FieldGid:
  11708. m.ResetGid()
  11709. return nil
  11710. case contact.FieldGname:
  11711. m.ResetGname()
  11712. return nil
  11713. case contact.FieldV3:
  11714. m.ResetV3()
  11715. return nil
  11716. case contact.FieldOrganizationID:
  11717. m.ResetOrganizationID()
  11718. return nil
  11719. case contact.FieldCtype:
  11720. m.ResetCtype()
  11721. return nil
  11722. case contact.FieldCage:
  11723. m.ResetCage()
  11724. return nil
  11725. case contact.FieldCname:
  11726. m.ResetCname()
  11727. return nil
  11728. case contact.FieldCarea:
  11729. m.ResetCarea()
  11730. return nil
  11731. case contact.FieldCbirthday:
  11732. m.ResetCbirthday()
  11733. return nil
  11734. case contact.FieldCbirtharea:
  11735. m.ResetCbirtharea()
  11736. return nil
  11737. case contact.FieldCidcardNo:
  11738. m.ResetCidcardNo()
  11739. return nil
  11740. case contact.FieldCtitle:
  11741. m.ResetCtitle()
  11742. return nil
  11743. case contact.FieldCc:
  11744. m.ResetCc()
  11745. return nil
  11746. case contact.FieldPhone:
  11747. m.ResetPhone()
  11748. return nil
  11749. }
  11750. return fmt.Errorf("unknown Contact field %s", name)
  11751. }
  11752. // AddedEdges returns all edge names that were set/added in this mutation.
  11753. func (m *ContactMutation) AddedEdges() []string {
  11754. edges := make([]string, 0, 3)
  11755. if m.contact_relationships != nil {
  11756. edges = append(edges, contact.EdgeContactRelationships)
  11757. }
  11758. if m.contact_fields != nil {
  11759. edges = append(edges, contact.EdgeContactFields)
  11760. }
  11761. if m.contact_messages != nil {
  11762. edges = append(edges, contact.EdgeContactMessages)
  11763. }
  11764. return edges
  11765. }
  11766. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11767. // name in this mutation.
  11768. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11769. switch name {
  11770. case contact.EdgeContactRelationships:
  11771. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11772. for id := range m.contact_relationships {
  11773. ids = append(ids, id)
  11774. }
  11775. return ids
  11776. case contact.EdgeContactFields:
  11777. ids := make([]ent.Value, 0, len(m.contact_fields))
  11778. for id := range m.contact_fields {
  11779. ids = append(ids, id)
  11780. }
  11781. return ids
  11782. case contact.EdgeContactMessages:
  11783. ids := make([]ent.Value, 0, len(m.contact_messages))
  11784. for id := range m.contact_messages {
  11785. ids = append(ids, id)
  11786. }
  11787. return ids
  11788. }
  11789. return nil
  11790. }
  11791. // RemovedEdges returns all edge names that were removed in this mutation.
  11792. func (m *ContactMutation) RemovedEdges() []string {
  11793. edges := make([]string, 0, 3)
  11794. if m.removedcontact_relationships != nil {
  11795. edges = append(edges, contact.EdgeContactRelationships)
  11796. }
  11797. if m.removedcontact_fields != nil {
  11798. edges = append(edges, contact.EdgeContactFields)
  11799. }
  11800. if m.removedcontact_messages != nil {
  11801. edges = append(edges, contact.EdgeContactMessages)
  11802. }
  11803. return edges
  11804. }
  11805. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11806. // the given name in this mutation.
  11807. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11808. switch name {
  11809. case contact.EdgeContactRelationships:
  11810. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11811. for id := range m.removedcontact_relationships {
  11812. ids = append(ids, id)
  11813. }
  11814. return ids
  11815. case contact.EdgeContactFields:
  11816. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  11817. for id := range m.removedcontact_fields {
  11818. ids = append(ids, id)
  11819. }
  11820. return ids
  11821. case contact.EdgeContactMessages:
  11822. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11823. for id := range m.removedcontact_messages {
  11824. ids = append(ids, id)
  11825. }
  11826. return ids
  11827. }
  11828. return nil
  11829. }
  11830. // ClearedEdges returns all edge names that were cleared in this mutation.
  11831. func (m *ContactMutation) ClearedEdges() []string {
  11832. edges := make([]string, 0, 3)
  11833. if m.clearedcontact_relationships {
  11834. edges = append(edges, contact.EdgeContactRelationships)
  11835. }
  11836. if m.clearedcontact_fields {
  11837. edges = append(edges, contact.EdgeContactFields)
  11838. }
  11839. if m.clearedcontact_messages {
  11840. edges = append(edges, contact.EdgeContactMessages)
  11841. }
  11842. return edges
  11843. }
  11844. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11845. // was cleared in this mutation.
  11846. func (m *ContactMutation) EdgeCleared(name string) bool {
  11847. switch name {
  11848. case contact.EdgeContactRelationships:
  11849. return m.clearedcontact_relationships
  11850. case contact.EdgeContactFields:
  11851. return m.clearedcontact_fields
  11852. case contact.EdgeContactMessages:
  11853. return m.clearedcontact_messages
  11854. }
  11855. return false
  11856. }
  11857. // ClearEdge clears the value of the edge with the given name. It returns an error
  11858. // if that edge is not defined in the schema.
  11859. func (m *ContactMutation) ClearEdge(name string) error {
  11860. switch name {
  11861. }
  11862. return fmt.Errorf("unknown Contact unique edge %s", name)
  11863. }
  11864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11865. // It returns an error if the edge is not defined in the schema.
  11866. func (m *ContactMutation) ResetEdge(name string) error {
  11867. switch name {
  11868. case contact.EdgeContactRelationships:
  11869. m.ResetContactRelationships()
  11870. return nil
  11871. case contact.EdgeContactFields:
  11872. m.ResetContactFields()
  11873. return nil
  11874. case contact.EdgeContactMessages:
  11875. m.ResetContactMessages()
  11876. return nil
  11877. }
  11878. return fmt.Errorf("unknown Contact edge %s", name)
  11879. }
  11880. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  11881. type ContactFieldMutation struct {
  11882. config
  11883. op Op
  11884. typ string
  11885. id *uint64
  11886. created_at *time.Time
  11887. updated_at *time.Time
  11888. status *uint8
  11889. addstatus *int8
  11890. deleted_at *time.Time
  11891. form_id *string
  11892. value *[]string
  11893. appendvalue []string
  11894. clearedFields map[string]struct{}
  11895. field_contact *uint64
  11896. clearedfield_contact bool
  11897. done bool
  11898. oldValue func(context.Context) (*ContactField, error)
  11899. predicates []predicate.ContactField
  11900. }
  11901. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  11902. // contactfieldOption allows management of the mutation configuration using functional options.
  11903. type contactfieldOption func(*ContactFieldMutation)
  11904. // newContactFieldMutation creates new mutation for the ContactField entity.
  11905. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  11906. m := &ContactFieldMutation{
  11907. config: c,
  11908. op: op,
  11909. typ: TypeContactField,
  11910. clearedFields: make(map[string]struct{}),
  11911. }
  11912. for _, opt := range opts {
  11913. opt(m)
  11914. }
  11915. return m
  11916. }
  11917. // withContactFieldID sets the ID field of the mutation.
  11918. func withContactFieldID(id uint64) contactfieldOption {
  11919. return func(m *ContactFieldMutation) {
  11920. var (
  11921. err error
  11922. once sync.Once
  11923. value *ContactField
  11924. )
  11925. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  11926. once.Do(func() {
  11927. if m.done {
  11928. err = errors.New("querying old values post mutation is not allowed")
  11929. } else {
  11930. value, err = m.Client().ContactField.Get(ctx, id)
  11931. }
  11932. })
  11933. return value, err
  11934. }
  11935. m.id = &id
  11936. }
  11937. }
  11938. // withContactField sets the old ContactField of the mutation.
  11939. func withContactField(node *ContactField) contactfieldOption {
  11940. return func(m *ContactFieldMutation) {
  11941. m.oldValue = func(context.Context) (*ContactField, error) {
  11942. return node, nil
  11943. }
  11944. m.id = &node.ID
  11945. }
  11946. }
  11947. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11948. // executed in a transaction (ent.Tx), a transactional client is returned.
  11949. func (m ContactFieldMutation) Client() *Client {
  11950. client := &Client{config: m.config}
  11951. client.init()
  11952. return client
  11953. }
  11954. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11955. // it returns an error otherwise.
  11956. func (m ContactFieldMutation) Tx() (*Tx, error) {
  11957. if _, ok := m.driver.(*txDriver); !ok {
  11958. return nil, errors.New("ent: mutation is not running in a transaction")
  11959. }
  11960. tx := &Tx{config: m.config}
  11961. tx.init()
  11962. return tx, nil
  11963. }
  11964. // SetID sets the value of the id field. Note that this
  11965. // operation is only accepted on creation of ContactField entities.
  11966. func (m *ContactFieldMutation) SetID(id uint64) {
  11967. m.id = &id
  11968. }
  11969. // ID returns the ID value in the mutation. Note that the ID is only available
  11970. // if it was provided to the builder or after it was returned from the database.
  11971. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  11972. if m.id == nil {
  11973. return
  11974. }
  11975. return *m.id, true
  11976. }
  11977. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11978. // That means, if the mutation is applied within a transaction with an isolation level such
  11979. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11980. // or updated by the mutation.
  11981. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  11982. switch {
  11983. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11984. id, exists := m.ID()
  11985. if exists {
  11986. return []uint64{id}, nil
  11987. }
  11988. fallthrough
  11989. case m.op.Is(OpUpdate | OpDelete):
  11990. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  11991. default:
  11992. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11993. }
  11994. }
  11995. // SetCreatedAt sets the "created_at" field.
  11996. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  11997. m.created_at = &t
  11998. }
  11999. // CreatedAt returns the value of the "created_at" field in the mutation.
  12000. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  12001. v := m.created_at
  12002. if v == nil {
  12003. return
  12004. }
  12005. return *v, true
  12006. }
  12007. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  12008. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12010. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12011. if !m.op.Is(OpUpdateOne) {
  12012. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12013. }
  12014. if m.id == nil || m.oldValue == nil {
  12015. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12016. }
  12017. oldValue, err := m.oldValue(ctx)
  12018. if err != nil {
  12019. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12020. }
  12021. return oldValue.CreatedAt, nil
  12022. }
  12023. // ResetCreatedAt resets all changes to the "created_at" field.
  12024. func (m *ContactFieldMutation) ResetCreatedAt() {
  12025. m.created_at = nil
  12026. }
  12027. // SetUpdatedAt sets the "updated_at" field.
  12028. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  12029. m.updated_at = &t
  12030. }
  12031. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12032. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  12033. v := m.updated_at
  12034. if v == nil {
  12035. return
  12036. }
  12037. return *v, true
  12038. }
  12039. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  12040. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12042. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12043. if !m.op.Is(OpUpdateOne) {
  12044. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12045. }
  12046. if m.id == nil || m.oldValue == nil {
  12047. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12048. }
  12049. oldValue, err := m.oldValue(ctx)
  12050. if err != nil {
  12051. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12052. }
  12053. return oldValue.UpdatedAt, nil
  12054. }
  12055. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12056. func (m *ContactFieldMutation) ResetUpdatedAt() {
  12057. m.updated_at = nil
  12058. }
  12059. // SetStatus sets the "status" field.
  12060. func (m *ContactFieldMutation) SetStatus(u uint8) {
  12061. m.status = &u
  12062. m.addstatus = nil
  12063. }
  12064. // Status returns the value of the "status" field in the mutation.
  12065. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  12066. v := m.status
  12067. if v == nil {
  12068. return
  12069. }
  12070. return *v, true
  12071. }
  12072. // OldStatus returns the old "status" field's value of the ContactField entity.
  12073. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12075. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12076. if !m.op.Is(OpUpdateOne) {
  12077. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12078. }
  12079. if m.id == nil || m.oldValue == nil {
  12080. return v, errors.New("OldStatus requires an ID field in the mutation")
  12081. }
  12082. oldValue, err := m.oldValue(ctx)
  12083. if err != nil {
  12084. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12085. }
  12086. return oldValue.Status, nil
  12087. }
  12088. // AddStatus adds u to the "status" field.
  12089. func (m *ContactFieldMutation) AddStatus(u int8) {
  12090. if m.addstatus != nil {
  12091. *m.addstatus += u
  12092. } else {
  12093. m.addstatus = &u
  12094. }
  12095. }
  12096. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12097. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  12098. v := m.addstatus
  12099. if v == nil {
  12100. return
  12101. }
  12102. return *v, true
  12103. }
  12104. // ClearStatus clears the value of the "status" field.
  12105. func (m *ContactFieldMutation) ClearStatus() {
  12106. m.status = nil
  12107. m.addstatus = nil
  12108. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  12109. }
  12110. // StatusCleared returns if the "status" field was cleared in this mutation.
  12111. func (m *ContactFieldMutation) StatusCleared() bool {
  12112. _, ok := m.clearedFields[contactfield.FieldStatus]
  12113. return ok
  12114. }
  12115. // ResetStatus resets all changes to the "status" field.
  12116. func (m *ContactFieldMutation) ResetStatus() {
  12117. m.status = nil
  12118. m.addstatus = nil
  12119. delete(m.clearedFields, contactfield.FieldStatus)
  12120. }
  12121. // SetDeletedAt sets the "deleted_at" field.
  12122. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  12123. m.deleted_at = &t
  12124. }
  12125. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12126. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  12127. v := m.deleted_at
  12128. if v == nil {
  12129. return
  12130. }
  12131. return *v, true
  12132. }
  12133. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  12134. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12136. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12137. if !m.op.Is(OpUpdateOne) {
  12138. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12139. }
  12140. if m.id == nil || m.oldValue == nil {
  12141. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12142. }
  12143. oldValue, err := m.oldValue(ctx)
  12144. if err != nil {
  12145. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12146. }
  12147. return oldValue.DeletedAt, nil
  12148. }
  12149. // ClearDeletedAt clears the value of the "deleted_at" field.
  12150. func (m *ContactFieldMutation) ClearDeletedAt() {
  12151. m.deleted_at = nil
  12152. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  12153. }
  12154. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12155. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  12156. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  12157. return ok
  12158. }
  12159. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12160. func (m *ContactFieldMutation) ResetDeletedAt() {
  12161. m.deleted_at = nil
  12162. delete(m.clearedFields, contactfield.FieldDeletedAt)
  12163. }
  12164. // SetContactID sets the "contact_id" field.
  12165. func (m *ContactFieldMutation) SetContactID(u uint64) {
  12166. m.field_contact = &u
  12167. }
  12168. // ContactID returns the value of the "contact_id" field in the mutation.
  12169. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  12170. v := m.field_contact
  12171. if v == nil {
  12172. return
  12173. }
  12174. return *v, true
  12175. }
  12176. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  12177. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12179. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12180. if !m.op.Is(OpUpdateOne) {
  12181. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12182. }
  12183. if m.id == nil || m.oldValue == nil {
  12184. return v, errors.New("OldContactID requires an ID field in the mutation")
  12185. }
  12186. oldValue, err := m.oldValue(ctx)
  12187. if err != nil {
  12188. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12189. }
  12190. return oldValue.ContactID, nil
  12191. }
  12192. // ResetContactID resets all changes to the "contact_id" field.
  12193. func (m *ContactFieldMutation) ResetContactID() {
  12194. m.field_contact = nil
  12195. }
  12196. // SetFormID sets the "form_id" field.
  12197. func (m *ContactFieldMutation) SetFormID(s string) {
  12198. m.form_id = &s
  12199. }
  12200. // FormID returns the value of the "form_id" field in the mutation.
  12201. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  12202. v := m.form_id
  12203. if v == nil {
  12204. return
  12205. }
  12206. return *v, true
  12207. }
  12208. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  12209. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12211. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  12212. if !m.op.Is(OpUpdateOne) {
  12213. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  12214. }
  12215. if m.id == nil || m.oldValue == nil {
  12216. return v, errors.New("OldFormID requires an ID field in the mutation")
  12217. }
  12218. oldValue, err := m.oldValue(ctx)
  12219. if err != nil {
  12220. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  12221. }
  12222. return oldValue.FormID, nil
  12223. }
  12224. // ResetFormID resets all changes to the "form_id" field.
  12225. func (m *ContactFieldMutation) ResetFormID() {
  12226. m.form_id = nil
  12227. }
  12228. // SetValue sets the "value" field.
  12229. func (m *ContactFieldMutation) SetValue(s []string) {
  12230. m.value = &s
  12231. m.appendvalue = nil
  12232. }
  12233. // Value returns the value of the "value" field in the mutation.
  12234. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  12235. v := m.value
  12236. if v == nil {
  12237. return
  12238. }
  12239. return *v, true
  12240. }
  12241. // OldValue returns the old "value" field's value of the ContactField entity.
  12242. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  12243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12244. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  12245. if !m.op.Is(OpUpdateOne) {
  12246. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  12247. }
  12248. if m.id == nil || m.oldValue == nil {
  12249. return v, errors.New("OldValue requires an ID field in the mutation")
  12250. }
  12251. oldValue, err := m.oldValue(ctx)
  12252. if err != nil {
  12253. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  12254. }
  12255. return oldValue.Value, nil
  12256. }
  12257. // AppendValue adds s to the "value" field.
  12258. func (m *ContactFieldMutation) AppendValue(s []string) {
  12259. m.appendvalue = append(m.appendvalue, s...)
  12260. }
  12261. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  12262. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  12263. if len(m.appendvalue) == 0 {
  12264. return nil, false
  12265. }
  12266. return m.appendvalue, true
  12267. }
  12268. // ResetValue resets all changes to the "value" field.
  12269. func (m *ContactFieldMutation) ResetValue() {
  12270. m.value = nil
  12271. m.appendvalue = nil
  12272. }
  12273. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  12274. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  12275. m.field_contact = &id
  12276. }
  12277. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  12278. func (m *ContactFieldMutation) ClearFieldContact() {
  12279. m.clearedfield_contact = true
  12280. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  12281. }
  12282. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  12283. func (m *ContactFieldMutation) FieldContactCleared() bool {
  12284. return m.clearedfield_contact
  12285. }
  12286. // FieldContactID returns the "field_contact" edge ID in the mutation.
  12287. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  12288. if m.field_contact != nil {
  12289. return *m.field_contact, true
  12290. }
  12291. return
  12292. }
  12293. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  12294. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12295. // FieldContactID instead. It exists only for internal usage by the builders.
  12296. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  12297. if id := m.field_contact; id != nil {
  12298. ids = append(ids, *id)
  12299. }
  12300. return
  12301. }
  12302. // ResetFieldContact resets all changes to the "field_contact" edge.
  12303. func (m *ContactFieldMutation) ResetFieldContact() {
  12304. m.field_contact = nil
  12305. m.clearedfield_contact = false
  12306. }
  12307. // Where appends a list predicates to the ContactFieldMutation builder.
  12308. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  12309. m.predicates = append(m.predicates, ps...)
  12310. }
  12311. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  12312. // users can use type-assertion to append predicates that do not depend on any generated package.
  12313. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  12314. p := make([]predicate.ContactField, len(ps))
  12315. for i := range ps {
  12316. p[i] = ps[i]
  12317. }
  12318. m.Where(p...)
  12319. }
  12320. // Op returns the operation name.
  12321. func (m *ContactFieldMutation) Op() Op {
  12322. return m.op
  12323. }
  12324. // SetOp allows setting the mutation operation.
  12325. func (m *ContactFieldMutation) SetOp(op Op) {
  12326. m.op = op
  12327. }
  12328. // Type returns the node type of this mutation (ContactField).
  12329. func (m *ContactFieldMutation) Type() string {
  12330. return m.typ
  12331. }
  12332. // Fields returns all fields that were changed during this mutation. Note that in
  12333. // order to get all numeric fields that were incremented/decremented, call
  12334. // AddedFields().
  12335. func (m *ContactFieldMutation) Fields() []string {
  12336. fields := make([]string, 0, 7)
  12337. if m.created_at != nil {
  12338. fields = append(fields, contactfield.FieldCreatedAt)
  12339. }
  12340. if m.updated_at != nil {
  12341. fields = append(fields, contactfield.FieldUpdatedAt)
  12342. }
  12343. if m.status != nil {
  12344. fields = append(fields, contactfield.FieldStatus)
  12345. }
  12346. if m.deleted_at != nil {
  12347. fields = append(fields, contactfield.FieldDeletedAt)
  12348. }
  12349. if m.field_contact != nil {
  12350. fields = append(fields, contactfield.FieldContactID)
  12351. }
  12352. if m.form_id != nil {
  12353. fields = append(fields, contactfield.FieldFormID)
  12354. }
  12355. if m.value != nil {
  12356. fields = append(fields, contactfield.FieldValue)
  12357. }
  12358. return fields
  12359. }
  12360. // Field returns the value of a field with the given name. The second boolean
  12361. // return value indicates that this field was not set, or was not defined in the
  12362. // schema.
  12363. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  12364. switch name {
  12365. case contactfield.FieldCreatedAt:
  12366. return m.CreatedAt()
  12367. case contactfield.FieldUpdatedAt:
  12368. return m.UpdatedAt()
  12369. case contactfield.FieldStatus:
  12370. return m.Status()
  12371. case contactfield.FieldDeletedAt:
  12372. return m.DeletedAt()
  12373. case contactfield.FieldContactID:
  12374. return m.ContactID()
  12375. case contactfield.FieldFormID:
  12376. return m.FormID()
  12377. case contactfield.FieldValue:
  12378. return m.Value()
  12379. }
  12380. return nil, false
  12381. }
  12382. // OldField returns the old value of the field from the database. An error is
  12383. // returned if the mutation operation is not UpdateOne, or the query to the
  12384. // database failed.
  12385. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12386. switch name {
  12387. case contactfield.FieldCreatedAt:
  12388. return m.OldCreatedAt(ctx)
  12389. case contactfield.FieldUpdatedAt:
  12390. return m.OldUpdatedAt(ctx)
  12391. case contactfield.FieldStatus:
  12392. return m.OldStatus(ctx)
  12393. case contactfield.FieldDeletedAt:
  12394. return m.OldDeletedAt(ctx)
  12395. case contactfield.FieldContactID:
  12396. return m.OldContactID(ctx)
  12397. case contactfield.FieldFormID:
  12398. return m.OldFormID(ctx)
  12399. case contactfield.FieldValue:
  12400. return m.OldValue(ctx)
  12401. }
  12402. return nil, fmt.Errorf("unknown ContactField field %s", name)
  12403. }
  12404. // SetField sets the value of a field with the given name. It returns an error if
  12405. // the field is not defined in the schema, or if the type mismatched the field
  12406. // type.
  12407. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  12408. switch name {
  12409. case contactfield.FieldCreatedAt:
  12410. v, ok := value.(time.Time)
  12411. if !ok {
  12412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12413. }
  12414. m.SetCreatedAt(v)
  12415. return nil
  12416. case contactfield.FieldUpdatedAt:
  12417. v, ok := value.(time.Time)
  12418. if !ok {
  12419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12420. }
  12421. m.SetUpdatedAt(v)
  12422. return nil
  12423. case contactfield.FieldStatus:
  12424. v, ok := value.(uint8)
  12425. if !ok {
  12426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12427. }
  12428. m.SetStatus(v)
  12429. return nil
  12430. case contactfield.FieldDeletedAt:
  12431. v, ok := value.(time.Time)
  12432. if !ok {
  12433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12434. }
  12435. m.SetDeletedAt(v)
  12436. return nil
  12437. case contactfield.FieldContactID:
  12438. v, ok := value.(uint64)
  12439. if !ok {
  12440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12441. }
  12442. m.SetContactID(v)
  12443. return nil
  12444. case contactfield.FieldFormID:
  12445. v, ok := value.(string)
  12446. if !ok {
  12447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12448. }
  12449. m.SetFormID(v)
  12450. return nil
  12451. case contactfield.FieldValue:
  12452. v, ok := value.([]string)
  12453. if !ok {
  12454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12455. }
  12456. m.SetValue(v)
  12457. return nil
  12458. }
  12459. return fmt.Errorf("unknown ContactField field %s", name)
  12460. }
  12461. // AddedFields returns all numeric fields that were incremented/decremented during
  12462. // this mutation.
  12463. func (m *ContactFieldMutation) AddedFields() []string {
  12464. var fields []string
  12465. if m.addstatus != nil {
  12466. fields = append(fields, contactfield.FieldStatus)
  12467. }
  12468. return fields
  12469. }
  12470. // AddedField returns the numeric value that was incremented/decremented on a field
  12471. // with the given name. The second boolean return value indicates that this field
  12472. // was not set, or was not defined in the schema.
  12473. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  12474. switch name {
  12475. case contactfield.FieldStatus:
  12476. return m.AddedStatus()
  12477. }
  12478. return nil, false
  12479. }
  12480. // AddField adds the value to the field with the given name. It returns an error if
  12481. // the field is not defined in the schema, or if the type mismatched the field
  12482. // type.
  12483. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  12484. switch name {
  12485. case contactfield.FieldStatus:
  12486. v, ok := value.(int8)
  12487. if !ok {
  12488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12489. }
  12490. m.AddStatus(v)
  12491. return nil
  12492. }
  12493. return fmt.Errorf("unknown ContactField numeric field %s", name)
  12494. }
  12495. // ClearedFields returns all nullable fields that were cleared during this
  12496. // mutation.
  12497. func (m *ContactFieldMutation) ClearedFields() []string {
  12498. var fields []string
  12499. if m.FieldCleared(contactfield.FieldStatus) {
  12500. fields = append(fields, contactfield.FieldStatus)
  12501. }
  12502. if m.FieldCleared(contactfield.FieldDeletedAt) {
  12503. fields = append(fields, contactfield.FieldDeletedAt)
  12504. }
  12505. return fields
  12506. }
  12507. // FieldCleared returns a boolean indicating if a field with the given name was
  12508. // cleared in this mutation.
  12509. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  12510. _, ok := m.clearedFields[name]
  12511. return ok
  12512. }
  12513. // ClearField clears the value of the field with the given name. It returns an
  12514. // error if the field is not defined in the schema.
  12515. func (m *ContactFieldMutation) ClearField(name string) error {
  12516. switch name {
  12517. case contactfield.FieldStatus:
  12518. m.ClearStatus()
  12519. return nil
  12520. case contactfield.FieldDeletedAt:
  12521. m.ClearDeletedAt()
  12522. return nil
  12523. }
  12524. return fmt.Errorf("unknown ContactField nullable field %s", name)
  12525. }
  12526. // ResetField resets all changes in the mutation for the field with the given name.
  12527. // It returns an error if the field is not defined in the schema.
  12528. func (m *ContactFieldMutation) ResetField(name string) error {
  12529. switch name {
  12530. case contactfield.FieldCreatedAt:
  12531. m.ResetCreatedAt()
  12532. return nil
  12533. case contactfield.FieldUpdatedAt:
  12534. m.ResetUpdatedAt()
  12535. return nil
  12536. case contactfield.FieldStatus:
  12537. m.ResetStatus()
  12538. return nil
  12539. case contactfield.FieldDeletedAt:
  12540. m.ResetDeletedAt()
  12541. return nil
  12542. case contactfield.FieldContactID:
  12543. m.ResetContactID()
  12544. return nil
  12545. case contactfield.FieldFormID:
  12546. m.ResetFormID()
  12547. return nil
  12548. case contactfield.FieldValue:
  12549. m.ResetValue()
  12550. return nil
  12551. }
  12552. return fmt.Errorf("unknown ContactField field %s", name)
  12553. }
  12554. // AddedEdges returns all edge names that were set/added in this mutation.
  12555. func (m *ContactFieldMutation) AddedEdges() []string {
  12556. edges := make([]string, 0, 1)
  12557. if m.field_contact != nil {
  12558. edges = append(edges, contactfield.EdgeFieldContact)
  12559. }
  12560. return edges
  12561. }
  12562. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12563. // name in this mutation.
  12564. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  12565. switch name {
  12566. case contactfield.EdgeFieldContact:
  12567. if id := m.field_contact; id != nil {
  12568. return []ent.Value{*id}
  12569. }
  12570. }
  12571. return nil
  12572. }
  12573. // RemovedEdges returns all edge names that were removed in this mutation.
  12574. func (m *ContactFieldMutation) RemovedEdges() []string {
  12575. edges := make([]string, 0, 1)
  12576. return edges
  12577. }
  12578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12579. // the given name in this mutation.
  12580. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  12581. return nil
  12582. }
  12583. // ClearedEdges returns all edge names that were cleared in this mutation.
  12584. func (m *ContactFieldMutation) ClearedEdges() []string {
  12585. edges := make([]string, 0, 1)
  12586. if m.clearedfield_contact {
  12587. edges = append(edges, contactfield.EdgeFieldContact)
  12588. }
  12589. return edges
  12590. }
  12591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12592. // was cleared in this mutation.
  12593. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  12594. switch name {
  12595. case contactfield.EdgeFieldContact:
  12596. return m.clearedfield_contact
  12597. }
  12598. return false
  12599. }
  12600. // ClearEdge clears the value of the edge with the given name. It returns an error
  12601. // if that edge is not defined in the schema.
  12602. func (m *ContactFieldMutation) ClearEdge(name string) error {
  12603. switch name {
  12604. case contactfield.EdgeFieldContact:
  12605. m.ClearFieldContact()
  12606. return nil
  12607. }
  12608. return fmt.Errorf("unknown ContactField unique edge %s", name)
  12609. }
  12610. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12611. // It returns an error if the edge is not defined in the schema.
  12612. func (m *ContactFieldMutation) ResetEdge(name string) error {
  12613. switch name {
  12614. case contactfield.EdgeFieldContact:
  12615. m.ResetFieldContact()
  12616. return nil
  12617. }
  12618. return fmt.Errorf("unknown ContactField edge %s", name)
  12619. }
  12620. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  12621. type ContactFieldTemplateMutation struct {
  12622. config
  12623. op Op
  12624. typ string
  12625. id *uint64
  12626. created_at *time.Time
  12627. updated_at *time.Time
  12628. status *uint8
  12629. addstatus *int8
  12630. deleted_at *time.Time
  12631. organization_id *uint64
  12632. addorganization_id *int64
  12633. template *[]custom_types.ContactFieldTemplate
  12634. appendtemplate []custom_types.ContactFieldTemplate
  12635. clearedFields map[string]struct{}
  12636. done bool
  12637. oldValue func(context.Context) (*ContactFieldTemplate, error)
  12638. predicates []predicate.ContactFieldTemplate
  12639. }
  12640. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  12641. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  12642. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  12643. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  12644. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  12645. m := &ContactFieldTemplateMutation{
  12646. config: c,
  12647. op: op,
  12648. typ: TypeContactFieldTemplate,
  12649. clearedFields: make(map[string]struct{}),
  12650. }
  12651. for _, opt := range opts {
  12652. opt(m)
  12653. }
  12654. return m
  12655. }
  12656. // withContactFieldTemplateID sets the ID field of the mutation.
  12657. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  12658. return func(m *ContactFieldTemplateMutation) {
  12659. var (
  12660. err error
  12661. once sync.Once
  12662. value *ContactFieldTemplate
  12663. )
  12664. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  12665. once.Do(func() {
  12666. if m.done {
  12667. err = errors.New("querying old values post mutation is not allowed")
  12668. } else {
  12669. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  12670. }
  12671. })
  12672. return value, err
  12673. }
  12674. m.id = &id
  12675. }
  12676. }
  12677. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  12678. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  12679. return func(m *ContactFieldTemplateMutation) {
  12680. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  12681. return node, nil
  12682. }
  12683. m.id = &node.ID
  12684. }
  12685. }
  12686. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12687. // executed in a transaction (ent.Tx), a transactional client is returned.
  12688. func (m ContactFieldTemplateMutation) Client() *Client {
  12689. client := &Client{config: m.config}
  12690. client.init()
  12691. return client
  12692. }
  12693. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12694. // it returns an error otherwise.
  12695. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  12696. if _, ok := m.driver.(*txDriver); !ok {
  12697. return nil, errors.New("ent: mutation is not running in a transaction")
  12698. }
  12699. tx := &Tx{config: m.config}
  12700. tx.init()
  12701. return tx, nil
  12702. }
  12703. // SetID sets the value of the id field. Note that this
  12704. // operation is only accepted on creation of ContactFieldTemplate entities.
  12705. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  12706. m.id = &id
  12707. }
  12708. // ID returns the ID value in the mutation. Note that the ID is only available
  12709. // if it was provided to the builder or after it was returned from the database.
  12710. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  12711. if m.id == nil {
  12712. return
  12713. }
  12714. return *m.id, true
  12715. }
  12716. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12717. // That means, if the mutation is applied within a transaction with an isolation level such
  12718. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12719. // or updated by the mutation.
  12720. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  12721. switch {
  12722. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12723. id, exists := m.ID()
  12724. if exists {
  12725. return []uint64{id}, nil
  12726. }
  12727. fallthrough
  12728. case m.op.Is(OpUpdate | OpDelete):
  12729. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  12730. default:
  12731. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12732. }
  12733. }
  12734. // SetCreatedAt sets the "created_at" field.
  12735. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  12736. m.created_at = &t
  12737. }
  12738. // CreatedAt returns the value of the "created_at" field in the mutation.
  12739. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  12740. v := m.created_at
  12741. if v == nil {
  12742. return
  12743. }
  12744. return *v, true
  12745. }
  12746. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  12747. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12749. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12750. if !m.op.Is(OpUpdateOne) {
  12751. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12752. }
  12753. if m.id == nil || m.oldValue == nil {
  12754. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12755. }
  12756. oldValue, err := m.oldValue(ctx)
  12757. if err != nil {
  12758. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12759. }
  12760. return oldValue.CreatedAt, nil
  12761. }
  12762. // ResetCreatedAt resets all changes to the "created_at" field.
  12763. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  12764. m.created_at = nil
  12765. }
  12766. // SetUpdatedAt sets the "updated_at" field.
  12767. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  12768. m.updated_at = &t
  12769. }
  12770. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12771. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  12772. v := m.updated_at
  12773. if v == nil {
  12774. return
  12775. }
  12776. return *v, true
  12777. }
  12778. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  12779. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12781. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12782. if !m.op.Is(OpUpdateOne) {
  12783. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12784. }
  12785. if m.id == nil || m.oldValue == nil {
  12786. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12787. }
  12788. oldValue, err := m.oldValue(ctx)
  12789. if err != nil {
  12790. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12791. }
  12792. return oldValue.UpdatedAt, nil
  12793. }
  12794. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12795. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  12796. m.updated_at = nil
  12797. }
  12798. // SetStatus sets the "status" field.
  12799. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  12800. m.status = &u
  12801. m.addstatus = nil
  12802. }
  12803. // Status returns the value of the "status" field in the mutation.
  12804. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  12805. v := m.status
  12806. if v == nil {
  12807. return
  12808. }
  12809. return *v, true
  12810. }
  12811. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  12812. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12814. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12815. if !m.op.Is(OpUpdateOne) {
  12816. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12817. }
  12818. if m.id == nil || m.oldValue == nil {
  12819. return v, errors.New("OldStatus requires an ID field in the mutation")
  12820. }
  12821. oldValue, err := m.oldValue(ctx)
  12822. if err != nil {
  12823. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12824. }
  12825. return oldValue.Status, nil
  12826. }
  12827. // AddStatus adds u to the "status" field.
  12828. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  12829. if m.addstatus != nil {
  12830. *m.addstatus += u
  12831. } else {
  12832. m.addstatus = &u
  12833. }
  12834. }
  12835. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12836. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  12837. v := m.addstatus
  12838. if v == nil {
  12839. return
  12840. }
  12841. return *v, true
  12842. }
  12843. // ClearStatus clears the value of the "status" field.
  12844. func (m *ContactFieldTemplateMutation) ClearStatus() {
  12845. m.status = nil
  12846. m.addstatus = nil
  12847. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  12848. }
  12849. // StatusCleared returns if the "status" field was cleared in this mutation.
  12850. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  12851. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  12852. return ok
  12853. }
  12854. // ResetStatus resets all changes to the "status" field.
  12855. func (m *ContactFieldTemplateMutation) ResetStatus() {
  12856. m.status = nil
  12857. m.addstatus = nil
  12858. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  12859. }
  12860. // SetDeletedAt sets the "deleted_at" field.
  12861. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  12862. m.deleted_at = &t
  12863. }
  12864. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12865. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  12866. v := m.deleted_at
  12867. if v == nil {
  12868. return
  12869. }
  12870. return *v, true
  12871. }
  12872. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  12873. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12875. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12876. if !m.op.Is(OpUpdateOne) {
  12877. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12878. }
  12879. if m.id == nil || m.oldValue == nil {
  12880. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12881. }
  12882. oldValue, err := m.oldValue(ctx)
  12883. if err != nil {
  12884. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12885. }
  12886. return oldValue.DeletedAt, nil
  12887. }
  12888. // ClearDeletedAt clears the value of the "deleted_at" field.
  12889. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  12890. m.deleted_at = nil
  12891. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  12892. }
  12893. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12894. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  12895. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  12896. return ok
  12897. }
  12898. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12899. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  12900. m.deleted_at = nil
  12901. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  12902. }
  12903. // SetOrganizationID sets the "organization_id" field.
  12904. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  12905. m.organization_id = &u
  12906. m.addorganization_id = nil
  12907. }
  12908. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12909. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  12910. v := m.organization_id
  12911. if v == nil {
  12912. return
  12913. }
  12914. return *v, true
  12915. }
  12916. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  12917. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12919. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12920. if !m.op.Is(OpUpdateOne) {
  12921. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12922. }
  12923. if m.id == nil || m.oldValue == nil {
  12924. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12925. }
  12926. oldValue, err := m.oldValue(ctx)
  12927. if err != nil {
  12928. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12929. }
  12930. return oldValue.OrganizationID, nil
  12931. }
  12932. // AddOrganizationID adds u to the "organization_id" field.
  12933. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  12934. if m.addorganization_id != nil {
  12935. *m.addorganization_id += u
  12936. } else {
  12937. m.addorganization_id = &u
  12938. }
  12939. }
  12940. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12941. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  12942. v := m.addorganization_id
  12943. if v == nil {
  12944. return
  12945. }
  12946. return *v, true
  12947. }
  12948. // ResetOrganizationID resets all changes to the "organization_id" field.
  12949. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  12950. m.organization_id = nil
  12951. m.addorganization_id = nil
  12952. }
  12953. // SetTemplate sets the "template" field.
  12954. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  12955. m.template = &ctft
  12956. m.appendtemplate = nil
  12957. }
  12958. // Template returns the value of the "template" field in the mutation.
  12959. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  12960. v := m.template
  12961. if v == nil {
  12962. return
  12963. }
  12964. return *v, true
  12965. }
  12966. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  12967. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  12968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12969. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  12970. if !m.op.Is(OpUpdateOne) {
  12971. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  12972. }
  12973. if m.id == nil || m.oldValue == nil {
  12974. return v, errors.New("OldTemplate requires an ID field in the mutation")
  12975. }
  12976. oldValue, err := m.oldValue(ctx)
  12977. if err != nil {
  12978. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  12979. }
  12980. return oldValue.Template, nil
  12981. }
  12982. // AppendTemplate adds ctft to the "template" field.
  12983. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  12984. m.appendtemplate = append(m.appendtemplate, ctft...)
  12985. }
  12986. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  12987. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  12988. if len(m.appendtemplate) == 0 {
  12989. return nil, false
  12990. }
  12991. return m.appendtemplate, true
  12992. }
  12993. // ResetTemplate resets all changes to the "template" field.
  12994. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  12995. m.template = nil
  12996. m.appendtemplate = nil
  12997. }
  12998. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  12999. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  13000. m.predicates = append(m.predicates, ps...)
  13001. }
  13002. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  13003. // users can use type-assertion to append predicates that do not depend on any generated package.
  13004. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  13005. p := make([]predicate.ContactFieldTemplate, len(ps))
  13006. for i := range ps {
  13007. p[i] = ps[i]
  13008. }
  13009. m.Where(p...)
  13010. }
  13011. // Op returns the operation name.
  13012. func (m *ContactFieldTemplateMutation) Op() Op {
  13013. return m.op
  13014. }
  13015. // SetOp allows setting the mutation operation.
  13016. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  13017. m.op = op
  13018. }
  13019. // Type returns the node type of this mutation (ContactFieldTemplate).
  13020. func (m *ContactFieldTemplateMutation) Type() string {
  13021. return m.typ
  13022. }
  13023. // Fields returns all fields that were changed during this mutation. Note that in
  13024. // order to get all numeric fields that were incremented/decremented, call
  13025. // AddedFields().
  13026. func (m *ContactFieldTemplateMutation) Fields() []string {
  13027. fields := make([]string, 0, 6)
  13028. if m.created_at != nil {
  13029. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  13030. }
  13031. if m.updated_at != nil {
  13032. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  13033. }
  13034. if m.status != nil {
  13035. fields = append(fields, contactfieldtemplate.FieldStatus)
  13036. }
  13037. if m.deleted_at != nil {
  13038. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  13039. }
  13040. if m.organization_id != nil {
  13041. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  13042. }
  13043. if m.template != nil {
  13044. fields = append(fields, contactfieldtemplate.FieldTemplate)
  13045. }
  13046. return fields
  13047. }
  13048. // Field returns the value of a field with the given name. The second boolean
  13049. // return value indicates that this field was not set, or was not defined in the
  13050. // schema.
  13051. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  13052. switch name {
  13053. case contactfieldtemplate.FieldCreatedAt:
  13054. return m.CreatedAt()
  13055. case contactfieldtemplate.FieldUpdatedAt:
  13056. return m.UpdatedAt()
  13057. case contactfieldtemplate.FieldStatus:
  13058. return m.Status()
  13059. case contactfieldtemplate.FieldDeletedAt:
  13060. return m.DeletedAt()
  13061. case contactfieldtemplate.FieldOrganizationID:
  13062. return m.OrganizationID()
  13063. case contactfieldtemplate.FieldTemplate:
  13064. return m.Template()
  13065. }
  13066. return nil, false
  13067. }
  13068. // OldField returns the old value of the field from the database. An error is
  13069. // returned if the mutation operation is not UpdateOne, or the query to the
  13070. // database failed.
  13071. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13072. switch name {
  13073. case contactfieldtemplate.FieldCreatedAt:
  13074. return m.OldCreatedAt(ctx)
  13075. case contactfieldtemplate.FieldUpdatedAt:
  13076. return m.OldUpdatedAt(ctx)
  13077. case contactfieldtemplate.FieldStatus:
  13078. return m.OldStatus(ctx)
  13079. case contactfieldtemplate.FieldDeletedAt:
  13080. return m.OldDeletedAt(ctx)
  13081. case contactfieldtemplate.FieldOrganizationID:
  13082. return m.OldOrganizationID(ctx)
  13083. case contactfieldtemplate.FieldTemplate:
  13084. return m.OldTemplate(ctx)
  13085. }
  13086. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13087. }
  13088. // SetField sets the value of a field with the given name. It returns an error if
  13089. // the field is not defined in the schema, or if the type mismatched the field
  13090. // type.
  13091. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  13092. switch name {
  13093. case contactfieldtemplate.FieldCreatedAt:
  13094. v, ok := value.(time.Time)
  13095. if !ok {
  13096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13097. }
  13098. m.SetCreatedAt(v)
  13099. return nil
  13100. case contactfieldtemplate.FieldUpdatedAt:
  13101. v, ok := value.(time.Time)
  13102. if !ok {
  13103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13104. }
  13105. m.SetUpdatedAt(v)
  13106. return nil
  13107. case contactfieldtemplate.FieldStatus:
  13108. v, ok := value.(uint8)
  13109. if !ok {
  13110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13111. }
  13112. m.SetStatus(v)
  13113. return nil
  13114. case contactfieldtemplate.FieldDeletedAt:
  13115. v, ok := value.(time.Time)
  13116. if !ok {
  13117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13118. }
  13119. m.SetDeletedAt(v)
  13120. return nil
  13121. case contactfieldtemplate.FieldOrganizationID:
  13122. v, ok := value.(uint64)
  13123. if !ok {
  13124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13125. }
  13126. m.SetOrganizationID(v)
  13127. return nil
  13128. case contactfieldtemplate.FieldTemplate:
  13129. v, ok := value.([]custom_types.ContactFieldTemplate)
  13130. if !ok {
  13131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13132. }
  13133. m.SetTemplate(v)
  13134. return nil
  13135. }
  13136. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13137. }
  13138. // AddedFields returns all numeric fields that were incremented/decremented during
  13139. // this mutation.
  13140. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  13141. var fields []string
  13142. if m.addstatus != nil {
  13143. fields = append(fields, contactfieldtemplate.FieldStatus)
  13144. }
  13145. if m.addorganization_id != nil {
  13146. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  13147. }
  13148. return fields
  13149. }
  13150. // AddedField returns the numeric value that was incremented/decremented on a field
  13151. // with the given name. The second boolean return value indicates that this field
  13152. // was not set, or was not defined in the schema.
  13153. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  13154. switch name {
  13155. case contactfieldtemplate.FieldStatus:
  13156. return m.AddedStatus()
  13157. case contactfieldtemplate.FieldOrganizationID:
  13158. return m.AddedOrganizationID()
  13159. }
  13160. return nil, false
  13161. }
  13162. // AddField adds the value to the field with the given name. It returns an error if
  13163. // the field is not defined in the schema, or if the type mismatched the field
  13164. // type.
  13165. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  13166. switch name {
  13167. case contactfieldtemplate.FieldStatus:
  13168. v, ok := value.(int8)
  13169. if !ok {
  13170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13171. }
  13172. m.AddStatus(v)
  13173. return nil
  13174. case contactfieldtemplate.FieldOrganizationID:
  13175. v, ok := value.(int64)
  13176. if !ok {
  13177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13178. }
  13179. m.AddOrganizationID(v)
  13180. return nil
  13181. }
  13182. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  13183. }
  13184. // ClearedFields returns all nullable fields that were cleared during this
  13185. // mutation.
  13186. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  13187. var fields []string
  13188. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  13189. fields = append(fields, contactfieldtemplate.FieldStatus)
  13190. }
  13191. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  13192. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  13193. }
  13194. return fields
  13195. }
  13196. // FieldCleared returns a boolean indicating if a field with the given name was
  13197. // cleared in this mutation.
  13198. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  13199. _, ok := m.clearedFields[name]
  13200. return ok
  13201. }
  13202. // ClearField clears the value of the field with the given name. It returns an
  13203. // error if the field is not defined in the schema.
  13204. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  13205. switch name {
  13206. case contactfieldtemplate.FieldStatus:
  13207. m.ClearStatus()
  13208. return nil
  13209. case contactfieldtemplate.FieldDeletedAt:
  13210. m.ClearDeletedAt()
  13211. return nil
  13212. }
  13213. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  13214. }
  13215. // ResetField resets all changes in the mutation for the field with the given name.
  13216. // It returns an error if the field is not defined in the schema.
  13217. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  13218. switch name {
  13219. case contactfieldtemplate.FieldCreatedAt:
  13220. m.ResetCreatedAt()
  13221. return nil
  13222. case contactfieldtemplate.FieldUpdatedAt:
  13223. m.ResetUpdatedAt()
  13224. return nil
  13225. case contactfieldtemplate.FieldStatus:
  13226. m.ResetStatus()
  13227. return nil
  13228. case contactfieldtemplate.FieldDeletedAt:
  13229. m.ResetDeletedAt()
  13230. return nil
  13231. case contactfieldtemplate.FieldOrganizationID:
  13232. m.ResetOrganizationID()
  13233. return nil
  13234. case contactfieldtemplate.FieldTemplate:
  13235. m.ResetTemplate()
  13236. return nil
  13237. }
  13238. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  13239. }
  13240. // AddedEdges returns all edge names that were set/added in this mutation.
  13241. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  13242. edges := make([]string, 0, 0)
  13243. return edges
  13244. }
  13245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13246. // name in this mutation.
  13247. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  13248. return nil
  13249. }
  13250. // RemovedEdges returns all edge names that were removed in this mutation.
  13251. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  13252. edges := make([]string, 0, 0)
  13253. return edges
  13254. }
  13255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13256. // the given name in this mutation.
  13257. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  13258. return nil
  13259. }
  13260. // ClearedEdges returns all edge names that were cleared in this mutation.
  13261. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  13262. edges := make([]string, 0, 0)
  13263. return edges
  13264. }
  13265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13266. // was cleared in this mutation.
  13267. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  13268. return false
  13269. }
  13270. // ClearEdge clears the value of the edge with the given name. It returns an error
  13271. // if that edge is not defined in the schema.
  13272. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  13273. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  13274. }
  13275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13276. // It returns an error if the edge is not defined in the schema.
  13277. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  13278. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  13279. }
  13280. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  13281. type CreditBalanceMutation struct {
  13282. config
  13283. op Op
  13284. typ string
  13285. id *uint64
  13286. created_at *time.Time
  13287. updated_at *time.Time
  13288. deleted_at *time.Time
  13289. user_id *string
  13290. balance *float64
  13291. addbalance *float64
  13292. status *int
  13293. addstatus *int
  13294. organization_id *uint64
  13295. addorganization_id *int64
  13296. clearedFields map[string]struct{}
  13297. done bool
  13298. oldValue func(context.Context) (*CreditBalance, error)
  13299. predicates []predicate.CreditBalance
  13300. }
  13301. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  13302. // creditbalanceOption allows management of the mutation configuration using functional options.
  13303. type creditbalanceOption func(*CreditBalanceMutation)
  13304. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  13305. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  13306. m := &CreditBalanceMutation{
  13307. config: c,
  13308. op: op,
  13309. typ: TypeCreditBalance,
  13310. clearedFields: make(map[string]struct{}),
  13311. }
  13312. for _, opt := range opts {
  13313. opt(m)
  13314. }
  13315. return m
  13316. }
  13317. // withCreditBalanceID sets the ID field of the mutation.
  13318. func withCreditBalanceID(id uint64) creditbalanceOption {
  13319. return func(m *CreditBalanceMutation) {
  13320. var (
  13321. err error
  13322. once sync.Once
  13323. value *CreditBalance
  13324. )
  13325. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  13326. once.Do(func() {
  13327. if m.done {
  13328. err = errors.New("querying old values post mutation is not allowed")
  13329. } else {
  13330. value, err = m.Client().CreditBalance.Get(ctx, id)
  13331. }
  13332. })
  13333. return value, err
  13334. }
  13335. m.id = &id
  13336. }
  13337. }
  13338. // withCreditBalance sets the old CreditBalance of the mutation.
  13339. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  13340. return func(m *CreditBalanceMutation) {
  13341. m.oldValue = func(context.Context) (*CreditBalance, error) {
  13342. return node, nil
  13343. }
  13344. m.id = &node.ID
  13345. }
  13346. }
  13347. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13348. // executed in a transaction (ent.Tx), a transactional client is returned.
  13349. func (m CreditBalanceMutation) Client() *Client {
  13350. client := &Client{config: m.config}
  13351. client.init()
  13352. return client
  13353. }
  13354. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13355. // it returns an error otherwise.
  13356. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  13357. if _, ok := m.driver.(*txDriver); !ok {
  13358. return nil, errors.New("ent: mutation is not running in a transaction")
  13359. }
  13360. tx := &Tx{config: m.config}
  13361. tx.init()
  13362. return tx, nil
  13363. }
  13364. // SetID sets the value of the id field. Note that this
  13365. // operation is only accepted on creation of CreditBalance entities.
  13366. func (m *CreditBalanceMutation) SetID(id uint64) {
  13367. m.id = &id
  13368. }
  13369. // ID returns the ID value in the mutation. Note that the ID is only available
  13370. // if it was provided to the builder or after it was returned from the database.
  13371. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  13372. if m.id == nil {
  13373. return
  13374. }
  13375. return *m.id, true
  13376. }
  13377. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13378. // That means, if the mutation is applied within a transaction with an isolation level such
  13379. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13380. // or updated by the mutation.
  13381. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  13382. switch {
  13383. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13384. id, exists := m.ID()
  13385. if exists {
  13386. return []uint64{id}, nil
  13387. }
  13388. fallthrough
  13389. case m.op.Is(OpUpdate | OpDelete):
  13390. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  13391. default:
  13392. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13393. }
  13394. }
  13395. // SetCreatedAt sets the "created_at" field.
  13396. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  13397. m.created_at = &t
  13398. }
  13399. // CreatedAt returns the value of the "created_at" field in the mutation.
  13400. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  13401. v := m.created_at
  13402. if v == nil {
  13403. return
  13404. }
  13405. return *v, true
  13406. }
  13407. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  13408. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13410. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13411. if !m.op.Is(OpUpdateOne) {
  13412. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13413. }
  13414. if m.id == nil || m.oldValue == nil {
  13415. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13416. }
  13417. oldValue, err := m.oldValue(ctx)
  13418. if err != nil {
  13419. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13420. }
  13421. return oldValue.CreatedAt, nil
  13422. }
  13423. // ResetCreatedAt resets all changes to the "created_at" field.
  13424. func (m *CreditBalanceMutation) ResetCreatedAt() {
  13425. m.created_at = nil
  13426. }
  13427. // SetUpdatedAt sets the "updated_at" field.
  13428. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  13429. m.updated_at = &t
  13430. }
  13431. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13432. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  13433. v := m.updated_at
  13434. if v == nil {
  13435. return
  13436. }
  13437. return *v, true
  13438. }
  13439. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  13440. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13442. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13443. if !m.op.Is(OpUpdateOne) {
  13444. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13445. }
  13446. if m.id == nil || m.oldValue == nil {
  13447. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13448. }
  13449. oldValue, err := m.oldValue(ctx)
  13450. if err != nil {
  13451. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13452. }
  13453. return oldValue.UpdatedAt, nil
  13454. }
  13455. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13456. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  13457. m.updated_at = nil
  13458. }
  13459. // SetDeletedAt sets the "deleted_at" field.
  13460. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  13461. m.deleted_at = &t
  13462. }
  13463. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13464. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  13465. v := m.deleted_at
  13466. if v == nil {
  13467. return
  13468. }
  13469. return *v, true
  13470. }
  13471. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  13472. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13474. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13475. if !m.op.Is(OpUpdateOne) {
  13476. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13477. }
  13478. if m.id == nil || m.oldValue == nil {
  13479. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13480. }
  13481. oldValue, err := m.oldValue(ctx)
  13482. if err != nil {
  13483. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13484. }
  13485. return oldValue.DeletedAt, nil
  13486. }
  13487. // ClearDeletedAt clears the value of the "deleted_at" field.
  13488. func (m *CreditBalanceMutation) ClearDeletedAt() {
  13489. m.deleted_at = nil
  13490. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  13491. }
  13492. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13493. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  13494. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  13495. return ok
  13496. }
  13497. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13498. func (m *CreditBalanceMutation) ResetDeletedAt() {
  13499. m.deleted_at = nil
  13500. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  13501. }
  13502. // SetUserID sets the "user_id" field.
  13503. func (m *CreditBalanceMutation) SetUserID(s string) {
  13504. m.user_id = &s
  13505. }
  13506. // UserID returns the value of the "user_id" field in the mutation.
  13507. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  13508. v := m.user_id
  13509. if v == nil {
  13510. return
  13511. }
  13512. return *v, true
  13513. }
  13514. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  13515. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13517. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  13518. if !m.op.Is(OpUpdateOne) {
  13519. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13520. }
  13521. if m.id == nil || m.oldValue == nil {
  13522. return v, errors.New("OldUserID requires an ID field in the mutation")
  13523. }
  13524. oldValue, err := m.oldValue(ctx)
  13525. if err != nil {
  13526. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13527. }
  13528. return oldValue.UserID, nil
  13529. }
  13530. // ClearUserID clears the value of the "user_id" field.
  13531. func (m *CreditBalanceMutation) ClearUserID() {
  13532. m.user_id = nil
  13533. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  13534. }
  13535. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13536. func (m *CreditBalanceMutation) UserIDCleared() bool {
  13537. _, ok := m.clearedFields[creditbalance.FieldUserID]
  13538. return ok
  13539. }
  13540. // ResetUserID resets all changes to the "user_id" field.
  13541. func (m *CreditBalanceMutation) ResetUserID() {
  13542. m.user_id = nil
  13543. delete(m.clearedFields, creditbalance.FieldUserID)
  13544. }
  13545. // SetBalance sets the "balance" field.
  13546. func (m *CreditBalanceMutation) SetBalance(f float64) {
  13547. m.balance = &f
  13548. m.addbalance = nil
  13549. }
  13550. // Balance returns the value of the "balance" field in the mutation.
  13551. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  13552. v := m.balance
  13553. if v == nil {
  13554. return
  13555. }
  13556. return *v, true
  13557. }
  13558. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  13559. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13561. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  13562. if !m.op.Is(OpUpdateOne) {
  13563. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  13564. }
  13565. if m.id == nil || m.oldValue == nil {
  13566. return v, errors.New("OldBalance requires an ID field in the mutation")
  13567. }
  13568. oldValue, err := m.oldValue(ctx)
  13569. if err != nil {
  13570. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  13571. }
  13572. return oldValue.Balance, nil
  13573. }
  13574. // AddBalance adds f to the "balance" field.
  13575. func (m *CreditBalanceMutation) AddBalance(f float64) {
  13576. if m.addbalance != nil {
  13577. *m.addbalance += f
  13578. } else {
  13579. m.addbalance = &f
  13580. }
  13581. }
  13582. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  13583. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  13584. v := m.addbalance
  13585. if v == nil {
  13586. return
  13587. }
  13588. return *v, true
  13589. }
  13590. // ResetBalance resets all changes to the "balance" field.
  13591. func (m *CreditBalanceMutation) ResetBalance() {
  13592. m.balance = nil
  13593. m.addbalance = nil
  13594. }
  13595. // SetStatus sets the "status" field.
  13596. func (m *CreditBalanceMutation) SetStatus(i int) {
  13597. m.status = &i
  13598. m.addstatus = nil
  13599. }
  13600. // Status returns the value of the "status" field in the mutation.
  13601. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  13602. v := m.status
  13603. if v == nil {
  13604. return
  13605. }
  13606. return *v, true
  13607. }
  13608. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  13609. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13611. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  13612. if !m.op.Is(OpUpdateOne) {
  13613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13614. }
  13615. if m.id == nil || m.oldValue == nil {
  13616. return v, errors.New("OldStatus requires an ID field in the mutation")
  13617. }
  13618. oldValue, err := m.oldValue(ctx)
  13619. if err != nil {
  13620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13621. }
  13622. return oldValue.Status, nil
  13623. }
  13624. // AddStatus adds i to the "status" field.
  13625. func (m *CreditBalanceMutation) AddStatus(i int) {
  13626. if m.addstatus != nil {
  13627. *m.addstatus += i
  13628. } else {
  13629. m.addstatus = &i
  13630. }
  13631. }
  13632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13633. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  13634. v := m.addstatus
  13635. if v == nil {
  13636. return
  13637. }
  13638. return *v, true
  13639. }
  13640. // ClearStatus clears the value of the "status" field.
  13641. func (m *CreditBalanceMutation) ClearStatus() {
  13642. m.status = nil
  13643. m.addstatus = nil
  13644. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  13645. }
  13646. // StatusCleared returns if the "status" field was cleared in this mutation.
  13647. func (m *CreditBalanceMutation) StatusCleared() bool {
  13648. _, ok := m.clearedFields[creditbalance.FieldStatus]
  13649. return ok
  13650. }
  13651. // ResetStatus resets all changes to the "status" field.
  13652. func (m *CreditBalanceMutation) ResetStatus() {
  13653. m.status = nil
  13654. m.addstatus = nil
  13655. delete(m.clearedFields, creditbalance.FieldStatus)
  13656. }
  13657. // SetOrganizationID sets the "organization_id" field.
  13658. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  13659. m.organization_id = &u
  13660. m.addorganization_id = nil
  13661. }
  13662. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13663. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  13664. v := m.organization_id
  13665. if v == nil {
  13666. return
  13667. }
  13668. return *v, true
  13669. }
  13670. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  13671. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  13672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13673. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13674. if !m.op.Is(OpUpdateOne) {
  13675. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13676. }
  13677. if m.id == nil || m.oldValue == nil {
  13678. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13679. }
  13680. oldValue, err := m.oldValue(ctx)
  13681. if err != nil {
  13682. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13683. }
  13684. return oldValue.OrganizationID, nil
  13685. }
  13686. // AddOrganizationID adds u to the "organization_id" field.
  13687. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  13688. if m.addorganization_id != nil {
  13689. *m.addorganization_id += u
  13690. } else {
  13691. m.addorganization_id = &u
  13692. }
  13693. }
  13694. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13695. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  13696. v := m.addorganization_id
  13697. if v == nil {
  13698. return
  13699. }
  13700. return *v, true
  13701. }
  13702. // ClearOrganizationID clears the value of the "organization_id" field.
  13703. func (m *CreditBalanceMutation) ClearOrganizationID() {
  13704. m.organization_id = nil
  13705. m.addorganization_id = nil
  13706. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  13707. }
  13708. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13709. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  13710. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  13711. return ok
  13712. }
  13713. // ResetOrganizationID resets all changes to the "organization_id" field.
  13714. func (m *CreditBalanceMutation) ResetOrganizationID() {
  13715. m.organization_id = nil
  13716. m.addorganization_id = nil
  13717. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  13718. }
  13719. // Where appends a list predicates to the CreditBalanceMutation builder.
  13720. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  13721. m.predicates = append(m.predicates, ps...)
  13722. }
  13723. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  13724. // users can use type-assertion to append predicates that do not depend on any generated package.
  13725. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  13726. p := make([]predicate.CreditBalance, len(ps))
  13727. for i := range ps {
  13728. p[i] = ps[i]
  13729. }
  13730. m.Where(p...)
  13731. }
  13732. // Op returns the operation name.
  13733. func (m *CreditBalanceMutation) Op() Op {
  13734. return m.op
  13735. }
  13736. // SetOp allows setting the mutation operation.
  13737. func (m *CreditBalanceMutation) SetOp(op Op) {
  13738. m.op = op
  13739. }
  13740. // Type returns the node type of this mutation (CreditBalance).
  13741. func (m *CreditBalanceMutation) Type() string {
  13742. return m.typ
  13743. }
  13744. // Fields returns all fields that were changed during this mutation. Note that in
  13745. // order to get all numeric fields that were incremented/decremented, call
  13746. // AddedFields().
  13747. func (m *CreditBalanceMutation) Fields() []string {
  13748. fields := make([]string, 0, 7)
  13749. if m.created_at != nil {
  13750. fields = append(fields, creditbalance.FieldCreatedAt)
  13751. }
  13752. if m.updated_at != nil {
  13753. fields = append(fields, creditbalance.FieldUpdatedAt)
  13754. }
  13755. if m.deleted_at != nil {
  13756. fields = append(fields, creditbalance.FieldDeletedAt)
  13757. }
  13758. if m.user_id != nil {
  13759. fields = append(fields, creditbalance.FieldUserID)
  13760. }
  13761. if m.balance != nil {
  13762. fields = append(fields, creditbalance.FieldBalance)
  13763. }
  13764. if m.status != nil {
  13765. fields = append(fields, creditbalance.FieldStatus)
  13766. }
  13767. if m.organization_id != nil {
  13768. fields = append(fields, creditbalance.FieldOrganizationID)
  13769. }
  13770. return fields
  13771. }
  13772. // Field returns the value of a field with the given name. The second boolean
  13773. // return value indicates that this field was not set, or was not defined in the
  13774. // schema.
  13775. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13776. switch name {
  13777. case creditbalance.FieldCreatedAt:
  13778. return m.CreatedAt()
  13779. case creditbalance.FieldUpdatedAt:
  13780. return m.UpdatedAt()
  13781. case creditbalance.FieldDeletedAt:
  13782. return m.DeletedAt()
  13783. case creditbalance.FieldUserID:
  13784. return m.UserID()
  13785. case creditbalance.FieldBalance:
  13786. return m.Balance()
  13787. case creditbalance.FieldStatus:
  13788. return m.Status()
  13789. case creditbalance.FieldOrganizationID:
  13790. return m.OrganizationID()
  13791. }
  13792. return nil, false
  13793. }
  13794. // OldField returns the old value of the field from the database. An error is
  13795. // returned if the mutation operation is not UpdateOne, or the query to the
  13796. // database failed.
  13797. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13798. switch name {
  13799. case creditbalance.FieldCreatedAt:
  13800. return m.OldCreatedAt(ctx)
  13801. case creditbalance.FieldUpdatedAt:
  13802. return m.OldUpdatedAt(ctx)
  13803. case creditbalance.FieldDeletedAt:
  13804. return m.OldDeletedAt(ctx)
  13805. case creditbalance.FieldUserID:
  13806. return m.OldUserID(ctx)
  13807. case creditbalance.FieldBalance:
  13808. return m.OldBalance(ctx)
  13809. case creditbalance.FieldStatus:
  13810. return m.OldStatus(ctx)
  13811. case creditbalance.FieldOrganizationID:
  13812. return m.OldOrganizationID(ctx)
  13813. }
  13814. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13815. }
  13816. // SetField sets the value of a field with the given name. It returns an error if
  13817. // the field is not defined in the schema, or if the type mismatched the field
  13818. // type.
  13819. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13820. switch name {
  13821. case creditbalance.FieldCreatedAt:
  13822. v, ok := value.(time.Time)
  13823. if !ok {
  13824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13825. }
  13826. m.SetCreatedAt(v)
  13827. return nil
  13828. case creditbalance.FieldUpdatedAt:
  13829. v, ok := value.(time.Time)
  13830. if !ok {
  13831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13832. }
  13833. m.SetUpdatedAt(v)
  13834. return nil
  13835. case creditbalance.FieldDeletedAt:
  13836. v, ok := value.(time.Time)
  13837. if !ok {
  13838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13839. }
  13840. m.SetDeletedAt(v)
  13841. return nil
  13842. case creditbalance.FieldUserID:
  13843. v, ok := value.(string)
  13844. if !ok {
  13845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13846. }
  13847. m.SetUserID(v)
  13848. return nil
  13849. case creditbalance.FieldBalance:
  13850. v, ok := value.(float64)
  13851. if !ok {
  13852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13853. }
  13854. m.SetBalance(v)
  13855. return nil
  13856. case creditbalance.FieldStatus:
  13857. v, ok := value.(int)
  13858. if !ok {
  13859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13860. }
  13861. m.SetStatus(v)
  13862. return nil
  13863. case creditbalance.FieldOrganizationID:
  13864. v, ok := value.(uint64)
  13865. if !ok {
  13866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13867. }
  13868. m.SetOrganizationID(v)
  13869. return nil
  13870. }
  13871. return fmt.Errorf("unknown CreditBalance field %s", name)
  13872. }
  13873. // AddedFields returns all numeric fields that were incremented/decremented during
  13874. // this mutation.
  13875. func (m *CreditBalanceMutation) AddedFields() []string {
  13876. var fields []string
  13877. if m.addbalance != nil {
  13878. fields = append(fields, creditbalance.FieldBalance)
  13879. }
  13880. if m.addstatus != nil {
  13881. fields = append(fields, creditbalance.FieldStatus)
  13882. }
  13883. if m.addorganization_id != nil {
  13884. fields = append(fields, creditbalance.FieldOrganizationID)
  13885. }
  13886. return fields
  13887. }
  13888. // AddedField returns the numeric value that was incremented/decremented on a field
  13889. // with the given name. The second boolean return value indicates that this field
  13890. // was not set, or was not defined in the schema.
  13891. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13892. switch name {
  13893. case creditbalance.FieldBalance:
  13894. return m.AddedBalance()
  13895. case creditbalance.FieldStatus:
  13896. return m.AddedStatus()
  13897. case creditbalance.FieldOrganizationID:
  13898. return m.AddedOrganizationID()
  13899. }
  13900. return nil, false
  13901. }
  13902. // AddField adds the value to the field with the given name. It returns an error if
  13903. // the field is not defined in the schema, or if the type mismatched the field
  13904. // type.
  13905. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13906. switch name {
  13907. case creditbalance.FieldBalance:
  13908. v, ok := value.(float64)
  13909. if !ok {
  13910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13911. }
  13912. m.AddBalance(v)
  13913. return nil
  13914. case creditbalance.FieldStatus:
  13915. v, ok := value.(int)
  13916. if !ok {
  13917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13918. }
  13919. m.AddStatus(v)
  13920. return nil
  13921. case creditbalance.FieldOrganizationID:
  13922. v, ok := value.(int64)
  13923. if !ok {
  13924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13925. }
  13926. m.AddOrganizationID(v)
  13927. return nil
  13928. }
  13929. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13930. }
  13931. // ClearedFields returns all nullable fields that were cleared during this
  13932. // mutation.
  13933. func (m *CreditBalanceMutation) ClearedFields() []string {
  13934. var fields []string
  13935. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13936. fields = append(fields, creditbalance.FieldDeletedAt)
  13937. }
  13938. if m.FieldCleared(creditbalance.FieldUserID) {
  13939. fields = append(fields, creditbalance.FieldUserID)
  13940. }
  13941. if m.FieldCleared(creditbalance.FieldStatus) {
  13942. fields = append(fields, creditbalance.FieldStatus)
  13943. }
  13944. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13945. fields = append(fields, creditbalance.FieldOrganizationID)
  13946. }
  13947. return fields
  13948. }
  13949. // FieldCleared returns a boolean indicating if a field with the given name was
  13950. // cleared in this mutation.
  13951. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13952. _, ok := m.clearedFields[name]
  13953. return ok
  13954. }
  13955. // ClearField clears the value of the field with the given name. It returns an
  13956. // error if the field is not defined in the schema.
  13957. func (m *CreditBalanceMutation) ClearField(name string) error {
  13958. switch name {
  13959. case creditbalance.FieldDeletedAt:
  13960. m.ClearDeletedAt()
  13961. return nil
  13962. case creditbalance.FieldUserID:
  13963. m.ClearUserID()
  13964. return nil
  13965. case creditbalance.FieldStatus:
  13966. m.ClearStatus()
  13967. return nil
  13968. case creditbalance.FieldOrganizationID:
  13969. m.ClearOrganizationID()
  13970. return nil
  13971. }
  13972. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13973. }
  13974. // ResetField resets all changes in the mutation for the field with the given name.
  13975. // It returns an error if the field is not defined in the schema.
  13976. func (m *CreditBalanceMutation) ResetField(name string) error {
  13977. switch name {
  13978. case creditbalance.FieldCreatedAt:
  13979. m.ResetCreatedAt()
  13980. return nil
  13981. case creditbalance.FieldUpdatedAt:
  13982. m.ResetUpdatedAt()
  13983. return nil
  13984. case creditbalance.FieldDeletedAt:
  13985. m.ResetDeletedAt()
  13986. return nil
  13987. case creditbalance.FieldUserID:
  13988. m.ResetUserID()
  13989. return nil
  13990. case creditbalance.FieldBalance:
  13991. m.ResetBalance()
  13992. return nil
  13993. case creditbalance.FieldStatus:
  13994. m.ResetStatus()
  13995. return nil
  13996. case creditbalance.FieldOrganizationID:
  13997. m.ResetOrganizationID()
  13998. return nil
  13999. }
  14000. return fmt.Errorf("unknown CreditBalance field %s", name)
  14001. }
  14002. // AddedEdges returns all edge names that were set/added in this mutation.
  14003. func (m *CreditBalanceMutation) AddedEdges() []string {
  14004. edges := make([]string, 0, 0)
  14005. return edges
  14006. }
  14007. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14008. // name in this mutation.
  14009. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  14010. return nil
  14011. }
  14012. // RemovedEdges returns all edge names that were removed in this mutation.
  14013. func (m *CreditBalanceMutation) RemovedEdges() []string {
  14014. edges := make([]string, 0, 0)
  14015. return edges
  14016. }
  14017. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14018. // the given name in this mutation.
  14019. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  14020. return nil
  14021. }
  14022. // ClearedEdges returns all edge names that were cleared in this mutation.
  14023. func (m *CreditBalanceMutation) ClearedEdges() []string {
  14024. edges := make([]string, 0, 0)
  14025. return edges
  14026. }
  14027. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14028. // was cleared in this mutation.
  14029. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  14030. return false
  14031. }
  14032. // ClearEdge clears the value of the edge with the given name. It returns an error
  14033. // if that edge is not defined in the schema.
  14034. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  14035. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  14036. }
  14037. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14038. // It returns an error if the edge is not defined in the schema.
  14039. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  14040. return fmt.Errorf("unknown CreditBalance edge %s", name)
  14041. }
  14042. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  14043. type CreditUsageMutation struct {
  14044. config
  14045. op Op
  14046. typ string
  14047. id *uint64
  14048. created_at *time.Time
  14049. updated_at *time.Time
  14050. deleted_at *time.Time
  14051. user_id *string
  14052. number *float64
  14053. addnumber *float64
  14054. pay_number *float64
  14055. addpay_number *float64
  14056. before_number *float64
  14057. addbefore_number *float64
  14058. after_number *float64
  14059. addafter_number *float64
  14060. pay_method *string
  14061. status *int
  14062. addstatus *int
  14063. ntype *int
  14064. addntype *int
  14065. table *string
  14066. organization_id *uint64
  14067. addorganization_id *int64
  14068. nid *uint64
  14069. addnid *int64
  14070. reason *string
  14071. operator *string
  14072. clearedFields map[string]struct{}
  14073. done bool
  14074. oldValue func(context.Context) (*CreditUsage, error)
  14075. predicates []predicate.CreditUsage
  14076. }
  14077. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  14078. // creditusageOption allows management of the mutation configuration using functional options.
  14079. type creditusageOption func(*CreditUsageMutation)
  14080. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  14081. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  14082. m := &CreditUsageMutation{
  14083. config: c,
  14084. op: op,
  14085. typ: TypeCreditUsage,
  14086. clearedFields: make(map[string]struct{}),
  14087. }
  14088. for _, opt := range opts {
  14089. opt(m)
  14090. }
  14091. return m
  14092. }
  14093. // withCreditUsageID sets the ID field of the mutation.
  14094. func withCreditUsageID(id uint64) creditusageOption {
  14095. return func(m *CreditUsageMutation) {
  14096. var (
  14097. err error
  14098. once sync.Once
  14099. value *CreditUsage
  14100. )
  14101. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  14102. once.Do(func() {
  14103. if m.done {
  14104. err = errors.New("querying old values post mutation is not allowed")
  14105. } else {
  14106. value, err = m.Client().CreditUsage.Get(ctx, id)
  14107. }
  14108. })
  14109. return value, err
  14110. }
  14111. m.id = &id
  14112. }
  14113. }
  14114. // withCreditUsage sets the old CreditUsage of the mutation.
  14115. func withCreditUsage(node *CreditUsage) creditusageOption {
  14116. return func(m *CreditUsageMutation) {
  14117. m.oldValue = func(context.Context) (*CreditUsage, error) {
  14118. return node, nil
  14119. }
  14120. m.id = &node.ID
  14121. }
  14122. }
  14123. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14124. // executed in a transaction (ent.Tx), a transactional client is returned.
  14125. func (m CreditUsageMutation) Client() *Client {
  14126. client := &Client{config: m.config}
  14127. client.init()
  14128. return client
  14129. }
  14130. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14131. // it returns an error otherwise.
  14132. func (m CreditUsageMutation) Tx() (*Tx, error) {
  14133. if _, ok := m.driver.(*txDriver); !ok {
  14134. return nil, errors.New("ent: mutation is not running in a transaction")
  14135. }
  14136. tx := &Tx{config: m.config}
  14137. tx.init()
  14138. return tx, nil
  14139. }
  14140. // SetID sets the value of the id field. Note that this
  14141. // operation is only accepted on creation of CreditUsage entities.
  14142. func (m *CreditUsageMutation) SetID(id uint64) {
  14143. m.id = &id
  14144. }
  14145. // ID returns the ID value in the mutation. Note that the ID is only available
  14146. // if it was provided to the builder or after it was returned from the database.
  14147. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  14148. if m.id == nil {
  14149. return
  14150. }
  14151. return *m.id, true
  14152. }
  14153. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14154. // That means, if the mutation is applied within a transaction with an isolation level such
  14155. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14156. // or updated by the mutation.
  14157. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  14158. switch {
  14159. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14160. id, exists := m.ID()
  14161. if exists {
  14162. return []uint64{id}, nil
  14163. }
  14164. fallthrough
  14165. case m.op.Is(OpUpdate | OpDelete):
  14166. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  14167. default:
  14168. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14169. }
  14170. }
  14171. // SetCreatedAt sets the "created_at" field.
  14172. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  14173. m.created_at = &t
  14174. }
  14175. // CreatedAt returns the value of the "created_at" field in the mutation.
  14176. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  14177. v := m.created_at
  14178. if v == nil {
  14179. return
  14180. }
  14181. return *v, true
  14182. }
  14183. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  14184. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14186. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14187. if !m.op.Is(OpUpdateOne) {
  14188. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14189. }
  14190. if m.id == nil || m.oldValue == nil {
  14191. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14192. }
  14193. oldValue, err := m.oldValue(ctx)
  14194. if err != nil {
  14195. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14196. }
  14197. return oldValue.CreatedAt, nil
  14198. }
  14199. // ResetCreatedAt resets all changes to the "created_at" field.
  14200. func (m *CreditUsageMutation) ResetCreatedAt() {
  14201. m.created_at = nil
  14202. }
  14203. // SetUpdatedAt sets the "updated_at" field.
  14204. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  14205. m.updated_at = &t
  14206. }
  14207. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14208. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  14209. v := m.updated_at
  14210. if v == nil {
  14211. return
  14212. }
  14213. return *v, true
  14214. }
  14215. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  14216. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14218. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14219. if !m.op.Is(OpUpdateOne) {
  14220. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14221. }
  14222. if m.id == nil || m.oldValue == nil {
  14223. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14224. }
  14225. oldValue, err := m.oldValue(ctx)
  14226. if err != nil {
  14227. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14228. }
  14229. return oldValue.UpdatedAt, nil
  14230. }
  14231. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14232. func (m *CreditUsageMutation) ResetUpdatedAt() {
  14233. m.updated_at = nil
  14234. }
  14235. // SetDeletedAt sets the "deleted_at" field.
  14236. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  14237. m.deleted_at = &t
  14238. }
  14239. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14240. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  14241. v := m.deleted_at
  14242. if v == nil {
  14243. return
  14244. }
  14245. return *v, true
  14246. }
  14247. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  14248. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14250. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14251. if !m.op.Is(OpUpdateOne) {
  14252. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14253. }
  14254. if m.id == nil || m.oldValue == nil {
  14255. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14256. }
  14257. oldValue, err := m.oldValue(ctx)
  14258. if err != nil {
  14259. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14260. }
  14261. return oldValue.DeletedAt, nil
  14262. }
  14263. // ClearDeletedAt clears the value of the "deleted_at" field.
  14264. func (m *CreditUsageMutation) ClearDeletedAt() {
  14265. m.deleted_at = nil
  14266. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  14267. }
  14268. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14269. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  14270. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  14271. return ok
  14272. }
  14273. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14274. func (m *CreditUsageMutation) ResetDeletedAt() {
  14275. m.deleted_at = nil
  14276. delete(m.clearedFields, creditusage.FieldDeletedAt)
  14277. }
  14278. // SetUserID sets the "user_id" field.
  14279. func (m *CreditUsageMutation) SetUserID(s string) {
  14280. m.user_id = &s
  14281. }
  14282. // UserID returns the value of the "user_id" field in the mutation.
  14283. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  14284. v := m.user_id
  14285. if v == nil {
  14286. return
  14287. }
  14288. return *v, true
  14289. }
  14290. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  14291. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14293. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  14294. if !m.op.Is(OpUpdateOne) {
  14295. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14296. }
  14297. if m.id == nil || m.oldValue == nil {
  14298. return v, errors.New("OldUserID requires an ID field in the mutation")
  14299. }
  14300. oldValue, err := m.oldValue(ctx)
  14301. if err != nil {
  14302. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14303. }
  14304. return oldValue.UserID, nil
  14305. }
  14306. // ClearUserID clears the value of the "user_id" field.
  14307. func (m *CreditUsageMutation) ClearUserID() {
  14308. m.user_id = nil
  14309. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  14310. }
  14311. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14312. func (m *CreditUsageMutation) UserIDCleared() bool {
  14313. _, ok := m.clearedFields[creditusage.FieldUserID]
  14314. return ok
  14315. }
  14316. // ResetUserID resets all changes to the "user_id" field.
  14317. func (m *CreditUsageMutation) ResetUserID() {
  14318. m.user_id = nil
  14319. delete(m.clearedFields, creditusage.FieldUserID)
  14320. }
  14321. // SetNumber sets the "number" field.
  14322. func (m *CreditUsageMutation) SetNumber(f float64) {
  14323. m.number = &f
  14324. m.addnumber = nil
  14325. }
  14326. // Number returns the value of the "number" field in the mutation.
  14327. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  14328. v := m.number
  14329. if v == nil {
  14330. return
  14331. }
  14332. return *v, true
  14333. }
  14334. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  14335. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14337. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  14338. if !m.op.Is(OpUpdateOne) {
  14339. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  14340. }
  14341. if m.id == nil || m.oldValue == nil {
  14342. return v, errors.New("OldNumber requires an ID field in the mutation")
  14343. }
  14344. oldValue, err := m.oldValue(ctx)
  14345. if err != nil {
  14346. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  14347. }
  14348. return oldValue.Number, nil
  14349. }
  14350. // AddNumber adds f to the "number" field.
  14351. func (m *CreditUsageMutation) AddNumber(f float64) {
  14352. if m.addnumber != nil {
  14353. *m.addnumber += f
  14354. } else {
  14355. m.addnumber = &f
  14356. }
  14357. }
  14358. // AddedNumber returns the value that was added to the "number" field in this mutation.
  14359. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  14360. v := m.addnumber
  14361. if v == nil {
  14362. return
  14363. }
  14364. return *v, true
  14365. }
  14366. // ResetNumber resets all changes to the "number" field.
  14367. func (m *CreditUsageMutation) ResetNumber() {
  14368. m.number = nil
  14369. m.addnumber = nil
  14370. }
  14371. // SetPayNumber sets the "pay_number" field.
  14372. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  14373. m.pay_number = &f
  14374. m.addpay_number = nil
  14375. }
  14376. // PayNumber returns the value of the "pay_number" field in the mutation.
  14377. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  14378. v := m.pay_number
  14379. if v == nil {
  14380. return
  14381. }
  14382. return *v, true
  14383. }
  14384. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  14385. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14387. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  14388. if !m.op.Is(OpUpdateOne) {
  14389. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  14390. }
  14391. if m.id == nil || m.oldValue == nil {
  14392. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  14393. }
  14394. oldValue, err := m.oldValue(ctx)
  14395. if err != nil {
  14396. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  14397. }
  14398. return oldValue.PayNumber, nil
  14399. }
  14400. // AddPayNumber adds f to the "pay_number" field.
  14401. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  14402. if m.addpay_number != nil {
  14403. *m.addpay_number += f
  14404. } else {
  14405. m.addpay_number = &f
  14406. }
  14407. }
  14408. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  14409. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  14410. v := m.addpay_number
  14411. if v == nil {
  14412. return
  14413. }
  14414. return *v, true
  14415. }
  14416. // ClearPayNumber clears the value of the "pay_number" field.
  14417. func (m *CreditUsageMutation) ClearPayNumber() {
  14418. m.pay_number = nil
  14419. m.addpay_number = nil
  14420. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  14421. }
  14422. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  14423. func (m *CreditUsageMutation) PayNumberCleared() bool {
  14424. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  14425. return ok
  14426. }
  14427. // ResetPayNumber resets all changes to the "pay_number" field.
  14428. func (m *CreditUsageMutation) ResetPayNumber() {
  14429. m.pay_number = nil
  14430. m.addpay_number = nil
  14431. delete(m.clearedFields, creditusage.FieldPayNumber)
  14432. }
  14433. // SetBeforeNumber sets the "before_number" field.
  14434. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  14435. m.before_number = &f
  14436. m.addbefore_number = nil
  14437. }
  14438. // BeforeNumber returns the value of the "before_number" field in the mutation.
  14439. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  14440. v := m.before_number
  14441. if v == nil {
  14442. return
  14443. }
  14444. return *v, true
  14445. }
  14446. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  14447. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14449. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  14450. if !m.op.Is(OpUpdateOne) {
  14451. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  14452. }
  14453. if m.id == nil || m.oldValue == nil {
  14454. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  14455. }
  14456. oldValue, err := m.oldValue(ctx)
  14457. if err != nil {
  14458. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  14459. }
  14460. return oldValue.BeforeNumber, nil
  14461. }
  14462. // AddBeforeNumber adds f to the "before_number" field.
  14463. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  14464. if m.addbefore_number != nil {
  14465. *m.addbefore_number += f
  14466. } else {
  14467. m.addbefore_number = &f
  14468. }
  14469. }
  14470. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  14471. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  14472. v := m.addbefore_number
  14473. if v == nil {
  14474. return
  14475. }
  14476. return *v, true
  14477. }
  14478. // ClearBeforeNumber clears the value of the "before_number" field.
  14479. func (m *CreditUsageMutation) ClearBeforeNumber() {
  14480. m.before_number = nil
  14481. m.addbefore_number = nil
  14482. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  14483. }
  14484. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  14485. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  14486. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  14487. return ok
  14488. }
  14489. // ResetBeforeNumber resets all changes to the "before_number" field.
  14490. func (m *CreditUsageMutation) ResetBeforeNumber() {
  14491. m.before_number = nil
  14492. m.addbefore_number = nil
  14493. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  14494. }
  14495. // SetAfterNumber sets the "after_number" field.
  14496. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  14497. m.after_number = &f
  14498. m.addafter_number = nil
  14499. }
  14500. // AfterNumber returns the value of the "after_number" field in the mutation.
  14501. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  14502. v := m.after_number
  14503. if v == nil {
  14504. return
  14505. }
  14506. return *v, true
  14507. }
  14508. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  14509. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14511. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  14512. if !m.op.Is(OpUpdateOne) {
  14513. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  14514. }
  14515. if m.id == nil || m.oldValue == nil {
  14516. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  14517. }
  14518. oldValue, err := m.oldValue(ctx)
  14519. if err != nil {
  14520. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  14521. }
  14522. return oldValue.AfterNumber, nil
  14523. }
  14524. // AddAfterNumber adds f to the "after_number" field.
  14525. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  14526. if m.addafter_number != nil {
  14527. *m.addafter_number += f
  14528. } else {
  14529. m.addafter_number = &f
  14530. }
  14531. }
  14532. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  14533. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  14534. v := m.addafter_number
  14535. if v == nil {
  14536. return
  14537. }
  14538. return *v, true
  14539. }
  14540. // ClearAfterNumber clears the value of the "after_number" field.
  14541. func (m *CreditUsageMutation) ClearAfterNumber() {
  14542. m.after_number = nil
  14543. m.addafter_number = nil
  14544. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  14545. }
  14546. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  14547. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  14548. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  14549. return ok
  14550. }
  14551. // ResetAfterNumber resets all changes to the "after_number" field.
  14552. func (m *CreditUsageMutation) ResetAfterNumber() {
  14553. m.after_number = nil
  14554. m.addafter_number = nil
  14555. delete(m.clearedFields, creditusage.FieldAfterNumber)
  14556. }
  14557. // SetPayMethod sets the "pay_method" field.
  14558. func (m *CreditUsageMutation) SetPayMethod(s string) {
  14559. m.pay_method = &s
  14560. }
  14561. // PayMethod returns the value of the "pay_method" field in the mutation.
  14562. func (m *CreditUsageMutation) PayMethod() (r string, exists bool) {
  14563. v := m.pay_method
  14564. if v == nil {
  14565. return
  14566. }
  14567. return *v, true
  14568. }
  14569. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  14570. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14572. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v string, err error) {
  14573. if !m.op.Is(OpUpdateOne) {
  14574. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  14575. }
  14576. if m.id == nil || m.oldValue == nil {
  14577. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  14578. }
  14579. oldValue, err := m.oldValue(ctx)
  14580. if err != nil {
  14581. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  14582. }
  14583. return oldValue.PayMethod, nil
  14584. }
  14585. // ClearPayMethod clears the value of the "pay_method" field.
  14586. func (m *CreditUsageMutation) ClearPayMethod() {
  14587. m.pay_method = nil
  14588. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  14589. }
  14590. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  14591. func (m *CreditUsageMutation) PayMethodCleared() bool {
  14592. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  14593. return ok
  14594. }
  14595. // ResetPayMethod resets all changes to the "pay_method" field.
  14596. func (m *CreditUsageMutation) ResetPayMethod() {
  14597. m.pay_method = nil
  14598. delete(m.clearedFields, creditusage.FieldPayMethod)
  14599. }
  14600. // SetStatus sets the "status" field.
  14601. func (m *CreditUsageMutation) SetStatus(i int) {
  14602. m.status = &i
  14603. m.addstatus = nil
  14604. }
  14605. // Status returns the value of the "status" field in the mutation.
  14606. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  14607. v := m.status
  14608. if v == nil {
  14609. return
  14610. }
  14611. return *v, true
  14612. }
  14613. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  14614. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14616. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  14617. if !m.op.Is(OpUpdateOne) {
  14618. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14619. }
  14620. if m.id == nil || m.oldValue == nil {
  14621. return v, errors.New("OldStatus requires an ID field in the mutation")
  14622. }
  14623. oldValue, err := m.oldValue(ctx)
  14624. if err != nil {
  14625. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14626. }
  14627. return oldValue.Status, nil
  14628. }
  14629. // AddStatus adds i to the "status" field.
  14630. func (m *CreditUsageMutation) AddStatus(i int) {
  14631. if m.addstatus != nil {
  14632. *m.addstatus += i
  14633. } else {
  14634. m.addstatus = &i
  14635. }
  14636. }
  14637. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14638. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  14639. v := m.addstatus
  14640. if v == nil {
  14641. return
  14642. }
  14643. return *v, true
  14644. }
  14645. // ClearStatus clears the value of the "status" field.
  14646. func (m *CreditUsageMutation) ClearStatus() {
  14647. m.status = nil
  14648. m.addstatus = nil
  14649. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  14650. }
  14651. // StatusCleared returns if the "status" field was cleared in this mutation.
  14652. func (m *CreditUsageMutation) StatusCleared() bool {
  14653. _, ok := m.clearedFields[creditusage.FieldStatus]
  14654. return ok
  14655. }
  14656. // ResetStatus resets all changes to the "status" field.
  14657. func (m *CreditUsageMutation) ResetStatus() {
  14658. m.status = nil
  14659. m.addstatus = nil
  14660. delete(m.clearedFields, creditusage.FieldStatus)
  14661. }
  14662. // SetNtype sets the "ntype" field.
  14663. func (m *CreditUsageMutation) SetNtype(i int) {
  14664. m.ntype = &i
  14665. m.addntype = nil
  14666. }
  14667. // Ntype returns the value of the "ntype" field in the mutation.
  14668. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  14669. v := m.ntype
  14670. if v == nil {
  14671. return
  14672. }
  14673. return *v, true
  14674. }
  14675. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  14676. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14678. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  14679. if !m.op.Is(OpUpdateOne) {
  14680. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  14681. }
  14682. if m.id == nil || m.oldValue == nil {
  14683. return v, errors.New("OldNtype requires an ID field in the mutation")
  14684. }
  14685. oldValue, err := m.oldValue(ctx)
  14686. if err != nil {
  14687. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  14688. }
  14689. return oldValue.Ntype, nil
  14690. }
  14691. // AddNtype adds i to the "ntype" field.
  14692. func (m *CreditUsageMutation) AddNtype(i int) {
  14693. if m.addntype != nil {
  14694. *m.addntype += i
  14695. } else {
  14696. m.addntype = &i
  14697. }
  14698. }
  14699. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  14700. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  14701. v := m.addntype
  14702. if v == nil {
  14703. return
  14704. }
  14705. return *v, true
  14706. }
  14707. // ResetNtype resets all changes to the "ntype" field.
  14708. func (m *CreditUsageMutation) ResetNtype() {
  14709. m.ntype = nil
  14710. m.addntype = nil
  14711. }
  14712. // SetTable sets the "table" field.
  14713. func (m *CreditUsageMutation) SetTable(s string) {
  14714. m.table = &s
  14715. }
  14716. // Table returns the value of the "table" field in the mutation.
  14717. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  14718. v := m.table
  14719. if v == nil {
  14720. return
  14721. }
  14722. return *v, true
  14723. }
  14724. // OldTable returns the old "table" field's value of the CreditUsage entity.
  14725. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14727. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  14728. if !m.op.Is(OpUpdateOne) {
  14729. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  14730. }
  14731. if m.id == nil || m.oldValue == nil {
  14732. return v, errors.New("OldTable requires an ID field in the mutation")
  14733. }
  14734. oldValue, err := m.oldValue(ctx)
  14735. if err != nil {
  14736. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  14737. }
  14738. return oldValue.Table, nil
  14739. }
  14740. // ResetTable resets all changes to the "table" field.
  14741. func (m *CreditUsageMutation) ResetTable() {
  14742. m.table = nil
  14743. }
  14744. // SetOrganizationID sets the "organization_id" field.
  14745. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  14746. m.organization_id = &u
  14747. m.addorganization_id = nil
  14748. }
  14749. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14750. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  14751. v := m.organization_id
  14752. if v == nil {
  14753. return
  14754. }
  14755. return *v, true
  14756. }
  14757. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  14758. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14760. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14761. if !m.op.Is(OpUpdateOne) {
  14762. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14763. }
  14764. if m.id == nil || m.oldValue == nil {
  14765. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14766. }
  14767. oldValue, err := m.oldValue(ctx)
  14768. if err != nil {
  14769. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14770. }
  14771. return oldValue.OrganizationID, nil
  14772. }
  14773. // AddOrganizationID adds u to the "organization_id" field.
  14774. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  14775. if m.addorganization_id != nil {
  14776. *m.addorganization_id += u
  14777. } else {
  14778. m.addorganization_id = &u
  14779. }
  14780. }
  14781. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14782. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  14783. v := m.addorganization_id
  14784. if v == nil {
  14785. return
  14786. }
  14787. return *v, true
  14788. }
  14789. // ClearOrganizationID clears the value of the "organization_id" field.
  14790. func (m *CreditUsageMutation) ClearOrganizationID() {
  14791. m.organization_id = nil
  14792. m.addorganization_id = nil
  14793. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  14794. }
  14795. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14796. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  14797. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  14798. return ok
  14799. }
  14800. // ResetOrganizationID resets all changes to the "organization_id" field.
  14801. func (m *CreditUsageMutation) ResetOrganizationID() {
  14802. m.organization_id = nil
  14803. m.addorganization_id = nil
  14804. delete(m.clearedFields, creditusage.FieldOrganizationID)
  14805. }
  14806. // SetNid sets the "nid" field.
  14807. func (m *CreditUsageMutation) SetNid(u uint64) {
  14808. m.nid = &u
  14809. m.addnid = nil
  14810. }
  14811. // Nid returns the value of the "nid" field in the mutation.
  14812. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  14813. v := m.nid
  14814. if v == nil {
  14815. return
  14816. }
  14817. return *v, true
  14818. }
  14819. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  14820. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14822. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  14823. if !m.op.Is(OpUpdateOne) {
  14824. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  14825. }
  14826. if m.id == nil || m.oldValue == nil {
  14827. return v, errors.New("OldNid requires an ID field in the mutation")
  14828. }
  14829. oldValue, err := m.oldValue(ctx)
  14830. if err != nil {
  14831. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  14832. }
  14833. return oldValue.Nid, nil
  14834. }
  14835. // AddNid adds u to the "nid" field.
  14836. func (m *CreditUsageMutation) AddNid(u int64) {
  14837. if m.addnid != nil {
  14838. *m.addnid += u
  14839. } else {
  14840. m.addnid = &u
  14841. }
  14842. }
  14843. // AddedNid returns the value that was added to the "nid" field in this mutation.
  14844. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  14845. v := m.addnid
  14846. if v == nil {
  14847. return
  14848. }
  14849. return *v, true
  14850. }
  14851. // ResetNid resets all changes to the "nid" field.
  14852. func (m *CreditUsageMutation) ResetNid() {
  14853. m.nid = nil
  14854. m.addnid = nil
  14855. }
  14856. // SetReason sets the "reason" field.
  14857. func (m *CreditUsageMutation) SetReason(s string) {
  14858. m.reason = &s
  14859. }
  14860. // Reason returns the value of the "reason" field in the mutation.
  14861. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  14862. v := m.reason
  14863. if v == nil {
  14864. return
  14865. }
  14866. return *v, true
  14867. }
  14868. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  14869. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14871. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  14872. if !m.op.Is(OpUpdateOne) {
  14873. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  14874. }
  14875. if m.id == nil || m.oldValue == nil {
  14876. return v, errors.New("OldReason requires an ID field in the mutation")
  14877. }
  14878. oldValue, err := m.oldValue(ctx)
  14879. if err != nil {
  14880. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  14881. }
  14882. return oldValue.Reason, nil
  14883. }
  14884. // ResetReason resets all changes to the "reason" field.
  14885. func (m *CreditUsageMutation) ResetReason() {
  14886. m.reason = nil
  14887. }
  14888. // SetOperator sets the "operator" field.
  14889. func (m *CreditUsageMutation) SetOperator(s string) {
  14890. m.operator = &s
  14891. }
  14892. // Operator returns the value of the "operator" field in the mutation.
  14893. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  14894. v := m.operator
  14895. if v == nil {
  14896. return
  14897. }
  14898. return *v, true
  14899. }
  14900. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  14901. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  14902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14903. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  14904. if !m.op.Is(OpUpdateOne) {
  14905. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  14906. }
  14907. if m.id == nil || m.oldValue == nil {
  14908. return v, errors.New("OldOperator requires an ID field in the mutation")
  14909. }
  14910. oldValue, err := m.oldValue(ctx)
  14911. if err != nil {
  14912. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  14913. }
  14914. return oldValue.Operator, nil
  14915. }
  14916. // ResetOperator resets all changes to the "operator" field.
  14917. func (m *CreditUsageMutation) ResetOperator() {
  14918. m.operator = nil
  14919. }
  14920. // Where appends a list predicates to the CreditUsageMutation builder.
  14921. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  14922. m.predicates = append(m.predicates, ps...)
  14923. }
  14924. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  14925. // users can use type-assertion to append predicates that do not depend on any generated package.
  14926. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  14927. p := make([]predicate.CreditUsage, len(ps))
  14928. for i := range ps {
  14929. p[i] = ps[i]
  14930. }
  14931. m.Where(p...)
  14932. }
  14933. // Op returns the operation name.
  14934. func (m *CreditUsageMutation) Op() Op {
  14935. return m.op
  14936. }
  14937. // SetOp allows setting the mutation operation.
  14938. func (m *CreditUsageMutation) SetOp(op Op) {
  14939. m.op = op
  14940. }
  14941. // Type returns the node type of this mutation (CreditUsage).
  14942. func (m *CreditUsageMutation) Type() string {
  14943. return m.typ
  14944. }
  14945. // Fields returns all fields that were changed during this mutation. Note that in
  14946. // order to get all numeric fields that were incremented/decremented, call
  14947. // AddedFields().
  14948. func (m *CreditUsageMutation) Fields() []string {
  14949. fields := make([]string, 0, 16)
  14950. if m.created_at != nil {
  14951. fields = append(fields, creditusage.FieldCreatedAt)
  14952. }
  14953. if m.updated_at != nil {
  14954. fields = append(fields, creditusage.FieldUpdatedAt)
  14955. }
  14956. if m.deleted_at != nil {
  14957. fields = append(fields, creditusage.FieldDeletedAt)
  14958. }
  14959. if m.user_id != nil {
  14960. fields = append(fields, creditusage.FieldUserID)
  14961. }
  14962. if m.number != nil {
  14963. fields = append(fields, creditusage.FieldNumber)
  14964. }
  14965. if m.pay_number != nil {
  14966. fields = append(fields, creditusage.FieldPayNumber)
  14967. }
  14968. if m.before_number != nil {
  14969. fields = append(fields, creditusage.FieldBeforeNumber)
  14970. }
  14971. if m.after_number != nil {
  14972. fields = append(fields, creditusage.FieldAfterNumber)
  14973. }
  14974. if m.pay_method != nil {
  14975. fields = append(fields, creditusage.FieldPayMethod)
  14976. }
  14977. if m.status != nil {
  14978. fields = append(fields, creditusage.FieldStatus)
  14979. }
  14980. if m.ntype != nil {
  14981. fields = append(fields, creditusage.FieldNtype)
  14982. }
  14983. if m.table != nil {
  14984. fields = append(fields, creditusage.FieldTable)
  14985. }
  14986. if m.organization_id != nil {
  14987. fields = append(fields, creditusage.FieldOrganizationID)
  14988. }
  14989. if m.nid != nil {
  14990. fields = append(fields, creditusage.FieldNid)
  14991. }
  14992. if m.reason != nil {
  14993. fields = append(fields, creditusage.FieldReason)
  14994. }
  14995. if m.operator != nil {
  14996. fields = append(fields, creditusage.FieldOperator)
  14997. }
  14998. return fields
  14999. }
  15000. // Field returns the value of a field with the given name. The second boolean
  15001. // return value indicates that this field was not set, or was not defined in the
  15002. // schema.
  15003. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  15004. switch name {
  15005. case creditusage.FieldCreatedAt:
  15006. return m.CreatedAt()
  15007. case creditusage.FieldUpdatedAt:
  15008. return m.UpdatedAt()
  15009. case creditusage.FieldDeletedAt:
  15010. return m.DeletedAt()
  15011. case creditusage.FieldUserID:
  15012. return m.UserID()
  15013. case creditusage.FieldNumber:
  15014. return m.Number()
  15015. case creditusage.FieldPayNumber:
  15016. return m.PayNumber()
  15017. case creditusage.FieldBeforeNumber:
  15018. return m.BeforeNumber()
  15019. case creditusage.FieldAfterNumber:
  15020. return m.AfterNumber()
  15021. case creditusage.FieldPayMethod:
  15022. return m.PayMethod()
  15023. case creditusage.FieldStatus:
  15024. return m.Status()
  15025. case creditusage.FieldNtype:
  15026. return m.Ntype()
  15027. case creditusage.FieldTable:
  15028. return m.Table()
  15029. case creditusage.FieldOrganizationID:
  15030. return m.OrganizationID()
  15031. case creditusage.FieldNid:
  15032. return m.Nid()
  15033. case creditusage.FieldReason:
  15034. return m.Reason()
  15035. case creditusage.FieldOperator:
  15036. return m.Operator()
  15037. }
  15038. return nil, false
  15039. }
  15040. // OldField returns the old value of the field from the database. An error is
  15041. // returned if the mutation operation is not UpdateOne, or the query to the
  15042. // database failed.
  15043. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15044. switch name {
  15045. case creditusage.FieldCreatedAt:
  15046. return m.OldCreatedAt(ctx)
  15047. case creditusage.FieldUpdatedAt:
  15048. return m.OldUpdatedAt(ctx)
  15049. case creditusage.FieldDeletedAt:
  15050. return m.OldDeletedAt(ctx)
  15051. case creditusage.FieldUserID:
  15052. return m.OldUserID(ctx)
  15053. case creditusage.FieldNumber:
  15054. return m.OldNumber(ctx)
  15055. case creditusage.FieldPayNumber:
  15056. return m.OldPayNumber(ctx)
  15057. case creditusage.FieldBeforeNumber:
  15058. return m.OldBeforeNumber(ctx)
  15059. case creditusage.FieldAfterNumber:
  15060. return m.OldAfterNumber(ctx)
  15061. case creditusage.FieldPayMethod:
  15062. return m.OldPayMethod(ctx)
  15063. case creditusage.FieldStatus:
  15064. return m.OldStatus(ctx)
  15065. case creditusage.FieldNtype:
  15066. return m.OldNtype(ctx)
  15067. case creditusage.FieldTable:
  15068. return m.OldTable(ctx)
  15069. case creditusage.FieldOrganizationID:
  15070. return m.OldOrganizationID(ctx)
  15071. case creditusage.FieldNid:
  15072. return m.OldNid(ctx)
  15073. case creditusage.FieldReason:
  15074. return m.OldReason(ctx)
  15075. case creditusage.FieldOperator:
  15076. return m.OldOperator(ctx)
  15077. }
  15078. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  15079. }
  15080. // SetField sets the value of a field with the given name. It returns an error if
  15081. // the field is not defined in the schema, or if the type mismatched the field
  15082. // type.
  15083. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  15084. switch name {
  15085. case creditusage.FieldCreatedAt:
  15086. v, ok := value.(time.Time)
  15087. if !ok {
  15088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15089. }
  15090. m.SetCreatedAt(v)
  15091. return nil
  15092. case creditusage.FieldUpdatedAt:
  15093. v, ok := value.(time.Time)
  15094. if !ok {
  15095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15096. }
  15097. m.SetUpdatedAt(v)
  15098. return nil
  15099. case creditusage.FieldDeletedAt:
  15100. v, ok := value.(time.Time)
  15101. if !ok {
  15102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15103. }
  15104. m.SetDeletedAt(v)
  15105. return nil
  15106. case creditusage.FieldUserID:
  15107. v, ok := value.(string)
  15108. if !ok {
  15109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15110. }
  15111. m.SetUserID(v)
  15112. return nil
  15113. case creditusage.FieldNumber:
  15114. v, ok := value.(float64)
  15115. if !ok {
  15116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15117. }
  15118. m.SetNumber(v)
  15119. return nil
  15120. case creditusage.FieldPayNumber:
  15121. v, ok := value.(float64)
  15122. if !ok {
  15123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15124. }
  15125. m.SetPayNumber(v)
  15126. return nil
  15127. case creditusage.FieldBeforeNumber:
  15128. v, ok := value.(float64)
  15129. if !ok {
  15130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15131. }
  15132. m.SetBeforeNumber(v)
  15133. return nil
  15134. case creditusage.FieldAfterNumber:
  15135. v, ok := value.(float64)
  15136. if !ok {
  15137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15138. }
  15139. m.SetAfterNumber(v)
  15140. return nil
  15141. case creditusage.FieldPayMethod:
  15142. v, ok := value.(string)
  15143. if !ok {
  15144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15145. }
  15146. m.SetPayMethod(v)
  15147. return nil
  15148. case creditusage.FieldStatus:
  15149. v, ok := value.(int)
  15150. if !ok {
  15151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15152. }
  15153. m.SetStatus(v)
  15154. return nil
  15155. case creditusage.FieldNtype:
  15156. v, ok := value.(int)
  15157. if !ok {
  15158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15159. }
  15160. m.SetNtype(v)
  15161. return nil
  15162. case creditusage.FieldTable:
  15163. v, ok := value.(string)
  15164. if !ok {
  15165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15166. }
  15167. m.SetTable(v)
  15168. return nil
  15169. case creditusage.FieldOrganizationID:
  15170. v, ok := value.(uint64)
  15171. if !ok {
  15172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15173. }
  15174. m.SetOrganizationID(v)
  15175. return nil
  15176. case creditusage.FieldNid:
  15177. v, ok := value.(uint64)
  15178. if !ok {
  15179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15180. }
  15181. m.SetNid(v)
  15182. return nil
  15183. case creditusage.FieldReason:
  15184. v, ok := value.(string)
  15185. if !ok {
  15186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15187. }
  15188. m.SetReason(v)
  15189. return nil
  15190. case creditusage.FieldOperator:
  15191. v, ok := value.(string)
  15192. if !ok {
  15193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15194. }
  15195. m.SetOperator(v)
  15196. return nil
  15197. }
  15198. return fmt.Errorf("unknown CreditUsage field %s", name)
  15199. }
  15200. // AddedFields returns all numeric fields that were incremented/decremented during
  15201. // this mutation.
  15202. func (m *CreditUsageMutation) AddedFields() []string {
  15203. var fields []string
  15204. if m.addnumber != nil {
  15205. fields = append(fields, creditusage.FieldNumber)
  15206. }
  15207. if m.addpay_number != nil {
  15208. fields = append(fields, creditusage.FieldPayNumber)
  15209. }
  15210. if m.addbefore_number != nil {
  15211. fields = append(fields, creditusage.FieldBeforeNumber)
  15212. }
  15213. if m.addafter_number != nil {
  15214. fields = append(fields, creditusage.FieldAfterNumber)
  15215. }
  15216. if m.addstatus != nil {
  15217. fields = append(fields, creditusage.FieldStatus)
  15218. }
  15219. if m.addntype != nil {
  15220. fields = append(fields, creditusage.FieldNtype)
  15221. }
  15222. if m.addorganization_id != nil {
  15223. fields = append(fields, creditusage.FieldOrganizationID)
  15224. }
  15225. if m.addnid != nil {
  15226. fields = append(fields, creditusage.FieldNid)
  15227. }
  15228. return fields
  15229. }
  15230. // AddedField returns the numeric value that was incremented/decremented on a field
  15231. // with the given name. The second boolean return value indicates that this field
  15232. // was not set, or was not defined in the schema.
  15233. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  15234. switch name {
  15235. case creditusage.FieldNumber:
  15236. return m.AddedNumber()
  15237. case creditusage.FieldPayNumber:
  15238. return m.AddedPayNumber()
  15239. case creditusage.FieldBeforeNumber:
  15240. return m.AddedBeforeNumber()
  15241. case creditusage.FieldAfterNumber:
  15242. return m.AddedAfterNumber()
  15243. case creditusage.FieldStatus:
  15244. return m.AddedStatus()
  15245. case creditusage.FieldNtype:
  15246. return m.AddedNtype()
  15247. case creditusage.FieldOrganizationID:
  15248. return m.AddedOrganizationID()
  15249. case creditusage.FieldNid:
  15250. return m.AddedNid()
  15251. }
  15252. return nil, false
  15253. }
  15254. // AddField adds the value to the field with the given name. It returns an error if
  15255. // the field is not defined in the schema, or if the type mismatched the field
  15256. // type.
  15257. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  15258. switch name {
  15259. case creditusage.FieldNumber:
  15260. v, ok := value.(float64)
  15261. if !ok {
  15262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15263. }
  15264. m.AddNumber(v)
  15265. return nil
  15266. case creditusage.FieldPayNumber:
  15267. v, ok := value.(float64)
  15268. if !ok {
  15269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15270. }
  15271. m.AddPayNumber(v)
  15272. return nil
  15273. case creditusage.FieldBeforeNumber:
  15274. v, ok := value.(float64)
  15275. if !ok {
  15276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15277. }
  15278. m.AddBeforeNumber(v)
  15279. return nil
  15280. case creditusage.FieldAfterNumber:
  15281. v, ok := value.(float64)
  15282. if !ok {
  15283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15284. }
  15285. m.AddAfterNumber(v)
  15286. return nil
  15287. case creditusage.FieldStatus:
  15288. v, ok := value.(int)
  15289. if !ok {
  15290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15291. }
  15292. m.AddStatus(v)
  15293. return nil
  15294. case creditusage.FieldNtype:
  15295. v, ok := value.(int)
  15296. if !ok {
  15297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15298. }
  15299. m.AddNtype(v)
  15300. return nil
  15301. case creditusage.FieldOrganizationID:
  15302. v, ok := value.(int64)
  15303. if !ok {
  15304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15305. }
  15306. m.AddOrganizationID(v)
  15307. return nil
  15308. case creditusage.FieldNid:
  15309. v, ok := value.(int64)
  15310. if !ok {
  15311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15312. }
  15313. m.AddNid(v)
  15314. return nil
  15315. }
  15316. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  15317. }
  15318. // ClearedFields returns all nullable fields that were cleared during this
  15319. // mutation.
  15320. func (m *CreditUsageMutation) ClearedFields() []string {
  15321. var fields []string
  15322. if m.FieldCleared(creditusage.FieldDeletedAt) {
  15323. fields = append(fields, creditusage.FieldDeletedAt)
  15324. }
  15325. if m.FieldCleared(creditusage.FieldUserID) {
  15326. fields = append(fields, creditusage.FieldUserID)
  15327. }
  15328. if m.FieldCleared(creditusage.FieldPayNumber) {
  15329. fields = append(fields, creditusage.FieldPayNumber)
  15330. }
  15331. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  15332. fields = append(fields, creditusage.FieldBeforeNumber)
  15333. }
  15334. if m.FieldCleared(creditusage.FieldAfterNumber) {
  15335. fields = append(fields, creditusage.FieldAfterNumber)
  15336. }
  15337. if m.FieldCleared(creditusage.FieldPayMethod) {
  15338. fields = append(fields, creditusage.FieldPayMethod)
  15339. }
  15340. if m.FieldCleared(creditusage.FieldStatus) {
  15341. fields = append(fields, creditusage.FieldStatus)
  15342. }
  15343. if m.FieldCleared(creditusage.FieldOrganizationID) {
  15344. fields = append(fields, creditusage.FieldOrganizationID)
  15345. }
  15346. return fields
  15347. }
  15348. // FieldCleared returns a boolean indicating if a field with the given name was
  15349. // cleared in this mutation.
  15350. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  15351. _, ok := m.clearedFields[name]
  15352. return ok
  15353. }
  15354. // ClearField clears the value of the field with the given name. It returns an
  15355. // error if the field is not defined in the schema.
  15356. func (m *CreditUsageMutation) ClearField(name string) error {
  15357. switch name {
  15358. case creditusage.FieldDeletedAt:
  15359. m.ClearDeletedAt()
  15360. return nil
  15361. case creditusage.FieldUserID:
  15362. m.ClearUserID()
  15363. return nil
  15364. case creditusage.FieldPayNumber:
  15365. m.ClearPayNumber()
  15366. return nil
  15367. case creditusage.FieldBeforeNumber:
  15368. m.ClearBeforeNumber()
  15369. return nil
  15370. case creditusage.FieldAfterNumber:
  15371. m.ClearAfterNumber()
  15372. return nil
  15373. case creditusage.FieldPayMethod:
  15374. m.ClearPayMethod()
  15375. return nil
  15376. case creditusage.FieldStatus:
  15377. m.ClearStatus()
  15378. return nil
  15379. case creditusage.FieldOrganizationID:
  15380. m.ClearOrganizationID()
  15381. return nil
  15382. }
  15383. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  15384. }
  15385. // ResetField resets all changes in the mutation for the field with the given name.
  15386. // It returns an error if the field is not defined in the schema.
  15387. func (m *CreditUsageMutation) ResetField(name string) error {
  15388. switch name {
  15389. case creditusage.FieldCreatedAt:
  15390. m.ResetCreatedAt()
  15391. return nil
  15392. case creditusage.FieldUpdatedAt:
  15393. m.ResetUpdatedAt()
  15394. return nil
  15395. case creditusage.FieldDeletedAt:
  15396. m.ResetDeletedAt()
  15397. return nil
  15398. case creditusage.FieldUserID:
  15399. m.ResetUserID()
  15400. return nil
  15401. case creditusage.FieldNumber:
  15402. m.ResetNumber()
  15403. return nil
  15404. case creditusage.FieldPayNumber:
  15405. m.ResetPayNumber()
  15406. return nil
  15407. case creditusage.FieldBeforeNumber:
  15408. m.ResetBeforeNumber()
  15409. return nil
  15410. case creditusage.FieldAfterNumber:
  15411. m.ResetAfterNumber()
  15412. return nil
  15413. case creditusage.FieldPayMethod:
  15414. m.ResetPayMethod()
  15415. return nil
  15416. case creditusage.FieldStatus:
  15417. m.ResetStatus()
  15418. return nil
  15419. case creditusage.FieldNtype:
  15420. m.ResetNtype()
  15421. return nil
  15422. case creditusage.FieldTable:
  15423. m.ResetTable()
  15424. return nil
  15425. case creditusage.FieldOrganizationID:
  15426. m.ResetOrganizationID()
  15427. return nil
  15428. case creditusage.FieldNid:
  15429. m.ResetNid()
  15430. return nil
  15431. case creditusage.FieldReason:
  15432. m.ResetReason()
  15433. return nil
  15434. case creditusage.FieldOperator:
  15435. m.ResetOperator()
  15436. return nil
  15437. }
  15438. return fmt.Errorf("unknown CreditUsage field %s", name)
  15439. }
  15440. // AddedEdges returns all edge names that were set/added in this mutation.
  15441. func (m *CreditUsageMutation) AddedEdges() []string {
  15442. edges := make([]string, 0, 0)
  15443. return edges
  15444. }
  15445. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15446. // name in this mutation.
  15447. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  15448. return nil
  15449. }
  15450. // RemovedEdges returns all edge names that were removed in this mutation.
  15451. func (m *CreditUsageMutation) RemovedEdges() []string {
  15452. edges := make([]string, 0, 0)
  15453. return edges
  15454. }
  15455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15456. // the given name in this mutation.
  15457. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  15458. return nil
  15459. }
  15460. // ClearedEdges returns all edge names that were cleared in this mutation.
  15461. func (m *CreditUsageMutation) ClearedEdges() []string {
  15462. edges := make([]string, 0, 0)
  15463. return edges
  15464. }
  15465. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15466. // was cleared in this mutation.
  15467. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  15468. return false
  15469. }
  15470. // ClearEdge clears the value of the edge with the given name. It returns an error
  15471. // if that edge is not defined in the schema.
  15472. func (m *CreditUsageMutation) ClearEdge(name string) error {
  15473. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  15474. }
  15475. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15476. // It returns an error if the edge is not defined in the schema.
  15477. func (m *CreditUsageMutation) ResetEdge(name string) error {
  15478. return fmt.Errorf("unknown CreditUsage edge %s", name)
  15479. }
  15480. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  15481. type EmployeeMutation struct {
  15482. config
  15483. op Op
  15484. typ string
  15485. id *uint64
  15486. created_at *time.Time
  15487. updated_at *time.Time
  15488. deleted_at *time.Time
  15489. title *string
  15490. avatar *string
  15491. tags *string
  15492. hire_count *int
  15493. addhire_count *int
  15494. service_count *int
  15495. addservice_count *int
  15496. achievement_count *int
  15497. addachievement_count *int
  15498. intro *string
  15499. estimate *string
  15500. skill *string
  15501. ability_type *string
  15502. scene *string
  15503. switch_in *string
  15504. video_url *string
  15505. organization_id *uint64
  15506. addorganization_id *int64
  15507. category_id *uint64
  15508. addcategory_id *int64
  15509. api_base *string
  15510. api_key *string
  15511. ai_info *string
  15512. is_vip *int
  15513. addis_vip *int
  15514. chat_url *string
  15515. clearedFields map[string]struct{}
  15516. em_work_experiences map[uint64]struct{}
  15517. removedem_work_experiences map[uint64]struct{}
  15518. clearedem_work_experiences bool
  15519. em_tutorial map[uint64]struct{}
  15520. removedem_tutorial map[uint64]struct{}
  15521. clearedem_tutorial bool
  15522. done bool
  15523. oldValue func(context.Context) (*Employee, error)
  15524. predicates []predicate.Employee
  15525. }
  15526. var _ ent.Mutation = (*EmployeeMutation)(nil)
  15527. // employeeOption allows management of the mutation configuration using functional options.
  15528. type employeeOption func(*EmployeeMutation)
  15529. // newEmployeeMutation creates new mutation for the Employee entity.
  15530. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  15531. m := &EmployeeMutation{
  15532. config: c,
  15533. op: op,
  15534. typ: TypeEmployee,
  15535. clearedFields: make(map[string]struct{}),
  15536. }
  15537. for _, opt := range opts {
  15538. opt(m)
  15539. }
  15540. return m
  15541. }
  15542. // withEmployeeID sets the ID field of the mutation.
  15543. func withEmployeeID(id uint64) employeeOption {
  15544. return func(m *EmployeeMutation) {
  15545. var (
  15546. err error
  15547. once sync.Once
  15548. value *Employee
  15549. )
  15550. m.oldValue = func(ctx context.Context) (*Employee, error) {
  15551. once.Do(func() {
  15552. if m.done {
  15553. err = errors.New("querying old values post mutation is not allowed")
  15554. } else {
  15555. value, err = m.Client().Employee.Get(ctx, id)
  15556. }
  15557. })
  15558. return value, err
  15559. }
  15560. m.id = &id
  15561. }
  15562. }
  15563. // withEmployee sets the old Employee of the mutation.
  15564. func withEmployee(node *Employee) employeeOption {
  15565. return func(m *EmployeeMutation) {
  15566. m.oldValue = func(context.Context) (*Employee, error) {
  15567. return node, nil
  15568. }
  15569. m.id = &node.ID
  15570. }
  15571. }
  15572. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15573. // executed in a transaction (ent.Tx), a transactional client is returned.
  15574. func (m EmployeeMutation) Client() *Client {
  15575. client := &Client{config: m.config}
  15576. client.init()
  15577. return client
  15578. }
  15579. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15580. // it returns an error otherwise.
  15581. func (m EmployeeMutation) Tx() (*Tx, error) {
  15582. if _, ok := m.driver.(*txDriver); !ok {
  15583. return nil, errors.New("ent: mutation is not running in a transaction")
  15584. }
  15585. tx := &Tx{config: m.config}
  15586. tx.init()
  15587. return tx, nil
  15588. }
  15589. // SetID sets the value of the id field. Note that this
  15590. // operation is only accepted on creation of Employee entities.
  15591. func (m *EmployeeMutation) SetID(id uint64) {
  15592. m.id = &id
  15593. }
  15594. // ID returns the ID value in the mutation. Note that the ID is only available
  15595. // if it was provided to the builder or after it was returned from the database.
  15596. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  15597. if m.id == nil {
  15598. return
  15599. }
  15600. return *m.id, true
  15601. }
  15602. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15603. // That means, if the mutation is applied within a transaction with an isolation level such
  15604. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15605. // or updated by the mutation.
  15606. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  15607. switch {
  15608. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15609. id, exists := m.ID()
  15610. if exists {
  15611. return []uint64{id}, nil
  15612. }
  15613. fallthrough
  15614. case m.op.Is(OpUpdate | OpDelete):
  15615. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  15616. default:
  15617. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15618. }
  15619. }
  15620. // SetCreatedAt sets the "created_at" field.
  15621. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  15622. m.created_at = &t
  15623. }
  15624. // CreatedAt returns the value of the "created_at" field in the mutation.
  15625. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  15626. v := m.created_at
  15627. if v == nil {
  15628. return
  15629. }
  15630. return *v, true
  15631. }
  15632. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  15633. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15635. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15636. if !m.op.Is(OpUpdateOne) {
  15637. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15638. }
  15639. if m.id == nil || m.oldValue == nil {
  15640. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15641. }
  15642. oldValue, err := m.oldValue(ctx)
  15643. if err != nil {
  15644. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15645. }
  15646. return oldValue.CreatedAt, nil
  15647. }
  15648. // ResetCreatedAt resets all changes to the "created_at" field.
  15649. func (m *EmployeeMutation) ResetCreatedAt() {
  15650. m.created_at = nil
  15651. }
  15652. // SetUpdatedAt sets the "updated_at" field.
  15653. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  15654. m.updated_at = &t
  15655. }
  15656. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15657. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  15658. v := m.updated_at
  15659. if v == nil {
  15660. return
  15661. }
  15662. return *v, true
  15663. }
  15664. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  15665. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15667. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15668. if !m.op.Is(OpUpdateOne) {
  15669. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15670. }
  15671. if m.id == nil || m.oldValue == nil {
  15672. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15673. }
  15674. oldValue, err := m.oldValue(ctx)
  15675. if err != nil {
  15676. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15677. }
  15678. return oldValue.UpdatedAt, nil
  15679. }
  15680. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15681. func (m *EmployeeMutation) ResetUpdatedAt() {
  15682. m.updated_at = nil
  15683. }
  15684. // SetDeletedAt sets the "deleted_at" field.
  15685. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  15686. m.deleted_at = &t
  15687. }
  15688. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15689. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  15690. v := m.deleted_at
  15691. if v == nil {
  15692. return
  15693. }
  15694. return *v, true
  15695. }
  15696. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  15697. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15699. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15700. if !m.op.Is(OpUpdateOne) {
  15701. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15702. }
  15703. if m.id == nil || m.oldValue == nil {
  15704. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15705. }
  15706. oldValue, err := m.oldValue(ctx)
  15707. if err != nil {
  15708. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15709. }
  15710. return oldValue.DeletedAt, nil
  15711. }
  15712. // ClearDeletedAt clears the value of the "deleted_at" field.
  15713. func (m *EmployeeMutation) ClearDeletedAt() {
  15714. m.deleted_at = nil
  15715. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  15716. }
  15717. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15718. func (m *EmployeeMutation) DeletedAtCleared() bool {
  15719. _, ok := m.clearedFields[employee.FieldDeletedAt]
  15720. return ok
  15721. }
  15722. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15723. func (m *EmployeeMutation) ResetDeletedAt() {
  15724. m.deleted_at = nil
  15725. delete(m.clearedFields, employee.FieldDeletedAt)
  15726. }
  15727. // SetTitle sets the "title" field.
  15728. func (m *EmployeeMutation) SetTitle(s string) {
  15729. m.title = &s
  15730. }
  15731. // Title returns the value of the "title" field in the mutation.
  15732. func (m *EmployeeMutation) Title() (r string, exists bool) {
  15733. v := m.title
  15734. if v == nil {
  15735. return
  15736. }
  15737. return *v, true
  15738. }
  15739. // OldTitle returns the old "title" field's value of the Employee entity.
  15740. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15742. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  15743. if !m.op.Is(OpUpdateOne) {
  15744. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15745. }
  15746. if m.id == nil || m.oldValue == nil {
  15747. return v, errors.New("OldTitle requires an ID field in the mutation")
  15748. }
  15749. oldValue, err := m.oldValue(ctx)
  15750. if err != nil {
  15751. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15752. }
  15753. return oldValue.Title, nil
  15754. }
  15755. // ResetTitle resets all changes to the "title" field.
  15756. func (m *EmployeeMutation) ResetTitle() {
  15757. m.title = nil
  15758. }
  15759. // SetAvatar sets the "avatar" field.
  15760. func (m *EmployeeMutation) SetAvatar(s string) {
  15761. m.avatar = &s
  15762. }
  15763. // Avatar returns the value of the "avatar" field in the mutation.
  15764. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  15765. v := m.avatar
  15766. if v == nil {
  15767. return
  15768. }
  15769. return *v, true
  15770. }
  15771. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  15772. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15774. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  15775. if !m.op.Is(OpUpdateOne) {
  15776. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  15777. }
  15778. if m.id == nil || m.oldValue == nil {
  15779. return v, errors.New("OldAvatar requires an ID field in the mutation")
  15780. }
  15781. oldValue, err := m.oldValue(ctx)
  15782. if err != nil {
  15783. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  15784. }
  15785. return oldValue.Avatar, nil
  15786. }
  15787. // ResetAvatar resets all changes to the "avatar" field.
  15788. func (m *EmployeeMutation) ResetAvatar() {
  15789. m.avatar = nil
  15790. }
  15791. // SetTags sets the "tags" field.
  15792. func (m *EmployeeMutation) SetTags(s string) {
  15793. m.tags = &s
  15794. }
  15795. // Tags returns the value of the "tags" field in the mutation.
  15796. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  15797. v := m.tags
  15798. if v == nil {
  15799. return
  15800. }
  15801. return *v, true
  15802. }
  15803. // OldTags returns the old "tags" field's value of the Employee entity.
  15804. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15806. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  15807. if !m.op.Is(OpUpdateOne) {
  15808. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  15809. }
  15810. if m.id == nil || m.oldValue == nil {
  15811. return v, errors.New("OldTags requires an ID field in the mutation")
  15812. }
  15813. oldValue, err := m.oldValue(ctx)
  15814. if err != nil {
  15815. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  15816. }
  15817. return oldValue.Tags, nil
  15818. }
  15819. // ResetTags resets all changes to the "tags" field.
  15820. func (m *EmployeeMutation) ResetTags() {
  15821. m.tags = nil
  15822. }
  15823. // SetHireCount sets the "hire_count" field.
  15824. func (m *EmployeeMutation) SetHireCount(i int) {
  15825. m.hire_count = &i
  15826. m.addhire_count = nil
  15827. }
  15828. // HireCount returns the value of the "hire_count" field in the mutation.
  15829. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  15830. v := m.hire_count
  15831. if v == nil {
  15832. return
  15833. }
  15834. return *v, true
  15835. }
  15836. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  15837. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15839. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  15840. if !m.op.Is(OpUpdateOne) {
  15841. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  15842. }
  15843. if m.id == nil || m.oldValue == nil {
  15844. return v, errors.New("OldHireCount requires an ID field in the mutation")
  15845. }
  15846. oldValue, err := m.oldValue(ctx)
  15847. if err != nil {
  15848. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  15849. }
  15850. return oldValue.HireCount, nil
  15851. }
  15852. // AddHireCount adds i to the "hire_count" field.
  15853. func (m *EmployeeMutation) AddHireCount(i int) {
  15854. if m.addhire_count != nil {
  15855. *m.addhire_count += i
  15856. } else {
  15857. m.addhire_count = &i
  15858. }
  15859. }
  15860. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  15861. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  15862. v := m.addhire_count
  15863. if v == nil {
  15864. return
  15865. }
  15866. return *v, true
  15867. }
  15868. // ResetHireCount resets all changes to the "hire_count" field.
  15869. func (m *EmployeeMutation) ResetHireCount() {
  15870. m.hire_count = nil
  15871. m.addhire_count = nil
  15872. }
  15873. // SetServiceCount sets the "service_count" field.
  15874. func (m *EmployeeMutation) SetServiceCount(i int) {
  15875. m.service_count = &i
  15876. m.addservice_count = nil
  15877. }
  15878. // ServiceCount returns the value of the "service_count" field in the mutation.
  15879. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  15880. v := m.service_count
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  15887. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  15899. }
  15900. return oldValue.ServiceCount, nil
  15901. }
  15902. // AddServiceCount adds i to the "service_count" field.
  15903. func (m *EmployeeMutation) AddServiceCount(i int) {
  15904. if m.addservice_count != nil {
  15905. *m.addservice_count += i
  15906. } else {
  15907. m.addservice_count = &i
  15908. }
  15909. }
  15910. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  15911. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  15912. v := m.addservice_count
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // ResetServiceCount resets all changes to the "service_count" field.
  15919. func (m *EmployeeMutation) ResetServiceCount() {
  15920. m.service_count = nil
  15921. m.addservice_count = nil
  15922. }
  15923. // SetAchievementCount sets the "achievement_count" field.
  15924. func (m *EmployeeMutation) SetAchievementCount(i int) {
  15925. m.achievement_count = &i
  15926. m.addachievement_count = nil
  15927. }
  15928. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  15929. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  15930. v := m.achievement_count
  15931. if v == nil {
  15932. return
  15933. }
  15934. return *v, true
  15935. }
  15936. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  15937. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15939. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  15940. if !m.op.Is(OpUpdateOne) {
  15941. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  15942. }
  15943. if m.id == nil || m.oldValue == nil {
  15944. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  15945. }
  15946. oldValue, err := m.oldValue(ctx)
  15947. if err != nil {
  15948. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  15949. }
  15950. return oldValue.AchievementCount, nil
  15951. }
  15952. // AddAchievementCount adds i to the "achievement_count" field.
  15953. func (m *EmployeeMutation) AddAchievementCount(i int) {
  15954. if m.addachievement_count != nil {
  15955. *m.addachievement_count += i
  15956. } else {
  15957. m.addachievement_count = &i
  15958. }
  15959. }
  15960. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  15961. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  15962. v := m.addachievement_count
  15963. if v == nil {
  15964. return
  15965. }
  15966. return *v, true
  15967. }
  15968. // ResetAchievementCount resets all changes to the "achievement_count" field.
  15969. func (m *EmployeeMutation) ResetAchievementCount() {
  15970. m.achievement_count = nil
  15971. m.addachievement_count = nil
  15972. }
  15973. // SetIntro sets the "intro" field.
  15974. func (m *EmployeeMutation) SetIntro(s string) {
  15975. m.intro = &s
  15976. }
  15977. // Intro returns the value of the "intro" field in the mutation.
  15978. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  15979. v := m.intro
  15980. if v == nil {
  15981. return
  15982. }
  15983. return *v, true
  15984. }
  15985. // OldIntro returns the old "intro" field's value of the Employee entity.
  15986. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15988. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  15989. if !m.op.Is(OpUpdateOne) {
  15990. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  15991. }
  15992. if m.id == nil || m.oldValue == nil {
  15993. return v, errors.New("OldIntro requires an ID field in the mutation")
  15994. }
  15995. oldValue, err := m.oldValue(ctx)
  15996. if err != nil {
  15997. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  15998. }
  15999. return oldValue.Intro, nil
  16000. }
  16001. // ResetIntro resets all changes to the "intro" field.
  16002. func (m *EmployeeMutation) ResetIntro() {
  16003. m.intro = nil
  16004. }
  16005. // SetEstimate sets the "estimate" field.
  16006. func (m *EmployeeMutation) SetEstimate(s string) {
  16007. m.estimate = &s
  16008. }
  16009. // Estimate returns the value of the "estimate" field in the mutation.
  16010. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  16011. v := m.estimate
  16012. if v == nil {
  16013. return
  16014. }
  16015. return *v, true
  16016. }
  16017. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  16018. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16020. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  16021. if !m.op.Is(OpUpdateOne) {
  16022. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  16023. }
  16024. if m.id == nil || m.oldValue == nil {
  16025. return v, errors.New("OldEstimate requires an ID field in the mutation")
  16026. }
  16027. oldValue, err := m.oldValue(ctx)
  16028. if err != nil {
  16029. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  16030. }
  16031. return oldValue.Estimate, nil
  16032. }
  16033. // ResetEstimate resets all changes to the "estimate" field.
  16034. func (m *EmployeeMutation) ResetEstimate() {
  16035. m.estimate = nil
  16036. }
  16037. // SetSkill sets the "skill" field.
  16038. func (m *EmployeeMutation) SetSkill(s string) {
  16039. m.skill = &s
  16040. }
  16041. // Skill returns the value of the "skill" field in the mutation.
  16042. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  16043. v := m.skill
  16044. if v == nil {
  16045. return
  16046. }
  16047. return *v, true
  16048. }
  16049. // OldSkill returns the old "skill" field's value of the Employee entity.
  16050. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16052. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  16053. if !m.op.Is(OpUpdateOne) {
  16054. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  16055. }
  16056. if m.id == nil || m.oldValue == nil {
  16057. return v, errors.New("OldSkill requires an ID field in the mutation")
  16058. }
  16059. oldValue, err := m.oldValue(ctx)
  16060. if err != nil {
  16061. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  16062. }
  16063. return oldValue.Skill, nil
  16064. }
  16065. // ResetSkill resets all changes to the "skill" field.
  16066. func (m *EmployeeMutation) ResetSkill() {
  16067. m.skill = nil
  16068. }
  16069. // SetAbilityType sets the "ability_type" field.
  16070. func (m *EmployeeMutation) SetAbilityType(s string) {
  16071. m.ability_type = &s
  16072. }
  16073. // AbilityType returns the value of the "ability_type" field in the mutation.
  16074. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  16075. v := m.ability_type
  16076. if v == nil {
  16077. return
  16078. }
  16079. return *v, true
  16080. }
  16081. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  16082. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16084. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  16085. if !m.op.Is(OpUpdateOne) {
  16086. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  16087. }
  16088. if m.id == nil || m.oldValue == nil {
  16089. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  16090. }
  16091. oldValue, err := m.oldValue(ctx)
  16092. if err != nil {
  16093. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  16094. }
  16095. return oldValue.AbilityType, nil
  16096. }
  16097. // ResetAbilityType resets all changes to the "ability_type" field.
  16098. func (m *EmployeeMutation) ResetAbilityType() {
  16099. m.ability_type = nil
  16100. }
  16101. // SetScene sets the "scene" field.
  16102. func (m *EmployeeMutation) SetScene(s string) {
  16103. m.scene = &s
  16104. }
  16105. // Scene returns the value of the "scene" field in the mutation.
  16106. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  16107. v := m.scene
  16108. if v == nil {
  16109. return
  16110. }
  16111. return *v, true
  16112. }
  16113. // OldScene returns the old "scene" field's value of the Employee entity.
  16114. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16116. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  16117. if !m.op.Is(OpUpdateOne) {
  16118. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  16119. }
  16120. if m.id == nil || m.oldValue == nil {
  16121. return v, errors.New("OldScene requires an ID field in the mutation")
  16122. }
  16123. oldValue, err := m.oldValue(ctx)
  16124. if err != nil {
  16125. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  16126. }
  16127. return oldValue.Scene, nil
  16128. }
  16129. // ResetScene resets all changes to the "scene" field.
  16130. func (m *EmployeeMutation) ResetScene() {
  16131. m.scene = nil
  16132. }
  16133. // SetSwitchIn sets the "switch_in" field.
  16134. func (m *EmployeeMutation) SetSwitchIn(s string) {
  16135. m.switch_in = &s
  16136. }
  16137. // SwitchIn returns the value of the "switch_in" field in the mutation.
  16138. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  16139. v := m.switch_in
  16140. if v == nil {
  16141. return
  16142. }
  16143. return *v, true
  16144. }
  16145. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  16146. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16148. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  16149. if !m.op.Is(OpUpdateOne) {
  16150. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  16151. }
  16152. if m.id == nil || m.oldValue == nil {
  16153. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  16154. }
  16155. oldValue, err := m.oldValue(ctx)
  16156. if err != nil {
  16157. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  16158. }
  16159. return oldValue.SwitchIn, nil
  16160. }
  16161. // ResetSwitchIn resets all changes to the "switch_in" field.
  16162. func (m *EmployeeMutation) ResetSwitchIn() {
  16163. m.switch_in = nil
  16164. }
  16165. // SetVideoURL sets the "video_url" field.
  16166. func (m *EmployeeMutation) SetVideoURL(s string) {
  16167. m.video_url = &s
  16168. }
  16169. // VideoURL returns the value of the "video_url" field in the mutation.
  16170. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  16171. v := m.video_url
  16172. if v == nil {
  16173. return
  16174. }
  16175. return *v, true
  16176. }
  16177. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  16178. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16180. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  16181. if !m.op.Is(OpUpdateOne) {
  16182. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  16183. }
  16184. if m.id == nil || m.oldValue == nil {
  16185. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  16186. }
  16187. oldValue, err := m.oldValue(ctx)
  16188. if err != nil {
  16189. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  16190. }
  16191. return oldValue.VideoURL, nil
  16192. }
  16193. // ResetVideoURL resets all changes to the "video_url" field.
  16194. func (m *EmployeeMutation) ResetVideoURL() {
  16195. m.video_url = nil
  16196. }
  16197. // SetOrganizationID sets the "organization_id" field.
  16198. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  16199. m.organization_id = &u
  16200. m.addorganization_id = nil
  16201. }
  16202. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16203. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  16204. v := m.organization_id
  16205. if v == nil {
  16206. return
  16207. }
  16208. return *v, true
  16209. }
  16210. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  16211. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16213. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16214. if !m.op.Is(OpUpdateOne) {
  16215. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16216. }
  16217. if m.id == nil || m.oldValue == nil {
  16218. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16219. }
  16220. oldValue, err := m.oldValue(ctx)
  16221. if err != nil {
  16222. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16223. }
  16224. return oldValue.OrganizationID, nil
  16225. }
  16226. // AddOrganizationID adds u to the "organization_id" field.
  16227. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  16228. if m.addorganization_id != nil {
  16229. *m.addorganization_id += u
  16230. } else {
  16231. m.addorganization_id = &u
  16232. }
  16233. }
  16234. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16235. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  16236. v := m.addorganization_id
  16237. if v == nil {
  16238. return
  16239. }
  16240. return *v, true
  16241. }
  16242. // ResetOrganizationID resets all changes to the "organization_id" field.
  16243. func (m *EmployeeMutation) ResetOrganizationID() {
  16244. m.organization_id = nil
  16245. m.addorganization_id = nil
  16246. }
  16247. // SetCategoryID sets the "category_id" field.
  16248. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  16249. m.category_id = &u
  16250. m.addcategory_id = nil
  16251. }
  16252. // CategoryID returns the value of the "category_id" field in the mutation.
  16253. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  16254. v := m.category_id
  16255. if v == nil {
  16256. return
  16257. }
  16258. return *v, true
  16259. }
  16260. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  16261. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16263. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  16264. if !m.op.Is(OpUpdateOne) {
  16265. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  16266. }
  16267. if m.id == nil || m.oldValue == nil {
  16268. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  16269. }
  16270. oldValue, err := m.oldValue(ctx)
  16271. if err != nil {
  16272. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  16273. }
  16274. return oldValue.CategoryID, nil
  16275. }
  16276. // AddCategoryID adds u to the "category_id" field.
  16277. func (m *EmployeeMutation) AddCategoryID(u int64) {
  16278. if m.addcategory_id != nil {
  16279. *m.addcategory_id += u
  16280. } else {
  16281. m.addcategory_id = &u
  16282. }
  16283. }
  16284. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  16285. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  16286. v := m.addcategory_id
  16287. if v == nil {
  16288. return
  16289. }
  16290. return *v, true
  16291. }
  16292. // ResetCategoryID resets all changes to the "category_id" field.
  16293. func (m *EmployeeMutation) ResetCategoryID() {
  16294. m.category_id = nil
  16295. m.addcategory_id = nil
  16296. }
  16297. // SetAPIBase sets the "api_base" field.
  16298. func (m *EmployeeMutation) SetAPIBase(s string) {
  16299. m.api_base = &s
  16300. }
  16301. // APIBase returns the value of the "api_base" field in the mutation.
  16302. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  16303. v := m.api_base
  16304. if v == nil {
  16305. return
  16306. }
  16307. return *v, true
  16308. }
  16309. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  16310. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16312. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  16313. if !m.op.Is(OpUpdateOne) {
  16314. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  16315. }
  16316. if m.id == nil || m.oldValue == nil {
  16317. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  16318. }
  16319. oldValue, err := m.oldValue(ctx)
  16320. if err != nil {
  16321. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  16322. }
  16323. return oldValue.APIBase, nil
  16324. }
  16325. // ResetAPIBase resets all changes to the "api_base" field.
  16326. func (m *EmployeeMutation) ResetAPIBase() {
  16327. m.api_base = nil
  16328. }
  16329. // SetAPIKey sets the "api_key" field.
  16330. func (m *EmployeeMutation) SetAPIKey(s string) {
  16331. m.api_key = &s
  16332. }
  16333. // APIKey returns the value of the "api_key" field in the mutation.
  16334. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  16335. v := m.api_key
  16336. if v == nil {
  16337. return
  16338. }
  16339. return *v, true
  16340. }
  16341. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  16342. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16344. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  16345. if !m.op.Is(OpUpdateOne) {
  16346. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  16347. }
  16348. if m.id == nil || m.oldValue == nil {
  16349. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  16350. }
  16351. oldValue, err := m.oldValue(ctx)
  16352. if err != nil {
  16353. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  16354. }
  16355. return oldValue.APIKey, nil
  16356. }
  16357. // ResetAPIKey resets all changes to the "api_key" field.
  16358. func (m *EmployeeMutation) ResetAPIKey() {
  16359. m.api_key = nil
  16360. }
  16361. // SetAiInfo sets the "ai_info" field.
  16362. func (m *EmployeeMutation) SetAiInfo(s string) {
  16363. m.ai_info = &s
  16364. }
  16365. // AiInfo returns the value of the "ai_info" field in the mutation.
  16366. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  16367. v := m.ai_info
  16368. if v == nil {
  16369. return
  16370. }
  16371. return *v, true
  16372. }
  16373. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  16374. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16376. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  16377. if !m.op.Is(OpUpdateOne) {
  16378. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  16379. }
  16380. if m.id == nil || m.oldValue == nil {
  16381. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  16382. }
  16383. oldValue, err := m.oldValue(ctx)
  16384. if err != nil {
  16385. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  16386. }
  16387. return oldValue.AiInfo, nil
  16388. }
  16389. // ClearAiInfo clears the value of the "ai_info" field.
  16390. func (m *EmployeeMutation) ClearAiInfo() {
  16391. m.ai_info = nil
  16392. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  16393. }
  16394. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  16395. func (m *EmployeeMutation) AiInfoCleared() bool {
  16396. _, ok := m.clearedFields[employee.FieldAiInfo]
  16397. return ok
  16398. }
  16399. // ResetAiInfo resets all changes to the "ai_info" field.
  16400. func (m *EmployeeMutation) ResetAiInfo() {
  16401. m.ai_info = nil
  16402. delete(m.clearedFields, employee.FieldAiInfo)
  16403. }
  16404. // SetIsVip sets the "is_vip" field.
  16405. func (m *EmployeeMutation) SetIsVip(i int) {
  16406. m.is_vip = &i
  16407. m.addis_vip = nil
  16408. }
  16409. // IsVip returns the value of the "is_vip" field in the mutation.
  16410. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  16411. v := m.is_vip
  16412. if v == nil {
  16413. return
  16414. }
  16415. return *v, true
  16416. }
  16417. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  16418. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16420. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  16421. if !m.op.Is(OpUpdateOne) {
  16422. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  16423. }
  16424. if m.id == nil || m.oldValue == nil {
  16425. return v, errors.New("OldIsVip requires an ID field in the mutation")
  16426. }
  16427. oldValue, err := m.oldValue(ctx)
  16428. if err != nil {
  16429. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  16430. }
  16431. return oldValue.IsVip, nil
  16432. }
  16433. // AddIsVip adds i to the "is_vip" field.
  16434. func (m *EmployeeMutation) AddIsVip(i int) {
  16435. if m.addis_vip != nil {
  16436. *m.addis_vip += i
  16437. } else {
  16438. m.addis_vip = &i
  16439. }
  16440. }
  16441. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  16442. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  16443. v := m.addis_vip
  16444. if v == nil {
  16445. return
  16446. }
  16447. return *v, true
  16448. }
  16449. // ResetIsVip resets all changes to the "is_vip" field.
  16450. func (m *EmployeeMutation) ResetIsVip() {
  16451. m.is_vip = nil
  16452. m.addis_vip = nil
  16453. }
  16454. // SetChatURL sets the "chat_url" field.
  16455. func (m *EmployeeMutation) SetChatURL(s string) {
  16456. m.chat_url = &s
  16457. }
  16458. // ChatURL returns the value of the "chat_url" field in the mutation.
  16459. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  16460. v := m.chat_url
  16461. if v == nil {
  16462. return
  16463. }
  16464. return *v, true
  16465. }
  16466. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  16467. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16469. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  16470. if !m.op.Is(OpUpdateOne) {
  16471. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  16472. }
  16473. if m.id == nil || m.oldValue == nil {
  16474. return v, errors.New("OldChatURL requires an ID field in the mutation")
  16475. }
  16476. oldValue, err := m.oldValue(ctx)
  16477. if err != nil {
  16478. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  16479. }
  16480. return oldValue.ChatURL, nil
  16481. }
  16482. // ResetChatURL resets all changes to the "chat_url" field.
  16483. func (m *EmployeeMutation) ResetChatURL() {
  16484. m.chat_url = nil
  16485. }
  16486. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  16487. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  16488. if m.em_work_experiences == nil {
  16489. m.em_work_experiences = make(map[uint64]struct{})
  16490. }
  16491. for i := range ids {
  16492. m.em_work_experiences[ids[i]] = struct{}{}
  16493. }
  16494. }
  16495. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  16496. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  16497. m.clearedem_work_experiences = true
  16498. }
  16499. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  16500. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  16501. return m.clearedem_work_experiences
  16502. }
  16503. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  16504. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  16505. if m.removedem_work_experiences == nil {
  16506. m.removedem_work_experiences = make(map[uint64]struct{})
  16507. }
  16508. for i := range ids {
  16509. delete(m.em_work_experiences, ids[i])
  16510. m.removedem_work_experiences[ids[i]] = struct{}{}
  16511. }
  16512. }
  16513. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  16514. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  16515. for id := range m.removedem_work_experiences {
  16516. ids = append(ids, id)
  16517. }
  16518. return
  16519. }
  16520. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  16521. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  16522. for id := range m.em_work_experiences {
  16523. ids = append(ids, id)
  16524. }
  16525. return
  16526. }
  16527. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  16528. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  16529. m.em_work_experiences = nil
  16530. m.clearedem_work_experiences = false
  16531. m.removedem_work_experiences = nil
  16532. }
  16533. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  16534. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  16535. if m.em_tutorial == nil {
  16536. m.em_tutorial = make(map[uint64]struct{})
  16537. }
  16538. for i := range ids {
  16539. m.em_tutorial[ids[i]] = struct{}{}
  16540. }
  16541. }
  16542. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  16543. func (m *EmployeeMutation) ClearEmTutorial() {
  16544. m.clearedem_tutorial = true
  16545. }
  16546. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  16547. func (m *EmployeeMutation) EmTutorialCleared() bool {
  16548. return m.clearedem_tutorial
  16549. }
  16550. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  16551. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  16552. if m.removedem_tutorial == nil {
  16553. m.removedem_tutorial = make(map[uint64]struct{})
  16554. }
  16555. for i := range ids {
  16556. delete(m.em_tutorial, ids[i])
  16557. m.removedem_tutorial[ids[i]] = struct{}{}
  16558. }
  16559. }
  16560. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  16561. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  16562. for id := range m.removedem_tutorial {
  16563. ids = append(ids, id)
  16564. }
  16565. return
  16566. }
  16567. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  16568. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  16569. for id := range m.em_tutorial {
  16570. ids = append(ids, id)
  16571. }
  16572. return
  16573. }
  16574. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  16575. func (m *EmployeeMutation) ResetEmTutorial() {
  16576. m.em_tutorial = nil
  16577. m.clearedem_tutorial = false
  16578. m.removedem_tutorial = nil
  16579. }
  16580. // Where appends a list predicates to the EmployeeMutation builder.
  16581. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  16582. m.predicates = append(m.predicates, ps...)
  16583. }
  16584. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  16585. // users can use type-assertion to append predicates that do not depend on any generated package.
  16586. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  16587. p := make([]predicate.Employee, len(ps))
  16588. for i := range ps {
  16589. p[i] = ps[i]
  16590. }
  16591. m.Where(p...)
  16592. }
  16593. // Op returns the operation name.
  16594. func (m *EmployeeMutation) Op() Op {
  16595. return m.op
  16596. }
  16597. // SetOp allows setting the mutation operation.
  16598. func (m *EmployeeMutation) SetOp(op Op) {
  16599. m.op = op
  16600. }
  16601. // Type returns the node type of this mutation (Employee).
  16602. func (m *EmployeeMutation) Type() string {
  16603. return m.typ
  16604. }
  16605. // Fields returns all fields that were changed during this mutation. Note that in
  16606. // order to get all numeric fields that were incremented/decremented, call
  16607. // AddedFields().
  16608. func (m *EmployeeMutation) Fields() []string {
  16609. fields := make([]string, 0, 23)
  16610. if m.created_at != nil {
  16611. fields = append(fields, employee.FieldCreatedAt)
  16612. }
  16613. if m.updated_at != nil {
  16614. fields = append(fields, employee.FieldUpdatedAt)
  16615. }
  16616. if m.deleted_at != nil {
  16617. fields = append(fields, employee.FieldDeletedAt)
  16618. }
  16619. if m.title != nil {
  16620. fields = append(fields, employee.FieldTitle)
  16621. }
  16622. if m.avatar != nil {
  16623. fields = append(fields, employee.FieldAvatar)
  16624. }
  16625. if m.tags != nil {
  16626. fields = append(fields, employee.FieldTags)
  16627. }
  16628. if m.hire_count != nil {
  16629. fields = append(fields, employee.FieldHireCount)
  16630. }
  16631. if m.service_count != nil {
  16632. fields = append(fields, employee.FieldServiceCount)
  16633. }
  16634. if m.achievement_count != nil {
  16635. fields = append(fields, employee.FieldAchievementCount)
  16636. }
  16637. if m.intro != nil {
  16638. fields = append(fields, employee.FieldIntro)
  16639. }
  16640. if m.estimate != nil {
  16641. fields = append(fields, employee.FieldEstimate)
  16642. }
  16643. if m.skill != nil {
  16644. fields = append(fields, employee.FieldSkill)
  16645. }
  16646. if m.ability_type != nil {
  16647. fields = append(fields, employee.FieldAbilityType)
  16648. }
  16649. if m.scene != nil {
  16650. fields = append(fields, employee.FieldScene)
  16651. }
  16652. if m.switch_in != nil {
  16653. fields = append(fields, employee.FieldSwitchIn)
  16654. }
  16655. if m.video_url != nil {
  16656. fields = append(fields, employee.FieldVideoURL)
  16657. }
  16658. if m.organization_id != nil {
  16659. fields = append(fields, employee.FieldOrganizationID)
  16660. }
  16661. if m.category_id != nil {
  16662. fields = append(fields, employee.FieldCategoryID)
  16663. }
  16664. if m.api_base != nil {
  16665. fields = append(fields, employee.FieldAPIBase)
  16666. }
  16667. if m.api_key != nil {
  16668. fields = append(fields, employee.FieldAPIKey)
  16669. }
  16670. if m.ai_info != nil {
  16671. fields = append(fields, employee.FieldAiInfo)
  16672. }
  16673. if m.is_vip != nil {
  16674. fields = append(fields, employee.FieldIsVip)
  16675. }
  16676. if m.chat_url != nil {
  16677. fields = append(fields, employee.FieldChatURL)
  16678. }
  16679. return fields
  16680. }
  16681. // Field returns the value of a field with the given name. The second boolean
  16682. // return value indicates that this field was not set, or was not defined in the
  16683. // schema.
  16684. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  16685. switch name {
  16686. case employee.FieldCreatedAt:
  16687. return m.CreatedAt()
  16688. case employee.FieldUpdatedAt:
  16689. return m.UpdatedAt()
  16690. case employee.FieldDeletedAt:
  16691. return m.DeletedAt()
  16692. case employee.FieldTitle:
  16693. return m.Title()
  16694. case employee.FieldAvatar:
  16695. return m.Avatar()
  16696. case employee.FieldTags:
  16697. return m.Tags()
  16698. case employee.FieldHireCount:
  16699. return m.HireCount()
  16700. case employee.FieldServiceCount:
  16701. return m.ServiceCount()
  16702. case employee.FieldAchievementCount:
  16703. return m.AchievementCount()
  16704. case employee.FieldIntro:
  16705. return m.Intro()
  16706. case employee.FieldEstimate:
  16707. return m.Estimate()
  16708. case employee.FieldSkill:
  16709. return m.Skill()
  16710. case employee.FieldAbilityType:
  16711. return m.AbilityType()
  16712. case employee.FieldScene:
  16713. return m.Scene()
  16714. case employee.FieldSwitchIn:
  16715. return m.SwitchIn()
  16716. case employee.FieldVideoURL:
  16717. return m.VideoURL()
  16718. case employee.FieldOrganizationID:
  16719. return m.OrganizationID()
  16720. case employee.FieldCategoryID:
  16721. return m.CategoryID()
  16722. case employee.FieldAPIBase:
  16723. return m.APIBase()
  16724. case employee.FieldAPIKey:
  16725. return m.APIKey()
  16726. case employee.FieldAiInfo:
  16727. return m.AiInfo()
  16728. case employee.FieldIsVip:
  16729. return m.IsVip()
  16730. case employee.FieldChatURL:
  16731. return m.ChatURL()
  16732. }
  16733. return nil, false
  16734. }
  16735. // OldField returns the old value of the field from the database. An error is
  16736. // returned if the mutation operation is not UpdateOne, or the query to the
  16737. // database failed.
  16738. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16739. switch name {
  16740. case employee.FieldCreatedAt:
  16741. return m.OldCreatedAt(ctx)
  16742. case employee.FieldUpdatedAt:
  16743. return m.OldUpdatedAt(ctx)
  16744. case employee.FieldDeletedAt:
  16745. return m.OldDeletedAt(ctx)
  16746. case employee.FieldTitle:
  16747. return m.OldTitle(ctx)
  16748. case employee.FieldAvatar:
  16749. return m.OldAvatar(ctx)
  16750. case employee.FieldTags:
  16751. return m.OldTags(ctx)
  16752. case employee.FieldHireCount:
  16753. return m.OldHireCount(ctx)
  16754. case employee.FieldServiceCount:
  16755. return m.OldServiceCount(ctx)
  16756. case employee.FieldAchievementCount:
  16757. return m.OldAchievementCount(ctx)
  16758. case employee.FieldIntro:
  16759. return m.OldIntro(ctx)
  16760. case employee.FieldEstimate:
  16761. return m.OldEstimate(ctx)
  16762. case employee.FieldSkill:
  16763. return m.OldSkill(ctx)
  16764. case employee.FieldAbilityType:
  16765. return m.OldAbilityType(ctx)
  16766. case employee.FieldScene:
  16767. return m.OldScene(ctx)
  16768. case employee.FieldSwitchIn:
  16769. return m.OldSwitchIn(ctx)
  16770. case employee.FieldVideoURL:
  16771. return m.OldVideoURL(ctx)
  16772. case employee.FieldOrganizationID:
  16773. return m.OldOrganizationID(ctx)
  16774. case employee.FieldCategoryID:
  16775. return m.OldCategoryID(ctx)
  16776. case employee.FieldAPIBase:
  16777. return m.OldAPIBase(ctx)
  16778. case employee.FieldAPIKey:
  16779. return m.OldAPIKey(ctx)
  16780. case employee.FieldAiInfo:
  16781. return m.OldAiInfo(ctx)
  16782. case employee.FieldIsVip:
  16783. return m.OldIsVip(ctx)
  16784. case employee.FieldChatURL:
  16785. return m.OldChatURL(ctx)
  16786. }
  16787. return nil, fmt.Errorf("unknown Employee field %s", name)
  16788. }
  16789. // SetField sets the value of a field with the given name. It returns an error if
  16790. // the field is not defined in the schema, or if the type mismatched the field
  16791. // type.
  16792. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  16793. switch name {
  16794. case employee.FieldCreatedAt:
  16795. v, ok := value.(time.Time)
  16796. if !ok {
  16797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16798. }
  16799. m.SetCreatedAt(v)
  16800. return nil
  16801. case employee.FieldUpdatedAt:
  16802. v, ok := value.(time.Time)
  16803. if !ok {
  16804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16805. }
  16806. m.SetUpdatedAt(v)
  16807. return nil
  16808. case employee.FieldDeletedAt:
  16809. v, ok := value.(time.Time)
  16810. if !ok {
  16811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16812. }
  16813. m.SetDeletedAt(v)
  16814. return nil
  16815. case employee.FieldTitle:
  16816. v, ok := value.(string)
  16817. if !ok {
  16818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16819. }
  16820. m.SetTitle(v)
  16821. return nil
  16822. case employee.FieldAvatar:
  16823. v, ok := value.(string)
  16824. if !ok {
  16825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16826. }
  16827. m.SetAvatar(v)
  16828. return nil
  16829. case employee.FieldTags:
  16830. v, ok := value.(string)
  16831. if !ok {
  16832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16833. }
  16834. m.SetTags(v)
  16835. return nil
  16836. case employee.FieldHireCount:
  16837. v, ok := value.(int)
  16838. if !ok {
  16839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16840. }
  16841. m.SetHireCount(v)
  16842. return nil
  16843. case employee.FieldServiceCount:
  16844. v, ok := value.(int)
  16845. if !ok {
  16846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16847. }
  16848. m.SetServiceCount(v)
  16849. return nil
  16850. case employee.FieldAchievementCount:
  16851. v, ok := value.(int)
  16852. if !ok {
  16853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16854. }
  16855. m.SetAchievementCount(v)
  16856. return nil
  16857. case employee.FieldIntro:
  16858. v, ok := value.(string)
  16859. if !ok {
  16860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16861. }
  16862. m.SetIntro(v)
  16863. return nil
  16864. case employee.FieldEstimate:
  16865. v, ok := value.(string)
  16866. if !ok {
  16867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16868. }
  16869. m.SetEstimate(v)
  16870. return nil
  16871. case employee.FieldSkill:
  16872. v, ok := value.(string)
  16873. if !ok {
  16874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16875. }
  16876. m.SetSkill(v)
  16877. return nil
  16878. case employee.FieldAbilityType:
  16879. v, ok := value.(string)
  16880. if !ok {
  16881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16882. }
  16883. m.SetAbilityType(v)
  16884. return nil
  16885. case employee.FieldScene:
  16886. v, ok := value.(string)
  16887. if !ok {
  16888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16889. }
  16890. m.SetScene(v)
  16891. return nil
  16892. case employee.FieldSwitchIn:
  16893. v, ok := value.(string)
  16894. if !ok {
  16895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16896. }
  16897. m.SetSwitchIn(v)
  16898. return nil
  16899. case employee.FieldVideoURL:
  16900. v, ok := value.(string)
  16901. if !ok {
  16902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16903. }
  16904. m.SetVideoURL(v)
  16905. return nil
  16906. case employee.FieldOrganizationID:
  16907. v, ok := value.(uint64)
  16908. if !ok {
  16909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16910. }
  16911. m.SetOrganizationID(v)
  16912. return nil
  16913. case employee.FieldCategoryID:
  16914. v, ok := value.(uint64)
  16915. if !ok {
  16916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16917. }
  16918. m.SetCategoryID(v)
  16919. return nil
  16920. case employee.FieldAPIBase:
  16921. v, ok := value.(string)
  16922. if !ok {
  16923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16924. }
  16925. m.SetAPIBase(v)
  16926. return nil
  16927. case employee.FieldAPIKey:
  16928. v, ok := value.(string)
  16929. if !ok {
  16930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16931. }
  16932. m.SetAPIKey(v)
  16933. return nil
  16934. case employee.FieldAiInfo:
  16935. v, ok := value.(string)
  16936. if !ok {
  16937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16938. }
  16939. m.SetAiInfo(v)
  16940. return nil
  16941. case employee.FieldIsVip:
  16942. v, ok := value.(int)
  16943. if !ok {
  16944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16945. }
  16946. m.SetIsVip(v)
  16947. return nil
  16948. case employee.FieldChatURL:
  16949. v, ok := value.(string)
  16950. if !ok {
  16951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16952. }
  16953. m.SetChatURL(v)
  16954. return nil
  16955. }
  16956. return fmt.Errorf("unknown Employee field %s", name)
  16957. }
  16958. // AddedFields returns all numeric fields that were incremented/decremented during
  16959. // this mutation.
  16960. func (m *EmployeeMutation) AddedFields() []string {
  16961. var fields []string
  16962. if m.addhire_count != nil {
  16963. fields = append(fields, employee.FieldHireCount)
  16964. }
  16965. if m.addservice_count != nil {
  16966. fields = append(fields, employee.FieldServiceCount)
  16967. }
  16968. if m.addachievement_count != nil {
  16969. fields = append(fields, employee.FieldAchievementCount)
  16970. }
  16971. if m.addorganization_id != nil {
  16972. fields = append(fields, employee.FieldOrganizationID)
  16973. }
  16974. if m.addcategory_id != nil {
  16975. fields = append(fields, employee.FieldCategoryID)
  16976. }
  16977. if m.addis_vip != nil {
  16978. fields = append(fields, employee.FieldIsVip)
  16979. }
  16980. return fields
  16981. }
  16982. // AddedField returns the numeric value that was incremented/decremented on a field
  16983. // with the given name. The second boolean return value indicates that this field
  16984. // was not set, or was not defined in the schema.
  16985. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  16986. switch name {
  16987. case employee.FieldHireCount:
  16988. return m.AddedHireCount()
  16989. case employee.FieldServiceCount:
  16990. return m.AddedServiceCount()
  16991. case employee.FieldAchievementCount:
  16992. return m.AddedAchievementCount()
  16993. case employee.FieldOrganizationID:
  16994. return m.AddedOrganizationID()
  16995. case employee.FieldCategoryID:
  16996. return m.AddedCategoryID()
  16997. case employee.FieldIsVip:
  16998. return m.AddedIsVip()
  16999. }
  17000. return nil, false
  17001. }
  17002. // AddField adds the value to the field with the given name. It returns an error if
  17003. // the field is not defined in the schema, or if the type mismatched the field
  17004. // type.
  17005. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  17006. switch name {
  17007. case employee.FieldHireCount:
  17008. v, ok := value.(int)
  17009. if !ok {
  17010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17011. }
  17012. m.AddHireCount(v)
  17013. return nil
  17014. case employee.FieldServiceCount:
  17015. v, ok := value.(int)
  17016. if !ok {
  17017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17018. }
  17019. m.AddServiceCount(v)
  17020. return nil
  17021. case employee.FieldAchievementCount:
  17022. v, ok := value.(int)
  17023. if !ok {
  17024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17025. }
  17026. m.AddAchievementCount(v)
  17027. return nil
  17028. case employee.FieldOrganizationID:
  17029. v, ok := value.(int64)
  17030. if !ok {
  17031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17032. }
  17033. m.AddOrganizationID(v)
  17034. return nil
  17035. case employee.FieldCategoryID:
  17036. v, ok := value.(int64)
  17037. if !ok {
  17038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17039. }
  17040. m.AddCategoryID(v)
  17041. return nil
  17042. case employee.FieldIsVip:
  17043. v, ok := value.(int)
  17044. if !ok {
  17045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17046. }
  17047. m.AddIsVip(v)
  17048. return nil
  17049. }
  17050. return fmt.Errorf("unknown Employee numeric field %s", name)
  17051. }
  17052. // ClearedFields returns all nullable fields that were cleared during this
  17053. // mutation.
  17054. func (m *EmployeeMutation) ClearedFields() []string {
  17055. var fields []string
  17056. if m.FieldCleared(employee.FieldDeletedAt) {
  17057. fields = append(fields, employee.FieldDeletedAt)
  17058. }
  17059. if m.FieldCleared(employee.FieldAiInfo) {
  17060. fields = append(fields, employee.FieldAiInfo)
  17061. }
  17062. return fields
  17063. }
  17064. // FieldCleared returns a boolean indicating if a field with the given name was
  17065. // cleared in this mutation.
  17066. func (m *EmployeeMutation) FieldCleared(name string) bool {
  17067. _, ok := m.clearedFields[name]
  17068. return ok
  17069. }
  17070. // ClearField clears the value of the field with the given name. It returns an
  17071. // error if the field is not defined in the schema.
  17072. func (m *EmployeeMutation) ClearField(name string) error {
  17073. switch name {
  17074. case employee.FieldDeletedAt:
  17075. m.ClearDeletedAt()
  17076. return nil
  17077. case employee.FieldAiInfo:
  17078. m.ClearAiInfo()
  17079. return nil
  17080. }
  17081. return fmt.Errorf("unknown Employee nullable field %s", name)
  17082. }
  17083. // ResetField resets all changes in the mutation for the field with the given name.
  17084. // It returns an error if the field is not defined in the schema.
  17085. func (m *EmployeeMutation) ResetField(name string) error {
  17086. switch name {
  17087. case employee.FieldCreatedAt:
  17088. m.ResetCreatedAt()
  17089. return nil
  17090. case employee.FieldUpdatedAt:
  17091. m.ResetUpdatedAt()
  17092. return nil
  17093. case employee.FieldDeletedAt:
  17094. m.ResetDeletedAt()
  17095. return nil
  17096. case employee.FieldTitle:
  17097. m.ResetTitle()
  17098. return nil
  17099. case employee.FieldAvatar:
  17100. m.ResetAvatar()
  17101. return nil
  17102. case employee.FieldTags:
  17103. m.ResetTags()
  17104. return nil
  17105. case employee.FieldHireCount:
  17106. m.ResetHireCount()
  17107. return nil
  17108. case employee.FieldServiceCount:
  17109. m.ResetServiceCount()
  17110. return nil
  17111. case employee.FieldAchievementCount:
  17112. m.ResetAchievementCount()
  17113. return nil
  17114. case employee.FieldIntro:
  17115. m.ResetIntro()
  17116. return nil
  17117. case employee.FieldEstimate:
  17118. m.ResetEstimate()
  17119. return nil
  17120. case employee.FieldSkill:
  17121. m.ResetSkill()
  17122. return nil
  17123. case employee.FieldAbilityType:
  17124. m.ResetAbilityType()
  17125. return nil
  17126. case employee.FieldScene:
  17127. m.ResetScene()
  17128. return nil
  17129. case employee.FieldSwitchIn:
  17130. m.ResetSwitchIn()
  17131. return nil
  17132. case employee.FieldVideoURL:
  17133. m.ResetVideoURL()
  17134. return nil
  17135. case employee.FieldOrganizationID:
  17136. m.ResetOrganizationID()
  17137. return nil
  17138. case employee.FieldCategoryID:
  17139. m.ResetCategoryID()
  17140. return nil
  17141. case employee.FieldAPIBase:
  17142. m.ResetAPIBase()
  17143. return nil
  17144. case employee.FieldAPIKey:
  17145. m.ResetAPIKey()
  17146. return nil
  17147. case employee.FieldAiInfo:
  17148. m.ResetAiInfo()
  17149. return nil
  17150. case employee.FieldIsVip:
  17151. m.ResetIsVip()
  17152. return nil
  17153. case employee.FieldChatURL:
  17154. m.ResetChatURL()
  17155. return nil
  17156. }
  17157. return fmt.Errorf("unknown Employee field %s", name)
  17158. }
  17159. // AddedEdges returns all edge names that were set/added in this mutation.
  17160. func (m *EmployeeMutation) AddedEdges() []string {
  17161. edges := make([]string, 0, 2)
  17162. if m.em_work_experiences != nil {
  17163. edges = append(edges, employee.EdgeEmWorkExperiences)
  17164. }
  17165. if m.em_tutorial != nil {
  17166. edges = append(edges, employee.EdgeEmTutorial)
  17167. }
  17168. return edges
  17169. }
  17170. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17171. // name in this mutation.
  17172. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  17173. switch name {
  17174. case employee.EdgeEmWorkExperiences:
  17175. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  17176. for id := range m.em_work_experiences {
  17177. ids = append(ids, id)
  17178. }
  17179. return ids
  17180. case employee.EdgeEmTutorial:
  17181. ids := make([]ent.Value, 0, len(m.em_tutorial))
  17182. for id := range m.em_tutorial {
  17183. ids = append(ids, id)
  17184. }
  17185. return ids
  17186. }
  17187. return nil
  17188. }
  17189. // RemovedEdges returns all edge names that were removed in this mutation.
  17190. func (m *EmployeeMutation) RemovedEdges() []string {
  17191. edges := make([]string, 0, 2)
  17192. if m.removedem_work_experiences != nil {
  17193. edges = append(edges, employee.EdgeEmWorkExperiences)
  17194. }
  17195. if m.removedem_tutorial != nil {
  17196. edges = append(edges, employee.EdgeEmTutorial)
  17197. }
  17198. return edges
  17199. }
  17200. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17201. // the given name in this mutation.
  17202. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  17203. switch name {
  17204. case employee.EdgeEmWorkExperiences:
  17205. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  17206. for id := range m.removedem_work_experiences {
  17207. ids = append(ids, id)
  17208. }
  17209. return ids
  17210. case employee.EdgeEmTutorial:
  17211. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  17212. for id := range m.removedem_tutorial {
  17213. ids = append(ids, id)
  17214. }
  17215. return ids
  17216. }
  17217. return nil
  17218. }
  17219. // ClearedEdges returns all edge names that were cleared in this mutation.
  17220. func (m *EmployeeMutation) ClearedEdges() []string {
  17221. edges := make([]string, 0, 2)
  17222. if m.clearedem_work_experiences {
  17223. edges = append(edges, employee.EdgeEmWorkExperiences)
  17224. }
  17225. if m.clearedem_tutorial {
  17226. edges = append(edges, employee.EdgeEmTutorial)
  17227. }
  17228. return edges
  17229. }
  17230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17231. // was cleared in this mutation.
  17232. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  17233. switch name {
  17234. case employee.EdgeEmWorkExperiences:
  17235. return m.clearedem_work_experiences
  17236. case employee.EdgeEmTutorial:
  17237. return m.clearedem_tutorial
  17238. }
  17239. return false
  17240. }
  17241. // ClearEdge clears the value of the edge with the given name. It returns an error
  17242. // if that edge is not defined in the schema.
  17243. func (m *EmployeeMutation) ClearEdge(name string) error {
  17244. switch name {
  17245. }
  17246. return fmt.Errorf("unknown Employee unique edge %s", name)
  17247. }
  17248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17249. // It returns an error if the edge is not defined in the schema.
  17250. func (m *EmployeeMutation) ResetEdge(name string) error {
  17251. switch name {
  17252. case employee.EdgeEmWorkExperiences:
  17253. m.ResetEmWorkExperiences()
  17254. return nil
  17255. case employee.EdgeEmTutorial:
  17256. m.ResetEmTutorial()
  17257. return nil
  17258. }
  17259. return fmt.Errorf("unknown Employee edge %s", name)
  17260. }
  17261. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  17262. type EmployeeConfigMutation struct {
  17263. config
  17264. op Op
  17265. typ string
  17266. id *uint64
  17267. created_at *time.Time
  17268. updated_at *time.Time
  17269. deleted_at *time.Time
  17270. stype *string
  17271. title *string
  17272. photo *string
  17273. organization_id *uint64
  17274. addorganization_id *int64
  17275. clearedFields map[string]struct{}
  17276. done bool
  17277. oldValue func(context.Context) (*EmployeeConfig, error)
  17278. predicates []predicate.EmployeeConfig
  17279. }
  17280. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  17281. // employeeconfigOption allows management of the mutation configuration using functional options.
  17282. type employeeconfigOption func(*EmployeeConfigMutation)
  17283. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  17284. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  17285. m := &EmployeeConfigMutation{
  17286. config: c,
  17287. op: op,
  17288. typ: TypeEmployeeConfig,
  17289. clearedFields: make(map[string]struct{}),
  17290. }
  17291. for _, opt := range opts {
  17292. opt(m)
  17293. }
  17294. return m
  17295. }
  17296. // withEmployeeConfigID sets the ID field of the mutation.
  17297. func withEmployeeConfigID(id uint64) employeeconfigOption {
  17298. return func(m *EmployeeConfigMutation) {
  17299. var (
  17300. err error
  17301. once sync.Once
  17302. value *EmployeeConfig
  17303. )
  17304. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  17305. once.Do(func() {
  17306. if m.done {
  17307. err = errors.New("querying old values post mutation is not allowed")
  17308. } else {
  17309. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  17310. }
  17311. })
  17312. return value, err
  17313. }
  17314. m.id = &id
  17315. }
  17316. }
  17317. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  17318. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  17319. return func(m *EmployeeConfigMutation) {
  17320. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  17321. return node, nil
  17322. }
  17323. m.id = &node.ID
  17324. }
  17325. }
  17326. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17327. // executed in a transaction (ent.Tx), a transactional client is returned.
  17328. func (m EmployeeConfigMutation) Client() *Client {
  17329. client := &Client{config: m.config}
  17330. client.init()
  17331. return client
  17332. }
  17333. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17334. // it returns an error otherwise.
  17335. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  17336. if _, ok := m.driver.(*txDriver); !ok {
  17337. return nil, errors.New("ent: mutation is not running in a transaction")
  17338. }
  17339. tx := &Tx{config: m.config}
  17340. tx.init()
  17341. return tx, nil
  17342. }
  17343. // SetID sets the value of the id field. Note that this
  17344. // operation is only accepted on creation of EmployeeConfig entities.
  17345. func (m *EmployeeConfigMutation) SetID(id uint64) {
  17346. m.id = &id
  17347. }
  17348. // ID returns the ID value in the mutation. Note that the ID is only available
  17349. // if it was provided to the builder or after it was returned from the database.
  17350. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  17351. if m.id == nil {
  17352. return
  17353. }
  17354. return *m.id, true
  17355. }
  17356. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17357. // That means, if the mutation is applied within a transaction with an isolation level such
  17358. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17359. // or updated by the mutation.
  17360. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  17361. switch {
  17362. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17363. id, exists := m.ID()
  17364. if exists {
  17365. return []uint64{id}, nil
  17366. }
  17367. fallthrough
  17368. case m.op.Is(OpUpdate | OpDelete):
  17369. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  17370. default:
  17371. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17372. }
  17373. }
  17374. // SetCreatedAt sets the "created_at" field.
  17375. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  17376. m.created_at = &t
  17377. }
  17378. // CreatedAt returns the value of the "created_at" field in the mutation.
  17379. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  17380. v := m.created_at
  17381. if v == nil {
  17382. return
  17383. }
  17384. return *v, true
  17385. }
  17386. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  17387. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17389. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17390. if !m.op.Is(OpUpdateOne) {
  17391. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17392. }
  17393. if m.id == nil || m.oldValue == nil {
  17394. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17395. }
  17396. oldValue, err := m.oldValue(ctx)
  17397. if err != nil {
  17398. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17399. }
  17400. return oldValue.CreatedAt, nil
  17401. }
  17402. // ResetCreatedAt resets all changes to the "created_at" field.
  17403. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  17404. m.created_at = nil
  17405. }
  17406. // SetUpdatedAt sets the "updated_at" field.
  17407. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  17408. m.updated_at = &t
  17409. }
  17410. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17411. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  17412. v := m.updated_at
  17413. if v == nil {
  17414. return
  17415. }
  17416. return *v, true
  17417. }
  17418. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  17419. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17421. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17422. if !m.op.Is(OpUpdateOne) {
  17423. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17424. }
  17425. if m.id == nil || m.oldValue == nil {
  17426. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17427. }
  17428. oldValue, err := m.oldValue(ctx)
  17429. if err != nil {
  17430. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17431. }
  17432. return oldValue.UpdatedAt, nil
  17433. }
  17434. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17435. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  17436. m.updated_at = nil
  17437. }
  17438. // SetDeletedAt sets the "deleted_at" field.
  17439. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  17440. m.deleted_at = &t
  17441. }
  17442. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17443. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  17444. v := m.deleted_at
  17445. if v == nil {
  17446. return
  17447. }
  17448. return *v, true
  17449. }
  17450. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  17451. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17453. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17454. if !m.op.Is(OpUpdateOne) {
  17455. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17456. }
  17457. if m.id == nil || m.oldValue == nil {
  17458. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17459. }
  17460. oldValue, err := m.oldValue(ctx)
  17461. if err != nil {
  17462. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17463. }
  17464. return oldValue.DeletedAt, nil
  17465. }
  17466. // ClearDeletedAt clears the value of the "deleted_at" field.
  17467. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  17468. m.deleted_at = nil
  17469. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  17470. }
  17471. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17472. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  17473. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  17474. return ok
  17475. }
  17476. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17477. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  17478. m.deleted_at = nil
  17479. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  17480. }
  17481. // SetStype sets the "stype" field.
  17482. func (m *EmployeeConfigMutation) SetStype(s string) {
  17483. m.stype = &s
  17484. }
  17485. // Stype returns the value of the "stype" field in the mutation.
  17486. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  17487. v := m.stype
  17488. if v == nil {
  17489. return
  17490. }
  17491. return *v, true
  17492. }
  17493. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  17494. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17496. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  17497. if !m.op.Is(OpUpdateOne) {
  17498. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  17499. }
  17500. if m.id == nil || m.oldValue == nil {
  17501. return v, errors.New("OldStype requires an ID field in the mutation")
  17502. }
  17503. oldValue, err := m.oldValue(ctx)
  17504. if err != nil {
  17505. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  17506. }
  17507. return oldValue.Stype, nil
  17508. }
  17509. // ResetStype resets all changes to the "stype" field.
  17510. func (m *EmployeeConfigMutation) ResetStype() {
  17511. m.stype = nil
  17512. }
  17513. // SetTitle sets the "title" field.
  17514. func (m *EmployeeConfigMutation) SetTitle(s string) {
  17515. m.title = &s
  17516. }
  17517. // Title returns the value of the "title" field in the mutation.
  17518. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  17519. v := m.title
  17520. if v == nil {
  17521. return
  17522. }
  17523. return *v, true
  17524. }
  17525. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  17526. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17528. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  17529. if !m.op.Is(OpUpdateOne) {
  17530. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17531. }
  17532. if m.id == nil || m.oldValue == nil {
  17533. return v, errors.New("OldTitle requires an ID field in the mutation")
  17534. }
  17535. oldValue, err := m.oldValue(ctx)
  17536. if err != nil {
  17537. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17538. }
  17539. return oldValue.Title, nil
  17540. }
  17541. // ResetTitle resets all changes to the "title" field.
  17542. func (m *EmployeeConfigMutation) ResetTitle() {
  17543. m.title = nil
  17544. }
  17545. // SetPhoto sets the "photo" field.
  17546. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  17547. m.photo = &s
  17548. }
  17549. // Photo returns the value of the "photo" field in the mutation.
  17550. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  17551. v := m.photo
  17552. if v == nil {
  17553. return
  17554. }
  17555. return *v, true
  17556. }
  17557. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  17558. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17560. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  17561. if !m.op.Is(OpUpdateOne) {
  17562. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  17563. }
  17564. if m.id == nil || m.oldValue == nil {
  17565. return v, errors.New("OldPhoto requires an ID field in the mutation")
  17566. }
  17567. oldValue, err := m.oldValue(ctx)
  17568. if err != nil {
  17569. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  17570. }
  17571. return oldValue.Photo, nil
  17572. }
  17573. // ResetPhoto resets all changes to the "photo" field.
  17574. func (m *EmployeeConfigMutation) ResetPhoto() {
  17575. m.photo = nil
  17576. }
  17577. // SetOrganizationID sets the "organization_id" field.
  17578. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  17579. m.organization_id = &u
  17580. m.addorganization_id = nil
  17581. }
  17582. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17583. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  17584. v := m.organization_id
  17585. if v == nil {
  17586. return
  17587. }
  17588. return *v, true
  17589. }
  17590. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  17591. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  17592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17593. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17594. if !m.op.Is(OpUpdateOne) {
  17595. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17596. }
  17597. if m.id == nil || m.oldValue == nil {
  17598. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17599. }
  17600. oldValue, err := m.oldValue(ctx)
  17601. if err != nil {
  17602. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17603. }
  17604. return oldValue.OrganizationID, nil
  17605. }
  17606. // AddOrganizationID adds u to the "organization_id" field.
  17607. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  17608. if m.addorganization_id != nil {
  17609. *m.addorganization_id += u
  17610. } else {
  17611. m.addorganization_id = &u
  17612. }
  17613. }
  17614. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17615. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  17616. v := m.addorganization_id
  17617. if v == nil {
  17618. return
  17619. }
  17620. return *v, true
  17621. }
  17622. // ClearOrganizationID clears the value of the "organization_id" field.
  17623. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  17624. m.organization_id = nil
  17625. m.addorganization_id = nil
  17626. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  17627. }
  17628. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17629. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  17630. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  17631. return ok
  17632. }
  17633. // ResetOrganizationID resets all changes to the "organization_id" field.
  17634. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  17635. m.organization_id = nil
  17636. m.addorganization_id = nil
  17637. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  17638. }
  17639. // Where appends a list predicates to the EmployeeConfigMutation builder.
  17640. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  17641. m.predicates = append(m.predicates, ps...)
  17642. }
  17643. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  17644. // users can use type-assertion to append predicates that do not depend on any generated package.
  17645. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  17646. p := make([]predicate.EmployeeConfig, len(ps))
  17647. for i := range ps {
  17648. p[i] = ps[i]
  17649. }
  17650. m.Where(p...)
  17651. }
  17652. // Op returns the operation name.
  17653. func (m *EmployeeConfigMutation) Op() Op {
  17654. return m.op
  17655. }
  17656. // SetOp allows setting the mutation operation.
  17657. func (m *EmployeeConfigMutation) SetOp(op Op) {
  17658. m.op = op
  17659. }
  17660. // Type returns the node type of this mutation (EmployeeConfig).
  17661. func (m *EmployeeConfigMutation) Type() string {
  17662. return m.typ
  17663. }
  17664. // Fields returns all fields that were changed during this mutation. Note that in
  17665. // order to get all numeric fields that were incremented/decremented, call
  17666. // AddedFields().
  17667. func (m *EmployeeConfigMutation) Fields() []string {
  17668. fields := make([]string, 0, 7)
  17669. if m.created_at != nil {
  17670. fields = append(fields, employeeconfig.FieldCreatedAt)
  17671. }
  17672. if m.updated_at != nil {
  17673. fields = append(fields, employeeconfig.FieldUpdatedAt)
  17674. }
  17675. if m.deleted_at != nil {
  17676. fields = append(fields, employeeconfig.FieldDeletedAt)
  17677. }
  17678. if m.stype != nil {
  17679. fields = append(fields, employeeconfig.FieldStype)
  17680. }
  17681. if m.title != nil {
  17682. fields = append(fields, employeeconfig.FieldTitle)
  17683. }
  17684. if m.photo != nil {
  17685. fields = append(fields, employeeconfig.FieldPhoto)
  17686. }
  17687. if m.organization_id != nil {
  17688. fields = append(fields, employeeconfig.FieldOrganizationID)
  17689. }
  17690. return fields
  17691. }
  17692. // Field returns the value of a field with the given name. The second boolean
  17693. // return value indicates that this field was not set, or was not defined in the
  17694. // schema.
  17695. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  17696. switch name {
  17697. case employeeconfig.FieldCreatedAt:
  17698. return m.CreatedAt()
  17699. case employeeconfig.FieldUpdatedAt:
  17700. return m.UpdatedAt()
  17701. case employeeconfig.FieldDeletedAt:
  17702. return m.DeletedAt()
  17703. case employeeconfig.FieldStype:
  17704. return m.Stype()
  17705. case employeeconfig.FieldTitle:
  17706. return m.Title()
  17707. case employeeconfig.FieldPhoto:
  17708. return m.Photo()
  17709. case employeeconfig.FieldOrganizationID:
  17710. return m.OrganizationID()
  17711. }
  17712. return nil, false
  17713. }
  17714. // OldField returns the old value of the field from the database. An error is
  17715. // returned if the mutation operation is not UpdateOne, or the query to the
  17716. // database failed.
  17717. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17718. switch name {
  17719. case employeeconfig.FieldCreatedAt:
  17720. return m.OldCreatedAt(ctx)
  17721. case employeeconfig.FieldUpdatedAt:
  17722. return m.OldUpdatedAt(ctx)
  17723. case employeeconfig.FieldDeletedAt:
  17724. return m.OldDeletedAt(ctx)
  17725. case employeeconfig.FieldStype:
  17726. return m.OldStype(ctx)
  17727. case employeeconfig.FieldTitle:
  17728. return m.OldTitle(ctx)
  17729. case employeeconfig.FieldPhoto:
  17730. return m.OldPhoto(ctx)
  17731. case employeeconfig.FieldOrganizationID:
  17732. return m.OldOrganizationID(ctx)
  17733. }
  17734. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  17735. }
  17736. // SetField sets the value of a field with the given name. It returns an error if
  17737. // the field is not defined in the schema, or if the type mismatched the field
  17738. // type.
  17739. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  17740. switch name {
  17741. case employeeconfig.FieldCreatedAt:
  17742. v, ok := value.(time.Time)
  17743. if !ok {
  17744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17745. }
  17746. m.SetCreatedAt(v)
  17747. return nil
  17748. case employeeconfig.FieldUpdatedAt:
  17749. v, ok := value.(time.Time)
  17750. if !ok {
  17751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17752. }
  17753. m.SetUpdatedAt(v)
  17754. return nil
  17755. case employeeconfig.FieldDeletedAt:
  17756. v, ok := value.(time.Time)
  17757. if !ok {
  17758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17759. }
  17760. m.SetDeletedAt(v)
  17761. return nil
  17762. case employeeconfig.FieldStype:
  17763. v, ok := value.(string)
  17764. if !ok {
  17765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17766. }
  17767. m.SetStype(v)
  17768. return nil
  17769. case employeeconfig.FieldTitle:
  17770. v, ok := value.(string)
  17771. if !ok {
  17772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17773. }
  17774. m.SetTitle(v)
  17775. return nil
  17776. case employeeconfig.FieldPhoto:
  17777. v, ok := value.(string)
  17778. if !ok {
  17779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17780. }
  17781. m.SetPhoto(v)
  17782. return nil
  17783. case employeeconfig.FieldOrganizationID:
  17784. v, ok := value.(uint64)
  17785. if !ok {
  17786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17787. }
  17788. m.SetOrganizationID(v)
  17789. return nil
  17790. }
  17791. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17792. }
  17793. // AddedFields returns all numeric fields that were incremented/decremented during
  17794. // this mutation.
  17795. func (m *EmployeeConfigMutation) AddedFields() []string {
  17796. var fields []string
  17797. if m.addorganization_id != nil {
  17798. fields = append(fields, employeeconfig.FieldOrganizationID)
  17799. }
  17800. return fields
  17801. }
  17802. // AddedField returns the numeric value that was incremented/decremented on a field
  17803. // with the given name. The second boolean return value indicates that this field
  17804. // was not set, or was not defined in the schema.
  17805. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  17806. switch name {
  17807. case employeeconfig.FieldOrganizationID:
  17808. return m.AddedOrganizationID()
  17809. }
  17810. return nil, false
  17811. }
  17812. // AddField adds the value to the field with the given name. It returns an error if
  17813. // the field is not defined in the schema, or if the type mismatched the field
  17814. // type.
  17815. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  17816. switch name {
  17817. case employeeconfig.FieldOrganizationID:
  17818. v, ok := value.(int64)
  17819. if !ok {
  17820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17821. }
  17822. m.AddOrganizationID(v)
  17823. return nil
  17824. }
  17825. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  17826. }
  17827. // ClearedFields returns all nullable fields that were cleared during this
  17828. // mutation.
  17829. func (m *EmployeeConfigMutation) ClearedFields() []string {
  17830. var fields []string
  17831. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  17832. fields = append(fields, employeeconfig.FieldDeletedAt)
  17833. }
  17834. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  17835. fields = append(fields, employeeconfig.FieldOrganizationID)
  17836. }
  17837. return fields
  17838. }
  17839. // FieldCleared returns a boolean indicating if a field with the given name was
  17840. // cleared in this mutation.
  17841. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  17842. _, ok := m.clearedFields[name]
  17843. return ok
  17844. }
  17845. // ClearField clears the value of the field with the given name. It returns an
  17846. // error if the field is not defined in the schema.
  17847. func (m *EmployeeConfigMutation) ClearField(name string) error {
  17848. switch name {
  17849. case employeeconfig.FieldDeletedAt:
  17850. m.ClearDeletedAt()
  17851. return nil
  17852. case employeeconfig.FieldOrganizationID:
  17853. m.ClearOrganizationID()
  17854. return nil
  17855. }
  17856. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  17857. }
  17858. // ResetField resets all changes in the mutation for the field with the given name.
  17859. // It returns an error if the field is not defined in the schema.
  17860. func (m *EmployeeConfigMutation) ResetField(name string) error {
  17861. switch name {
  17862. case employeeconfig.FieldCreatedAt:
  17863. m.ResetCreatedAt()
  17864. return nil
  17865. case employeeconfig.FieldUpdatedAt:
  17866. m.ResetUpdatedAt()
  17867. return nil
  17868. case employeeconfig.FieldDeletedAt:
  17869. m.ResetDeletedAt()
  17870. return nil
  17871. case employeeconfig.FieldStype:
  17872. m.ResetStype()
  17873. return nil
  17874. case employeeconfig.FieldTitle:
  17875. m.ResetTitle()
  17876. return nil
  17877. case employeeconfig.FieldPhoto:
  17878. m.ResetPhoto()
  17879. return nil
  17880. case employeeconfig.FieldOrganizationID:
  17881. m.ResetOrganizationID()
  17882. return nil
  17883. }
  17884. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  17885. }
  17886. // AddedEdges returns all edge names that were set/added in this mutation.
  17887. func (m *EmployeeConfigMutation) AddedEdges() []string {
  17888. edges := make([]string, 0, 0)
  17889. return edges
  17890. }
  17891. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17892. // name in this mutation.
  17893. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  17894. return nil
  17895. }
  17896. // RemovedEdges returns all edge names that were removed in this mutation.
  17897. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  17898. edges := make([]string, 0, 0)
  17899. return edges
  17900. }
  17901. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17902. // the given name in this mutation.
  17903. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  17904. return nil
  17905. }
  17906. // ClearedEdges returns all edge names that were cleared in this mutation.
  17907. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  17908. edges := make([]string, 0, 0)
  17909. return edges
  17910. }
  17911. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17912. // was cleared in this mutation.
  17913. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  17914. return false
  17915. }
  17916. // ClearEdge clears the value of the edge with the given name. It returns an error
  17917. // if that edge is not defined in the schema.
  17918. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  17919. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  17920. }
  17921. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17922. // It returns an error if the edge is not defined in the schema.
  17923. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  17924. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  17925. }
  17926. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  17927. type LabelMutation struct {
  17928. config
  17929. op Op
  17930. typ string
  17931. id *uint64
  17932. created_at *time.Time
  17933. updated_at *time.Time
  17934. status *uint8
  17935. addstatus *int8
  17936. _type *int
  17937. add_type *int
  17938. name *string
  17939. from *int
  17940. addfrom *int
  17941. mode *int
  17942. addmode *int
  17943. conditions *string
  17944. organization_id *uint64
  17945. addorganization_id *int64
  17946. clearedFields map[string]struct{}
  17947. label_relationships map[uint64]struct{}
  17948. removedlabel_relationships map[uint64]struct{}
  17949. clearedlabel_relationships bool
  17950. done bool
  17951. oldValue func(context.Context) (*Label, error)
  17952. predicates []predicate.Label
  17953. }
  17954. var _ ent.Mutation = (*LabelMutation)(nil)
  17955. // labelOption allows management of the mutation configuration using functional options.
  17956. type labelOption func(*LabelMutation)
  17957. // newLabelMutation creates new mutation for the Label entity.
  17958. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  17959. m := &LabelMutation{
  17960. config: c,
  17961. op: op,
  17962. typ: TypeLabel,
  17963. clearedFields: make(map[string]struct{}),
  17964. }
  17965. for _, opt := range opts {
  17966. opt(m)
  17967. }
  17968. return m
  17969. }
  17970. // withLabelID sets the ID field of the mutation.
  17971. func withLabelID(id uint64) labelOption {
  17972. return func(m *LabelMutation) {
  17973. var (
  17974. err error
  17975. once sync.Once
  17976. value *Label
  17977. )
  17978. m.oldValue = func(ctx context.Context) (*Label, error) {
  17979. once.Do(func() {
  17980. if m.done {
  17981. err = errors.New("querying old values post mutation is not allowed")
  17982. } else {
  17983. value, err = m.Client().Label.Get(ctx, id)
  17984. }
  17985. })
  17986. return value, err
  17987. }
  17988. m.id = &id
  17989. }
  17990. }
  17991. // withLabel sets the old Label of the mutation.
  17992. func withLabel(node *Label) labelOption {
  17993. return func(m *LabelMutation) {
  17994. m.oldValue = func(context.Context) (*Label, error) {
  17995. return node, nil
  17996. }
  17997. m.id = &node.ID
  17998. }
  17999. }
  18000. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18001. // executed in a transaction (ent.Tx), a transactional client is returned.
  18002. func (m LabelMutation) Client() *Client {
  18003. client := &Client{config: m.config}
  18004. client.init()
  18005. return client
  18006. }
  18007. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18008. // it returns an error otherwise.
  18009. func (m LabelMutation) Tx() (*Tx, error) {
  18010. if _, ok := m.driver.(*txDriver); !ok {
  18011. return nil, errors.New("ent: mutation is not running in a transaction")
  18012. }
  18013. tx := &Tx{config: m.config}
  18014. tx.init()
  18015. return tx, nil
  18016. }
  18017. // SetID sets the value of the id field. Note that this
  18018. // operation is only accepted on creation of Label entities.
  18019. func (m *LabelMutation) SetID(id uint64) {
  18020. m.id = &id
  18021. }
  18022. // ID returns the ID value in the mutation. Note that the ID is only available
  18023. // if it was provided to the builder or after it was returned from the database.
  18024. func (m *LabelMutation) ID() (id uint64, exists bool) {
  18025. if m.id == nil {
  18026. return
  18027. }
  18028. return *m.id, true
  18029. }
  18030. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18031. // That means, if the mutation is applied within a transaction with an isolation level such
  18032. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18033. // or updated by the mutation.
  18034. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  18035. switch {
  18036. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18037. id, exists := m.ID()
  18038. if exists {
  18039. return []uint64{id}, nil
  18040. }
  18041. fallthrough
  18042. case m.op.Is(OpUpdate | OpDelete):
  18043. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  18044. default:
  18045. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18046. }
  18047. }
  18048. // SetCreatedAt sets the "created_at" field.
  18049. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  18050. m.created_at = &t
  18051. }
  18052. // CreatedAt returns the value of the "created_at" field in the mutation.
  18053. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  18054. v := m.created_at
  18055. if v == nil {
  18056. return
  18057. }
  18058. return *v, true
  18059. }
  18060. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  18061. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18063. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18064. if !m.op.Is(OpUpdateOne) {
  18065. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18066. }
  18067. if m.id == nil || m.oldValue == nil {
  18068. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18069. }
  18070. oldValue, err := m.oldValue(ctx)
  18071. if err != nil {
  18072. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18073. }
  18074. return oldValue.CreatedAt, nil
  18075. }
  18076. // ResetCreatedAt resets all changes to the "created_at" field.
  18077. func (m *LabelMutation) ResetCreatedAt() {
  18078. m.created_at = nil
  18079. }
  18080. // SetUpdatedAt sets the "updated_at" field.
  18081. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  18082. m.updated_at = &t
  18083. }
  18084. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18085. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  18086. v := m.updated_at
  18087. if v == nil {
  18088. return
  18089. }
  18090. return *v, true
  18091. }
  18092. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  18093. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18095. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18096. if !m.op.Is(OpUpdateOne) {
  18097. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18098. }
  18099. if m.id == nil || m.oldValue == nil {
  18100. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18101. }
  18102. oldValue, err := m.oldValue(ctx)
  18103. if err != nil {
  18104. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18105. }
  18106. return oldValue.UpdatedAt, nil
  18107. }
  18108. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18109. func (m *LabelMutation) ResetUpdatedAt() {
  18110. m.updated_at = nil
  18111. }
  18112. // SetStatus sets the "status" field.
  18113. func (m *LabelMutation) SetStatus(u uint8) {
  18114. m.status = &u
  18115. m.addstatus = nil
  18116. }
  18117. // Status returns the value of the "status" field in the mutation.
  18118. func (m *LabelMutation) Status() (r uint8, exists bool) {
  18119. v := m.status
  18120. if v == nil {
  18121. return
  18122. }
  18123. return *v, true
  18124. }
  18125. // OldStatus returns the old "status" field's value of the Label entity.
  18126. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18128. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18129. if !m.op.Is(OpUpdateOne) {
  18130. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18131. }
  18132. if m.id == nil || m.oldValue == nil {
  18133. return v, errors.New("OldStatus requires an ID field in the mutation")
  18134. }
  18135. oldValue, err := m.oldValue(ctx)
  18136. if err != nil {
  18137. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18138. }
  18139. return oldValue.Status, nil
  18140. }
  18141. // AddStatus adds u to the "status" field.
  18142. func (m *LabelMutation) AddStatus(u int8) {
  18143. if m.addstatus != nil {
  18144. *m.addstatus += u
  18145. } else {
  18146. m.addstatus = &u
  18147. }
  18148. }
  18149. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18150. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  18151. v := m.addstatus
  18152. if v == nil {
  18153. return
  18154. }
  18155. return *v, true
  18156. }
  18157. // ClearStatus clears the value of the "status" field.
  18158. func (m *LabelMutation) ClearStatus() {
  18159. m.status = nil
  18160. m.addstatus = nil
  18161. m.clearedFields[label.FieldStatus] = struct{}{}
  18162. }
  18163. // StatusCleared returns if the "status" field was cleared in this mutation.
  18164. func (m *LabelMutation) StatusCleared() bool {
  18165. _, ok := m.clearedFields[label.FieldStatus]
  18166. return ok
  18167. }
  18168. // ResetStatus resets all changes to the "status" field.
  18169. func (m *LabelMutation) ResetStatus() {
  18170. m.status = nil
  18171. m.addstatus = nil
  18172. delete(m.clearedFields, label.FieldStatus)
  18173. }
  18174. // SetType sets the "type" field.
  18175. func (m *LabelMutation) SetType(i int) {
  18176. m._type = &i
  18177. m.add_type = nil
  18178. }
  18179. // GetType returns the value of the "type" field in the mutation.
  18180. func (m *LabelMutation) GetType() (r int, exists bool) {
  18181. v := m._type
  18182. if v == nil {
  18183. return
  18184. }
  18185. return *v, true
  18186. }
  18187. // OldType returns the old "type" field's value of the Label entity.
  18188. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18190. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  18191. if !m.op.Is(OpUpdateOne) {
  18192. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18193. }
  18194. if m.id == nil || m.oldValue == nil {
  18195. return v, errors.New("OldType requires an ID field in the mutation")
  18196. }
  18197. oldValue, err := m.oldValue(ctx)
  18198. if err != nil {
  18199. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18200. }
  18201. return oldValue.Type, nil
  18202. }
  18203. // AddType adds i to the "type" field.
  18204. func (m *LabelMutation) AddType(i int) {
  18205. if m.add_type != nil {
  18206. *m.add_type += i
  18207. } else {
  18208. m.add_type = &i
  18209. }
  18210. }
  18211. // AddedType returns the value that was added to the "type" field in this mutation.
  18212. func (m *LabelMutation) AddedType() (r int, exists bool) {
  18213. v := m.add_type
  18214. if v == nil {
  18215. return
  18216. }
  18217. return *v, true
  18218. }
  18219. // ResetType resets all changes to the "type" field.
  18220. func (m *LabelMutation) ResetType() {
  18221. m._type = nil
  18222. m.add_type = nil
  18223. }
  18224. // SetName sets the "name" field.
  18225. func (m *LabelMutation) SetName(s string) {
  18226. m.name = &s
  18227. }
  18228. // Name returns the value of the "name" field in the mutation.
  18229. func (m *LabelMutation) Name() (r string, exists bool) {
  18230. v := m.name
  18231. if v == nil {
  18232. return
  18233. }
  18234. return *v, true
  18235. }
  18236. // OldName returns the old "name" field's value of the Label entity.
  18237. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18239. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  18240. if !m.op.Is(OpUpdateOne) {
  18241. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18242. }
  18243. if m.id == nil || m.oldValue == nil {
  18244. return v, errors.New("OldName requires an ID field in the mutation")
  18245. }
  18246. oldValue, err := m.oldValue(ctx)
  18247. if err != nil {
  18248. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18249. }
  18250. return oldValue.Name, nil
  18251. }
  18252. // ResetName resets all changes to the "name" field.
  18253. func (m *LabelMutation) ResetName() {
  18254. m.name = nil
  18255. }
  18256. // SetFrom sets the "from" field.
  18257. func (m *LabelMutation) SetFrom(i int) {
  18258. m.from = &i
  18259. m.addfrom = nil
  18260. }
  18261. // From returns the value of the "from" field in the mutation.
  18262. func (m *LabelMutation) From() (r int, exists bool) {
  18263. v := m.from
  18264. if v == nil {
  18265. return
  18266. }
  18267. return *v, true
  18268. }
  18269. // OldFrom returns the old "from" field's value of the Label entity.
  18270. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18272. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  18273. if !m.op.Is(OpUpdateOne) {
  18274. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  18275. }
  18276. if m.id == nil || m.oldValue == nil {
  18277. return v, errors.New("OldFrom requires an ID field in the mutation")
  18278. }
  18279. oldValue, err := m.oldValue(ctx)
  18280. if err != nil {
  18281. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  18282. }
  18283. return oldValue.From, nil
  18284. }
  18285. // AddFrom adds i to the "from" field.
  18286. func (m *LabelMutation) AddFrom(i int) {
  18287. if m.addfrom != nil {
  18288. *m.addfrom += i
  18289. } else {
  18290. m.addfrom = &i
  18291. }
  18292. }
  18293. // AddedFrom returns the value that was added to the "from" field in this mutation.
  18294. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  18295. v := m.addfrom
  18296. if v == nil {
  18297. return
  18298. }
  18299. return *v, true
  18300. }
  18301. // ResetFrom resets all changes to the "from" field.
  18302. func (m *LabelMutation) ResetFrom() {
  18303. m.from = nil
  18304. m.addfrom = nil
  18305. }
  18306. // SetMode sets the "mode" field.
  18307. func (m *LabelMutation) SetMode(i int) {
  18308. m.mode = &i
  18309. m.addmode = nil
  18310. }
  18311. // Mode returns the value of the "mode" field in the mutation.
  18312. func (m *LabelMutation) Mode() (r int, exists bool) {
  18313. v := m.mode
  18314. if v == nil {
  18315. return
  18316. }
  18317. return *v, true
  18318. }
  18319. // OldMode returns the old "mode" field's value of the Label entity.
  18320. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18322. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  18323. if !m.op.Is(OpUpdateOne) {
  18324. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  18325. }
  18326. if m.id == nil || m.oldValue == nil {
  18327. return v, errors.New("OldMode requires an ID field in the mutation")
  18328. }
  18329. oldValue, err := m.oldValue(ctx)
  18330. if err != nil {
  18331. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  18332. }
  18333. return oldValue.Mode, nil
  18334. }
  18335. // AddMode adds i to the "mode" field.
  18336. func (m *LabelMutation) AddMode(i int) {
  18337. if m.addmode != nil {
  18338. *m.addmode += i
  18339. } else {
  18340. m.addmode = &i
  18341. }
  18342. }
  18343. // AddedMode returns the value that was added to the "mode" field in this mutation.
  18344. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  18345. v := m.addmode
  18346. if v == nil {
  18347. return
  18348. }
  18349. return *v, true
  18350. }
  18351. // ResetMode resets all changes to the "mode" field.
  18352. func (m *LabelMutation) ResetMode() {
  18353. m.mode = nil
  18354. m.addmode = nil
  18355. }
  18356. // SetConditions sets the "conditions" field.
  18357. func (m *LabelMutation) SetConditions(s string) {
  18358. m.conditions = &s
  18359. }
  18360. // Conditions returns the value of the "conditions" field in the mutation.
  18361. func (m *LabelMutation) Conditions() (r string, exists bool) {
  18362. v := m.conditions
  18363. if v == nil {
  18364. return
  18365. }
  18366. return *v, true
  18367. }
  18368. // OldConditions returns the old "conditions" field's value of the Label entity.
  18369. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18371. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  18372. if !m.op.Is(OpUpdateOne) {
  18373. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18374. }
  18375. if m.id == nil || m.oldValue == nil {
  18376. return v, errors.New("OldConditions requires an ID field in the mutation")
  18377. }
  18378. oldValue, err := m.oldValue(ctx)
  18379. if err != nil {
  18380. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18381. }
  18382. return oldValue.Conditions, nil
  18383. }
  18384. // ClearConditions clears the value of the "conditions" field.
  18385. func (m *LabelMutation) ClearConditions() {
  18386. m.conditions = nil
  18387. m.clearedFields[label.FieldConditions] = struct{}{}
  18388. }
  18389. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  18390. func (m *LabelMutation) ConditionsCleared() bool {
  18391. _, ok := m.clearedFields[label.FieldConditions]
  18392. return ok
  18393. }
  18394. // ResetConditions resets all changes to the "conditions" field.
  18395. func (m *LabelMutation) ResetConditions() {
  18396. m.conditions = nil
  18397. delete(m.clearedFields, label.FieldConditions)
  18398. }
  18399. // SetOrganizationID sets the "organization_id" field.
  18400. func (m *LabelMutation) SetOrganizationID(u uint64) {
  18401. m.organization_id = &u
  18402. m.addorganization_id = nil
  18403. }
  18404. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18405. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  18406. v := m.organization_id
  18407. if v == nil {
  18408. return
  18409. }
  18410. return *v, true
  18411. }
  18412. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  18413. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18415. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18416. if !m.op.Is(OpUpdateOne) {
  18417. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18418. }
  18419. if m.id == nil || m.oldValue == nil {
  18420. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18421. }
  18422. oldValue, err := m.oldValue(ctx)
  18423. if err != nil {
  18424. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18425. }
  18426. return oldValue.OrganizationID, nil
  18427. }
  18428. // AddOrganizationID adds u to the "organization_id" field.
  18429. func (m *LabelMutation) AddOrganizationID(u int64) {
  18430. if m.addorganization_id != nil {
  18431. *m.addorganization_id += u
  18432. } else {
  18433. m.addorganization_id = &u
  18434. }
  18435. }
  18436. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18437. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  18438. v := m.addorganization_id
  18439. if v == nil {
  18440. return
  18441. }
  18442. return *v, true
  18443. }
  18444. // ClearOrganizationID clears the value of the "organization_id" field.
  18445. func (m *LabelMutation) ClearOrganizationID() {
  18446. m.organization_id = nil
  18447. m.addorganization_id = nil
  18448. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  18449. }
  18450. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18451. func (m *LabelMutation) OrganizationIDCleared() bool {
  18452. _, ok := m.clearedFields[label.FieldOrganizationID]
  18453. return ok
  18454. }
  18455. // ResetOrganizationID resets all changes to the "organization_id" field.
  18456. func (m *LabelMutation) ResetOrganizationID() {
  18457. m.organization_id = nil
  18458. m.addorganization_id = nil
  18459. delete(m.clearedFields, label.FieldOrganizationID)
  18460. }
  18461. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  18462. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  18463. if m.label_relationships == nil {
  18464. m.label_relationships = make(map[uint64]struct{})
  18465. }
  18466. for i := range ids {
  18467. m.label_relationships[ids[i]] = struct{}{}
  18468. }
  18469. }
  18470. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  18471. func (m *LabelMutation) ClearLabelRelationships() {
  18472. m.clearedlabel_relationships = true
  18473. }
  18474. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  18475. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  18476. return m.clearedlabel_relationships
  18477. }
  18478. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  18479. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  18480. if m.removedlabel_relationships == nil {
  18481. m.removedlabel_relationships = make(map[uint64]struct{})
  18482. }
  18483. for i := range ids {
  18484. delete(m.label_relationships, ids[i])
  18485. m.removedlabel_relationships[ids[i]] = struct{}{}
  18486. }
  18487. }
  18488. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  18489. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  18490. for id := range m.removedlabel_relationships {
  18491. ids = append(ids, id)
  18492. }
  18493. return
  18494. }
  18495. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  18496. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  18497. for id := range m.label_relationships {
  18498. ids = append(ids, id)
  18499. }
  18500. return
  18501. }
  18502. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  18503. func (m *LabelMutation) ResetLabelRelationships() {
  18504. m.label_relationships = nil
  18505. m.clearedlabel_relationships = false
  18506. m.removedlabel_relationships = nil
  18507. }
  18508. // Where appends a list predicates to the LabelMutation builder.
  18509. func (m *LabelMutation) Where(ps ...predicate.Label) {
  18510. m.predicates = append(m.predicates, ps...)
  18511. }
  18512. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  18513. // users can use type-assertion to append predicates that do not depend on any generated package.
  18514. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  18515. p := make([]predicate.Label, len(ps))
  18516. for i := range ps {
  18517. p[i] = ps[i]
  18518. }
  18519. m.Where(p...)
  18520. }
  18521. // Op returns the operation name.
  18522. func (m *LabelMutation) Op() Op {
  18523. return m.op
  18524. }
  18525. // SetOp allows setting the mutation operation.
  18526. func (m *LabelMutation) SetOp(op Op) {
  18527. m.op = op
  18528. }
  18529. // Type returns the node type of this mutation (Label).
  18530. func (m *LabelMutation) Type() string {
  18531. return m.typ
  18532. }
  18533. // Fields returns all fields that were changed during this mutation. Note that in
  18534. // order to get all numeric fields that were incremented/decremented, call
  18535. // AddedFields().
  18536. func (m *LabelMutation) Fields() []string {
  18537. fields := make([]string, 0, 9)
  18538. if m.created_at != nil {
  18539. fields = append(fields, label.FieldCreatedAt)
  18540. }
  18541. if m.updated_at != nil {
  18542. fields = append(fields, label.FieldUpdatedAt)
  18543. }
  18544. if m.status != nil {
  18545. fields = append(fields, label.FieldStatus)
  18546. }
  18547. if m._type != nil {
  18548. fields = append(fields, label.FieldType)
  18549. }
  18550. if m.name != nil {
  18551. fields = append(fields, label.FieldName)
  18552. }
  18553. if m.from != nil {
  18554. fields = append(fields, label.FieldFrom)
  18555. }
  18556. if m.mode != nil {
  18557. fields = append(fields, label.FieldMode)
  18558. }
  18559. if m.conditions != nil {
  18560. fields = append(fields, label.FieldConditions)
  18561. }
  18562. if m.organization_id != nil {
  18563. fields = append(fields, label.FieldOrganizationID)
  18564. }
  18565. return fields
  18566. }
  18567. // Field returns the value of a field with the given name. The second boolean
  18568. // return value indicates that this field was not set, or was not defined in the
  18569. // schema.
  18570. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  18571. switch name {
  18572. case label.FieldCreatedAt:
  18573. return m.CreatedAt()
  18574. case label.FieldUpdatedAt:
  18575. return m.UpdatedAt()
  18576. case label.FieldStatus:
  18577. return m.Status()
  18578. case label.FieldType:
  18579. return m.GetType()
  18580. case label.FieldName:
  18581. return m.Name()
  18582. case label.FieldFrom:
  18583. return m.From()
  18584. case label.FieldMode:
  18585. return m.Mode()
  18586. case label.FieldConditions:
  18587. return m.Conditions()
  18588. case label.FieldOrganizationID:
  18589. return m.OrganizationID()
  18590. }
  18591. return nil, false
  18592. }
  18593. // OldField returns the old value of the field from the database. An error is
  18594. // returned if the mutation operation is not UpdateOne, or the query to the
  18595. // database failed.
  18596. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18597. switch name {
  18598. case label.FieldCreatedAt:
  18599. return m.OldCreatedAt(ctx)
  18600. case label.FieldUpdatedAt:
  18601. return m.OldUpdatedAt(ctx)
  18602. case label.FieldStatus:
  18603. return m.OldStatus(ctx)
  18604. case label.FieldType:
  18605. return m.OldType(ctx)
  18606. case label.FieldName:
  18607. return m.OldName(ctx)
  18608. case label.FieldFrom:
  18609. return m.OldFrom(ctx)
  18610. case label.FieldMode:
  18611. return m.OldMode(ctx)
  18612. case label.FieldConditions:
  18613. return m.OldConditions(ctx)
  18614. case label.FieldOrganizationID:
  18615. return m.OldOrganizationID(ctx)
  18616. }
  18617. return nil, fmt.Errorf("unknown Label field %s", name)
  18618. }
  18619. // SetField sets the value of a field with the given name. It returns an error if
  18620. // the field is not defined in the schema, or if the type mismatched the field
  18621. // type.
  18622. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  18623. switch name {
  18624. case label.FieldCreatedAt:
  18625. v, ok := value.(time.Time)
  18626. if !ok {
  18627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18628. }
  18629. m.SetCreatedAt(v)
  18630. return nil
  18631. case label.FieldUpdatedAt:
  18632. v, ok := value.(time.Time)
  18633. if !ok {
  18634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18635. }
  18636. m.SetUpdatedAt(v)
  18637. return nil
  18638. case label.FieldStatus:
  18639. v, ok := value.(uint8)
  18640. if !ok {
  18641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18642. }
  18643. m.SetStatus(v)
  18644. return nil
  18645. case label.FieldType:
  18646. v, ok := value.(int)
  18647. if !ok {
  18648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18649. }
  18650. m.SetType(v)
  18651. return nil
  18652. case label.FieldName:
  18653. v, ok := value.(string)
  18654. if !ok {
  18655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18656. }
  18657. m.SetName(v)
  18658. return nil
  18659. case label.FieldFrom:
  18660. v, ok := value.(int)
  18661. if !ok {
  18662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18663. }
  18664. m.SetFrom(v)
  18665. return nil
  18666. case label.FieldMode:
  18667. v, ok := value.(int)
  18668. if !ok {
  18669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18670. }
  18671. m.SetMode(v)
  18672. return nil
  18673. case label.FieldConditions:
  18674. v, ok := value.(string)
  18675. if !ok {
  18676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18677. }
  18678. m.SetConditions(v)
  18679. return nil
  18680. case label.FieldOrganizationID:
  18681. v, ok := value.(uint64)
  18682. if !ok {
  18683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18684. }
  18685. m.SetOrganizationID(v)
  18686. return nil
  18687. }
  18688. return fmt.Errorf("unknown Label field %s", name)
  18689. }
  18690. // AddedFields returns all numeric fields that were incremented/decremented during
  18691. // this mutation.
  18692. func (m *LabelMutation) AddedFields() []string {
  18693. var fields []string
  18694. if m.addstatus != nil {
  18695. fields = append(fields, label.FieldStatus)
  18696. }
  18697. if m.add_type != nil {
  18698. fields = append(fields, label.FieldType)
  18699. }
  18700. if m.addfrom != nil {
  18701. fields = append(fields, label.FieldFrom)
  18702. }
  18703. if m.addmode != nil {
  18704. fields = append(fields, label.FieldMode)
  18705. }
  18706. if m.addorganization_id != nil {
  18707. fields = append(fields, label.FieldOrganizationID)
  18708. }
  18709. return fields
  18710. }
  18711. // AddedField returns the numeric value that was incremented/decremented on a field
  18712. // with the given name. The second boolean return value indicates that this field
  18713. // was not set, or was not defined in the schema.
  18714. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  18715. switch name {
  18716. case label.FieldStatus:
  18717. return m.AddedStatus()
  18718. case label.FieldType:
  18719. return m.AddedType()
  18720. case label.FieldFrom:
  18721. return m.AddedFrom()
  18722. case label.FieldMode:
  18723. return m.AddedMode()
  18724. case label.FieldOrganizationID:
  18725. return m.AddedOrganizationID()
  18726. }
  18727. return nil, false
  18728. }
  18729. // AddField adds the value to the field with the given name. It returns an error if
  18730. // the field is not defined in the schema, or if the type mismatched the field
  18731. // type.
  18732. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  18733. switch name {
  18734. case label.FieldStatus:
  18735. v, ok := value.(int8)
  18736. if !ok {
  18737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18738. }
  18739. m.AddStatus(v)
  18740. return nil
  18741. case label.FieldType:
  18742. v, ok := value.(int)
  18743. if !ok {
  18744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18745. }
  18746. m.AddType(v)
  18747. return nil
  18748. case label.FieldFrom:
  18749. v, ok := value.(int)
  18750. if !ok {
  18751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18752. }
  18753. m.AddFrom(v)
  18754. return nil
  18755. case label.FieldMode:
  18756. v, ok := value.(int)
  18757. if !ok {
  18758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18759. }
  18760. m.AddMode(v)
  18761. return nil
  18762. case label.FieldOrganizationID:
  18763. v, ok := value.(int64)
  18764. if !ok {
  18765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18766. }
  18767. m.AddOrganizationID(v)
  18768. return nil
  18769. }
  18770. return fmt.Errorf("unknown Label numeric field %s", name)
  18771. }
  18772. // ClearedFields returns all nullable fields that were cleared during this
  18773. // mutation.
  18774. func (m *LabelMutation) ClearedFields() []string {
  18775. var fields []string
  18776. if m.FieldCleared(label.FieldStatus) {
  18777. fields = append(fields, label.FieldStatus)
  18778. }
  18779. if m.FieldCleared(label.FieldConditions) {
  18780. fields = append(fields, label.FieldConditions)
  18781. }
  18782. if m.FieldCleared(label.FieldOrganizationID) {
  18783. fields = append(fields, label.FieldOrganizationID)
  18784. }
  18785. return fields
  18786. }
  18787. // FieldCleared returns a boolean indicating if a field with the given name was
  18788. // cleared in this mutation.
  18789. func (m *LabelMutation) FieldCleared(name string) bool {
  18790. _, ok := m.clearedFields[name]
  18791. return ok
  18792. }
  18793. // ClearField clears the value of the field with the given name. It returns an
  18794. // error if the field is not defined in the schema.
  18795. func (m *LabelMutation) ClearField(name string) error {
  18796. switch name {
  18797. case label.FieldStatus:
  18798. m.ClearStatus()
  18799. return nil
  18800. case label.FieldConditions:
  18801. m.ClearConditions()
  18802. return nil
  18803. case label.FieldOrganizationID:
  18804. m.ClearOrganizationID()
  18805. return nil
  18806. }
  18807. return fmt.Errorf("unknown Label nullable field %s", name)
  18808. }
  18809. // ResetField resets all changes in the mutation for the field with the given name.
  18810. // It returns an error if the field is not defined in the schema.
  18811. func (m *LabelMutation) ResetField(name string) error {
  18812. switch name {
  18813. case label.FieldCreatedAt:
  18814. m.ResetCreatedAt()
  18815. return nil
  18816. case label.FieldUpdatedAt:
  18817. m.ResetUpdatedAt()
  18818. return nil
  18819. case label.FieldStatus:
  18820. m.ResetStatus()
  18821. return nil
  18822. case label.FieldType:
  18823. m.ResetType()
  18824. return nil
  18825. case label.FieldName:
  18826. m.ResetName()
  18827. return nil
  18828. case label.FieldFrom:
  18829. m.ResetFrom()
  18830. return nil
  18831. case label.FieldMode:
  18832. m.ResetMode()
  18833. return nil
  18834. case label.FieldConditions:
  18835. m.ResetConditions()
  18836. return nil
  18837. case label.FieldOrganizationID:
  18838. m.ResetOrganizationID()
  18839. return nil
  18840. }
  18841. return fmt.Errorf("unknown Label field %s", name)
  18842. }
  18843. // AddedEdges returns all edge names that were set/added in this mutation.
  18844. func (m *LabelMutation) AddedEdges() []string {
  18845. edges := make([]string, 0, 1)
  18846. if m.label_relationships != nil {
  18847. edges = append(edges, label.EdgeLabelRelationships)
  18848. }
  18849. return edges
  18850. }
  18851. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18852. // name in this mutation.
  18853. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  18854. switch name {
  18855. case label.EdgeLabelRelationships:
  18856. ids := make([]ent.Value, 0, len(m.label_relationships))
  18857. for id := range m.label_relationships {
  18858. ids = append(ids, id)
  18859. }
  18860. return ids
  18861. }
  18862. return nil
  18863. }
  18864. // RemovedEdges returns all edge names that were removed in this mutation.
  18865. func (m *LabelMutation) RemovedEdges() []string {
  18866. edges := make([]string, 0, 1)
  18867. if m.removedlabel_relationships != nil {
  18868. edges = append(edges, label.EdgeLabelRelationships)
  18869. }
  18870. return edges
  18871. }
  18872. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18873. // the given name in this mutation.
  18874. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  18875. switch name {
  18876. case label.EdgeLabelRelationships:
  18877. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  18878. for id := range m.removedlabel_relationships {
  18879. ids = append(ids, id)
  18880. }
  18881. return ids
  18882. }
  18883. return nil
  18884. }
  18885. // ClearedEdges returns all edge names that were cleared in this mutation.
  18886. func (m *LabelMutation) ClearedEdges() []string {
  18887. edges := make([]string, 0, 1)
  18888. if m.clearedlabel_relationships {
  18889. edges = append(edges, label.EdgeLabelRelationships)
  18890. }
  18891. return edges
  18892. }
  18893. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18894. // was cleared in this mutation.
  18895. func (m *LabelMutation) EdgeCleared(name string) bool {
  18896. switch name {
  18897. case label.EdgeLabelRelationships:
  18898. return m.clearedlabel_relationships
  18899. }
  18900. return false
  18901. }
  18902. // ClearEdge clears the value of the edge with the given name. It returns an error
  18903. // if that edge is not defined in the schema.
  18904. func (m *LabelMutation) ClearEdge(name string) error {
  18905. switch name {
  18906. }
  18907. return fmt.Errorf("unknown Label unique edge %s", name)
  18908. }
  18909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18910. // It returns an error if the edge is not defined in the schema.
  18911. func (m *LabelMutation) ResetEdge(name string) error {
  18912. switch name {
  18913. case label.EdgeLabelRelationships:
  18914. m.ResetLabelRelationships()
  18915. return nil
  18916. }
  18917. return fmt.Errorf("unknown Label edge %s", name)
  18918. }
  18919. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  18920. type LabelRelationshipMutation struct {
  18921. config
  18922. op Op
  18923. typ string
  18924. id *uint64
  18925. created_at *time.Time
  18926. updated_at *time.Time
  18927. status *uint8
  18928. addstatus *int8
  18929. organization_id *uint64
  18930. addorganization_id *int64
  18931. clearedFields map[string]struct{}
  18932. contacts *uint64
  18933. clearedcontacts bool
  18934. labels *uint64
  18935. clearedlabels bool
  18936. done bool
  18937. oldValue func(context.Context) (*LabelRelationship, error)
  18938. predicates []predicate.LabelRelationship
  18939. }
  18940. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  18941. // labelrelationshipOption allows management of the mutation configuration using functional options.
  18942. type labelrelationshipOption func(*LabelRelationshipMutation)
  18943. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  18944. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  18945. m := &LabelRelationshipMutation{
  18946. config: c,
  18947. op: op,
  18948. typ: TypeLabelRelationship,
  18949. clearedFields: make(map[string]struct{}),
  18950. }
  18951. for _, opt := range opts {
  18952. opt(m)
  18953. }
  18954. return m
  18955. }
  18956. // withLabelRelationshipID sets the ID field of the mutation.
  18957. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  18958. return func(m *LabelRelationshipMutation) {
  18959. var (
  18960. err error
  18961. once sync.Once
  18962. value *LabelRelationship
  18963. )
  18964. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  18965. once.Do(func() {
  18966. if m.done {
  18967. err = errors.New("querying old values post mutation is not allowed")
  18968. } else {
  18969. value, err = m.Client().LabelRelationship.Get(ctx, id)
  18970. }
  18971. })
  18972. return value, err
  18973. }
  18974. m.id = &id
  18975. }
  18976. }
  18977. // withLabelRelationship sets the old LabelRelationship of the mutation.
  18978. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  18979. return func(m *LabelRelationshipMutation) {
  18980. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  18981. return node, nil
  18982. }
  18983. m.id = &node.ID
  18984. }
  18985. }
  18986. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18987. // executed in a transaction (ent.Tx), a transactional client is returned.
  18988. func (m LabelRelationshipMutation) Client() *Client {
  18989. client := &Client{config: m.config}
  18990. client.init()
  18991. return client
  18992. }
  18993. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18994. // it returns an error otherwise.
  18995. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  18996. if _, ok := m.driver.(*txDriver); !ok {
  18997. return nil, errors.New("ent: mutation is not running in a transaction")
  18998. }
  18999. tx := &Tx{config: m.config}
  19000. tx.init()
  19001. return tx, nil
  19002. }
  19003. // SetID sets the value of the id field. Note that this
  19004. // operation is only accepted on creation of LabelRelationship entities.
  19005. func (m *LabelRelationshipMutation) SetID(id uint64) {
  19006. m.id = &id
  19007. }
  19008. // ID returns the ID value in the mutation. Note that the ID is only available
  19009. // if it was provided to the builder or after it was returned from the database.
  19010. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  19011. if m.id == nil {
  19012. return
  19013. }
  19014. return *m.id, true
  19015. }
  19016. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19017. // That means, if the mutation is applied within a transaction with an isolation level such
  19018. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19019. // or updated by the mutation.
  19020. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  19021. switch {
  19022. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19023. id, exists := m.ID()
  19024. if exists {
  19025. return []uint64{id}, nil
  19026. }
  19027. fallthrough
  19028. case m.op.Is(OpUpdate | OpDelete):
  19029. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  19030. default:
  19031. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19032. }
  19033. }
  19034. // SetCreatedAt sets the "created_at" field.
  19035. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  19036. m.created_at = &t
  19037. }
  19038. // CreatedAt returns the value of the "created_at" field in the mutation.
  19039. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  19040. v := m.created_at
  19041. if v == nil {
  19042. return
  19043. }
  19044. return *v, true
  19045. }
  19046. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  19047. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19049. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19050. if !m.op.Is(OpUpdateOne) {
  19051. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19052. }
  19053. if m.id == nil || m.oldValue == nil {
  19054. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19055. }
  19056. oldValue, err := m.oldValue(ctx)
  19057. if err != nil {
  19058. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19059. }
  19060. return oldValue.CreatedAt, nil
  19061. }
  19062. // ResetCreatedAt resets all changes to the "created_at" field.
  19063. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  19064. m.created_at = nil
  19065. }
  19066. // SetUpdatedAt sets the "updated_at" field.
  19067. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  19068. m.updated_at = &t
  19069. }
  19070. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19071. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  19072. v := m.updated_at
  19073. if v == nil {
  19074. return
  19075. }
  19076. return *v, true
  19077. }
  19078. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  19079. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19081. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19082. if !m.op.Is(OpUpdateOne) {
  19083. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19084. }
  19085. if m.id == nil || m.oldValue == nil {
  19086. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19087. }
  19088. oldValue, err := m.oldValue(ctx)
  19089. if err != nil {
  19090. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19091. }
  19092. return oldValue.UpdatedAt, nil
  19093. }
  19094. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19095. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  19096. m.updated_at = nil
  19097. }
  19098. // SetStatus sets the "status" field.
  19099. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  19100. m.status = &u
  19101. m.addstatus = nil
  19102. }
  19103. // Status returns the value of the "status" field in the mutation.
  19104. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  19105. v := m.status
  19106. if v == nil {
  19107. return
  19108. }
  19109. return *v, true
  19110. }
  19111. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  19112. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19114. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19115. if !m.op.Is(OpUpdateOne) {
  19116. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19117. }
  19118. if m.id == nil || m.oldValue == nil {
  19119. return v, errors.New("OldStatus requires an ID field in the mutation")
  19120. }
  19121. oldValue, err := m.oldValue(ctx)
  19122. if err != nil {
  19123. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19124. }
  19125. return oldValue.Status, nil
  19126. }
  19127. // AddStatus adds u to the "status" field.
  19128. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  19129. if m.addstatus != nil {
  19130. *m.addstatus += u
  19131. } else {
  19132. m.addstatus = &u
  19133. }
  19134. }
  19135. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19136. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  19137. v := m.addstatus
  19138. if v == nil {
  19139. return
  19140. }
  19141. return *v, true
  19142. }
  19143. // ClearStatus clears the value of the "status" field.
  19144. func (m *LabelRelationshipMutation) ClearStatus() {
  19145. m.status = nil
  19146. m.addstatus = nil
  19147. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  19148. }
  19149. // StatusCleared returns if the "status" field was cleared in this mutation.
  19150. func (m *LabelRelationshipMutation) StatusCleared() bool {
  19151. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  19152. return ok
  19153. }
  19154. // ResetStatus resets all changes to the "status" field.
  19155. func (m *LabelRelationshipMutation) ResetStatus() {
  19156. m.status = nil
  19157. m.addstatus = nil
  19158. delete(m.clearedFields, labelrelationship.FieldStatus)
  19159. }
  19160. // SetLabelID sets the "label_id" field.
  19161. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  19162. m.labels = &u
  19163. }
  19164. // LabelID returns the value of the "label_id" field in the mutation.
  19165. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  19166. v := m.labels
  19167. if v == nil {
  19168. return
  19169. }
  19170. return *v, true
  19171. }
  19172. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  19173. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19175. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  19176. if !m.op.Is(OpUpdateOne) {
  19177. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  19178. }
  19179. if m.id == nil || m.oldValue == nil {
  19180. return v, errors.New("OldLabelID requires an ID field in the mutation")
  19181. }
  19182. oldValue, err := m.oldValue(ctx)
  19183. if err != nil {
  19184. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  19185. }
  19186. return oldValue.LabelID, nil
  19187. }
  19188. // ResetLabelID resets all changes to the "label_id" field.
  19189. func (m *LabelRelationshipMutation) ResetLabelID() {
  19190. m.labels = nil
  19191. }
  19192. // SetContactID sets the "contact_id" field.
  19193. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  19194. m.contacts = &u
  19195. }
  19196. // ContactID returns the value of the "contact_id" field in the mutation.
  19197. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  19198. v := m.contacts
  19199. if v == nil {
  19200. return
  19201. }
  19202. return *v, true
  19203. }
  19204. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  19205. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19207. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19208. if !m.op.Is(OpUpdateOne) {
  19209. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19210. }
  19211. if m.id == nil || m.oldValue == nil {
  19212. return v, errors.New("OldContactID requires an ID field in the mutation")
  19213. }
  19214. oldValue, err := m.oldValue(ctx)
  19215. if err != nil {
  19216. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19217. }
  19218. return oldValue.ContactID, nil
  19219. }
  19220. // ResetContactID resets all changes to the "contact_id" field.
  19221. func (m *LabelRelationshipMutation) ResetContactID() {
  19222. m.contacts = nil
  19223. }
  19224. // SetOrganizationID sets the "organization_id" field.
  19225. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  19226. m.organization_id = &u
  19227. m.addorganization_id = nil
  19228. }
  19229. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19230. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  19231. v := m.organization_id
  19232. if v == nil {
  19233. return
  19234. }
  19235. return *v, true
  19236. }
  19237. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  19238. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  19239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19240. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19241. if !m.op.Is(OpUpdateOne) {
  19242. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19243. }
  19244. if m.id == nil || m.oldValue == nil {
  19245. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19246. }
  19247. oldValue, err := m.oldValue(ctx)
  19248. if err != nil {
  19249. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19250. }
  19251. return oldValue.OrganizationID, nil
  19252. }
  19253. // AddOrganizationID adds u to the "organization_id" field.
  19254. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  19255. if m.addorganization_id != nil {
  19256. *m.addorganization_id += u
  19257. } else {
  19258. m.addorganization_id = &u
  19259. }
  19260. }
  19261. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19262. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  19263. v := m.addorganization_id
  19264. if v == nil {
  19265. return
  19266. }
  19267. return *v, true
  19268. }
  19269. // ClearOrganizationID clears the value of the "organization_id" field.
  19270. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  19271. m.organization_id = nil
  19272. m.addorganization_id = nil
  19273. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  19274. }
  19275. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19276. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  19277. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  19278. return ok
  19279. }
  19280. // ResetOrganizationID resets all changes to the "organization_id" field.
  19281. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  19282. m.organization_id = nil
  19283. m.addorganization_id = nil
  19284. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  19285. }
  19286. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  19287. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  19288. m.contacts = &id
  19289. }
  19290. // ClearContacts clears the "contacts" edge to the Contact entity.
  19291. func (m *LabelRelationshipMutation) ClearContacts() {
  19292. m.clearedcontacts = true
  19293. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  19294. }
  19295. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  19296. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  19297. return m.clearedcontacts
  19298. }
  19299. // ContactsID returns the "contacts" edge ID in the mutation.
  19300. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  19301. if m.contacts != nil {
  19302. return *m.contacts, true
  19303. }
  19304. return
  19305. }
  19306. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  19307. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19308. // ContactsID instead. It exists only for internal usage by the builders.
  19309. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  19310. if id := m.contacts; id != nil {
  19311. ids = append(ids, *id)
  19312. }
  19313. return
  19314. }
  19315. // ResetContacts resets all changes to the "contacts" edge.
  19316. func (m *LabelRelationshipMutation) ResetContacts() {
  19317. m.contacts = nil
  19318. m.clearedcontacts = false
  19319. }
  19320. // SetLabelsID sets the "labels" edge to the Label entity by id.
  19321. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  19322. m.labels = &id
  19323. }
  19324. // ClearLabels clears the "labels" edge to the Label entity.
  19325. func (m *LabelRelationshipMutation) ClearLabels() {
  19326. m.clearedlabels = true
  19327. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  19328. }
  19329. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  19330. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  19331. return m.clearedlabels
  19332. }
  19333. // LabelsID returns the "labels" edge ID in the mutation.
  19334. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  19335. if m.labels != nil {
  19336. return *m.labels, true
  19337. }
  19338. return
  19339. }
  19340. // LabelsIDs returns the "labels" edge IDs in the mutation.
  19341. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19342. // LabelsID instead. It exists only for internal usage by the builders.
  19343. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  19344. if id := m.labels; id != nil {
  19345. ids = append(ids, *id)
  19346. }
  19347. return
  19348. }
  19349. // ResetLabels resets all changes to the "labels" edge.
  19350. func (m *LabelRelationshipMutation) ResetLabels() {
  19351. m.labels = nil
  19352. m.clearedlabels = false
  19353. }
  19354. // Where appends a list predicates to the LabelRelationshipMutation builder.
  19355. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  19356. m.predicates = append(m.predicates, ps...)
  19357. }
  19358. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  19359. // users can use type-assertion to append predicates that do not depend on any generated package.
  19360. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  19361. p := make([]predicate.LabelRelationship, len(ps))
  19362. for i := range ps {
  19363. p[i] = ps[i]
  19364. }
  19365. m.Where(p...)
  19366. }
  19367. // Op returns the operation name.
  19368. func (m *LabelRelationshipMutation) Op() Op {
  19369. return m.op
  19370. }
  19371. // SetOp allows setting the mutation operation.
  19372. func (m *LabelRelationshipMutation) SetOp(op Op) {
  19373. m.op = op
  19374. }
  19375. // Type returns the node type of this mutation (LabelRelationship).
  19376. func (m *LabelRelationshipMutation) Type() string {
  19377. return m.typ
  19378. }
  19379. // Fields returns all fields that were changed during this mutation. Note that in
  19380. // order to get all numeric fields that were incremented/decremented, call
  19381. // AddedFields().
  19382. func (m *LabelRelationshipMutation) Fields() []string {
  19383. fields := make([]string, 0, 6)
  19384. if m.created_at != nil {
  19385. fields = append(fields, labelrelationship.FieldCreatedAt)
  19386. }
  19387. if m.updated_at != nil {
  19388. fields = append(fields, labelrelationship.FieldUpdatedAt)
  19389. }
  19390. if m.status != nil {
  19391. fields = append(fields, labelrelationship.FieldStatus)
  19392. }
  19393. if m.labels != nil {
  19394. fields = append(fields, labelrelationship.FieldLabelID)
  19395. }
  19396. if m.contacts != nil {
  19397. fields = append(fields, labelrelationship.FieldContactID)
  19398. }
  19399. if m.organization_id != nil {
  19400. fields = append(fields, labelrelationship.FieldOrganizationID)
  19401. }
  19402. return fields
  19403. }
  19404. // Field returns the value of a field with the given name. The second boolean
  19405. // return value indicates that this field was not set, or was not defined in the
  19406. // schema.
  19407. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  19408. switch name {
  19409. case labelrelationship.FieldCreatedAt:
  19410. return m.CreatedAt()
  19411. case labelrelationship.FieldUpdatedAt:
  19412. return m.UpdatedAt()
  19413. case labelrelationship.FieldStatus:
  19414. return m.Status()
  19415. case labelrelationship.FieldLabelID:
  19416. return m.LabelID()
  19417. case labelrelationship.FieldContactID:
  19418. return m.ContactID()
  19419. case labelrelationship.FieldOrganizationID:
  19420. return m.OrganizationID()
  19421. }
  19422. return nil, false
  19423. }
  19424. // OldField returns the old value of the field from the database. An error is
  19425. // returned if the mutation operation is not UpdateOne, or the query to the
  19426. // database failed.
  19427. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19428. switch name {
  19429. case labelrelationship.FieldCreatedAt:
  19430. return m.OldCreatedAt(ctx)
  19431. case labelrelationship.FieldUpdatedAt:
  19432. return m.OldUpdatedAt(ctx)
  19433. case labelrelationship.FieldStatus:
  19434. return m.OldStatus(ctx)
  19435. case labelrelationship.FieldLabelID:
  19436. return m.OldLabelID(ctx)
  19437. case labelrelationship.FieldContactID:
  19438. return m.OldContactID(ctx)
  19439. case labelrelationship.FieldOrganizationID:
  19440. return m.OldOrganizationID(ctx)
  19441. }
  19442. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  19443. }
  19444. // SetField sets the value of a field with the given name. It returns an error if
  19445. // the field is not defined in the schema, or if the type mismatched the field
  19446. // type.
  19447. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  19448. switch name {
  19449. case labelrelationship.FieldCreatedAt:
  19450. v, ok := value.(time.Time)
  19451. if !ok {
  19452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19453. }
  19454. m.SetCreatedAt(v)
  19455. return nil
  19456. case labelrelationship.FieldUpdatedAt:
  19457. v, ok := value.(time.Time)
  19458. if !ok {
  19459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19460. }
  19461. m.SetUpdatedAt(v)
  19462. return nil
  19463. case labelrelationship.FieldStatus:
  19464. v, ok := value.(uint8)
  19465. if !ok {
  19466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19467. }
  19468. m.SetStatus(v)
  19469. return nil
  19470. case labelrelationship.FieldLabelID:
  19471. v, ok := value.(uint64)
  19472. if !ok {
  19473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19474. }
  19475. m.SetLabelID(v)
  19476. return nil
  19477. case labelrelationship.FieldContactID:
  19478. v, ok := value.(uint64)
  19479. if !ok {
  19480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19481. }
  19482. m.SetContactID(v)
  19483. return nil
  19484. case labelrelationship.FieldOrganizationID:
  19485. v, ok := value.(uint64)
  19486. if !ok {
  19487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19488. }
  19489. m.SetOrganizationID(v)
  19490. return nil
  19491. }
  19492. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19493. }
  19494. // AddedFields returns all numeric fields that were incremented/decremented during
  19495. // this mutation.
  19496. func (m *LabelRelationshipMutation) AddedFields() []string {
  19497. var fields []string
  19498. if m.addstatus != nil {
  19499. fields = append(fields, labelrelationship.FieldStatus)
  19500. }
  19501. if m.addorganization_id != nil {
  19502. fields = append(fields, labelrelationship.FieldOrganizationID)
  19503. }
  19504. return fields
  19505. }
  19506. // AddedField returns the numeric value that was incremented/decremented on a field
  19507. // with the given name. The second boolean return value indicates that this field
  19508. // was not set, or was not defined in the schema.
  19509. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  19510. switch name {
  19511. case labelrelationship.FieldStatus:
  19512. return m.AddedStatus()
  19513. case labelrelationship.FieldOrganizationID:
  19514. return m.AddedOrganizationID()
  19515. }
  19516. return nil, false
  19517. }
  19518. // AddField adds the value to the field with the given name. It returns an error if
  19519. // the field is not defined in the schema, or if the type mismatched the field
  19520. // type.
  19521. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  19522. switch name {
  19523. case labelrelationship.FieldStatus:
  19524. v, ok := value.(int8)
  19525. if !ok {
  19526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19527. }
  19528. m.AddStatus(v)
  19529. return nil
  19530. case labelrelationship.FieldOrganizationID:
  19531. v, ok := value.(int64)
  19532. if !ok {
  19533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19534. }
  19535. m.AddOrganizationID(v)
  19536. return nil
  19537. }
  19538. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  19539. }
  19540. // ClearedFields returns all nullable fields that were cleared during this
  19541. // mutation.
  19542. func (m *LabelRelationshipMutation) ClearedFields() []string {
  19543. var fields []string
  19544. if m.FieldCleared(labelrelationship.FieldStatus) {
  19545. fields = append(fields, labelrelationship.FieldStatus)
  19546. }
  19547. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  19548. fields = append(fields, labelrelationship.FieldOrganizationID)
  19549. }
  19550. return fields
  19551. }
  19552. // FieldCleared returns a boolean indicating if a field with the given name was
  19553. // cleared in this mutation.
  19554. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  19555. _, ok := m.clearedFields[name]
  19556. return ok
  19557. }
  19558. // ClearField clears the value of the field with the given name. It returns an
  19559. // error if the field is not defined in the schema.
  19560. func (m *LabelRelationshipMutation) ClearField(name string) error {
  19561. switch name {
  19562. case labelrelationship.FieldStatus:
  19563. m.ClearStatus()
  19564. return nil
  19565. case labelrelationship.FieldOrganizationID:
  19566. m.ClearOrganizationID()
  19567. return nil
  19568. }
  19569. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  19570. }
  19571. // ResetField resets all changes in the mutation for the field with the given name.
  19572. // It returns an error if the field is not defined in the schema.
  19573. func (m *LabelRelationshipMutation) ResetField(name string) error {
  19574. switch name {
  19575. case labelrelationship.FieldCreatedAt:
  19576. m.ResetCreatedAt()
  19577. return nil
  19578. case labelrelationship.FieldUpdatedAt:
  19579. m.ResetUpdatedAt()
  19580. return nil
  19581. case labelrelationship.FieldStatus:
  19582. m.ResetStatus()
  19583. return nil
  19584. case labelrelationship.FieldLabelID:
  19585. m.ResetLabelID()
  19586. return nil
  19587. case labelrelationship.FieldContactID:
  19588. m.ResetContactID()
  19589. return nil
  19590. case labelrelationship.FieldOrganizationID:
  19591. m.ResetOrganizationID()
  19592. return nil
  19593. }
  19594. return fmt.Errorf("unknown LabelRelationship field %s", name)
  19595. }
  19596. // AddedEdges returns all edge names that were set/added in this mutation.
  19597. func (m *LabelRelationshipMutation) AddedEdges() []string {
  19598. edges := make([]string, 0, 2)
  19599. if m.contacts != nil {
  19600. edges = append(edges, labelrelationship.EdgeContacts)
  19601. }
  19602. if m.labels != nil {
  19603. edges = append(edges, labelrelationship.EdgeLabels)
  19604. }
  19605. return edges
  19606. }
  19607. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19608. // name in this mutation.
  19609. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  19610. switch name {
  19611. case labelrelationship.EdgeContacts:
  19612. if id := m.contacts; id != nil {
  19613. return []ent.Value{*id}
  19614. }
  19615. case labelrelationship.EdgeLabels:
  19616. if id := m.labels; id != nil {
  19617. return []ent.Value{*id}
  19618. }
  19619. }
  19620. return nil
  19621. }
  19622. // RemovedEdges returns all edge names that were removed in this mutation.
  19623. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  19624. edges := make([]string, 0, 2)
  19625. return edges
  19626. }
  19627. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19628. // the given name in this mutation.
  19629. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  19630. return nil
  19631. }
  19632. // ClearedEdges returns all edge names that were cleared in this mutation.
  19633. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  19634. edges := make([]string, 0, 2)
  19635. if m.clearedcontacts {
  19636. edges = append(edges, labelrelationship.EdgeContacts)
  19637. }
  19638. if m.clearedlabels {
  19639. edges = append(edges, labelrelationship.EdgeLabels)
  19640. }
  19641. return edges
  19642. }
  19643. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19644. // was cleared in this mutation.
  19645. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  19646. switch name {
  19647. case labelrelationship.EdgeContacts:
  19648. return m.clearedcontacts
  19649. case labelrelationship.EdgeLabels:
  19650. return m.clearedlabels
  19651. }
  19652. return false
  19653. }
  19654. // ClearEdge clears the value of the edge with the given name. It returns an error
  19655. // if that edge is not defined in the schema.
  19656. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  19657. switch name {
  19658. case labelrelationship.EdgeContacts:
  19659. m.ClearContacts()
  19660. return nil
  19661. case labelrelationship.EdgeLabels:
  19662. m.ClearLabels()
  19663. return nil
  19664. }
  19665. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  19666. }
  19667. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19668. // It returns an error if the edge is not defined in the schema.
  19669. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  19670. switch name {
  19671. case labelrelationship.EdgeContacts:
  19672. m.ResetContacts()
  19673. return nil
  19674. case labelrelationship.EdgeLabels:
  19675. m.ResetLabels()
  19676. return nil
  19677. }
  19678. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  19679. }
  19680. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  19681. type LabelTaggingMutation struct {
  19682. config
  19683. op Op
  19684. typ string
  19685. id *uint64
  19686. created_at *time.Time
  19687. updated_at *time.Time
  19688. status *uint8
  19689. addstatus *int8
  19690. deleted_at *time.Time
  19691. organization_id *uint64
  19692. addorganization_id *int64
  19693. _type *int
  19694. add_type *int
  19695. conditions *string
  19696. action_label_add *[]uint64
  19697. appendaction_label_add []uint64
  19698. action_label_del *[]uint64
  19699. appendaction_label_del []uint64
  19700. clearedFields map[string]struct{}
  19701. done bool
  19702. oldValue func(context.Context) (*LabelTagging, error)
  19703. predicates []predicate.LabelTagging
  19704. }
  19705. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  19706. // labeltaggingOption allows management of the mutation configuration using functional options.
  19707. type labeltaggingOption func(*LabelTaggingMutation)
  19708. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  19709. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  19710. m := &LabelTaggingMutation{
  19711. config: c,
  19712. op: op,
  19713. typ: TypeLabelTagging,
  19714. clearedFields: make(map[string]struct{}),
  19715. }
  19716. for _, opt := range opts {
  19717. opt(m)
  19718. }
  19719. return m
  19720. }
  19721. // withLabelTaggingID sets the ID field of the mutation.
  19722. func withLabelTaggingID(id uint64) labeltaggingOption {
  19723. return func(m *LabelTaggingMutation) {
  19724. var (
  19725. err error
  19726. once sync.Once
  19727. value *LabelTagging
  19728. )
  19729. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  19730. once.Do(func() {
  19731. if m.done {
  19732. err = errors.New("querying old values post mutation is not allowed")
  19733. } else {
  19734. value, err = m.Client().LabelTagging.Get(ctx, id)
  19735. }
  19736. })
  19737. return value, err
  19738. }
  19739. m.id = &id
  19740. }
  19741. }
  19742. // withLabelTagging sets the old LabelTagging of the mutation.
  19743. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  19744. return func(m *LabelTaggingMutation) {
  19745. m.oldValue = func(context.Context) (*LabelTagging, error) {
  19746. return node, nil
  19747. }
  19748. m.id = &node.ID
  19749. }
  19750. }
  19751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19752. // executed in a transaction (ent.Tx), a transactional client is returned.
  19753. func (m LabelTaggingMutation) Client() *Client {
  19754. client := &Client{config: m.config}
  19755. client.init()
  19756. return client
  19757. }
  19758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19759. // it returns an error otherwise.
  19760. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  19761. if _, ok := m.driver.(*txDriver); !ok {
  19762. return nil, errors.New("ent: mutation is not running in a transaction")
  19763. }
  19764. tx := &Tx{config: m.config}
  19765. tx.init()
  19766. return tx, nil
  19767. }
  19768. // SetID sets the value of the id field. Note that this
  19769. // operation is only accepted on creation of LabelTagging entities.
  19770. func (m *LabelTaggingMutation) SetID(id uint64) {
  19771. m.id = &id
  19772. }
  19773. // ID returns the ID value in the mutation. Note that the ID is only available
  19774. // if it was provided to the builder or after it was returned from the database.
  19775. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  19776. if m.id == nil {
  19777. return
  19778. }
  19779. return *m.id, true
  19780. }
  19781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19782. // That means, if the mutation is applied within a transaction with an isolation level such
  19783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19784. // or updated by the mutation.
  19785. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  19786. switch {
  19787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19788. id, exists := m.ID()
  19789. if exists {
  19790. return []uint64{id}, nil
  19791. }
  19792. fallthrough
  19793. case m.op.Is(OpUpdate | OpDelete):
  19794. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  19795. default:
  19796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19797. }
  19798. }
  19799. // SetCreatedAt sets the "created_at" field.
  19800. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  19801. m.created_at = &t
  19802. }
  19803. // CreatedAt returns the value of the "created_at" field in the mutation.
  19804. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  19805. v := m.created_at
  19806. if v == nil {
  19807. return
  19808. }
  19809. return *v, true
  19810. }
  19811. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  19812. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19814. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19815. if !m.op.Is(OpUpdateOne) {
  19816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19817. }
  19818. if m.id == nil || m.oldValue == nil {
  19819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19820. }
  19821. oldValue, err := m.oldValue(ctx)
  19822. if err != nil {
  19823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19824. }
  19825. return oldValue.CreatedAt, nil
  19826. }
  19827. // ResetCreatedAt resets all changes to the "created_at" field.
  19828. func (m *LabelTaggingMutation) ResetCreatedAt() {
  19829. m.created_at = nil
  19830. }
  19831. // SetUpdatedAt sets the "updated_at" field.
  19832. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  19833. m.updated_at = &t
  19834. }
  19835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19836. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  19837. v := m.updated_at
  19838. if v == nil {
  19839. return
  19840. }
  19841. return *v, true
  19842. }
  19843. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  19844. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19846. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19847. if !m.op.Is(OpUpdateOne) {
  19848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19849. }
  19850. if m.id == nil || m.oldValue == nil {
  19851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19852. }
  19853. oldValue, err := m.oldValue(ctx)
  19854. if err != nil {
  19855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19856. }
  19857. return oldValue.UpdatedAt, nil
  19858. }
  19859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19860. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  19861. m.updated_at = nil
  19862. }
  19863. // SetStatus sets the "status" field.
  19864. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  19865. m.status = &u
  19866. m.addstatus = nil
  19867. }
  19868. // Status returns the value of the "status" field in the mutation.
  19869. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  19870. v := m.status
  19871. if v == nil {
  19872. return
  19873. }
  19874. return *v, true
  19875. }
  19876. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  19877. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19879. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19880. if !m.op.Is(OpUpdateOne) {
  19881. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19882. }
  19883. if m.id == nil || m.oldValue == nil {
  19884. return v, errors.New("OldStatus requires an ID field in the mutation")
  19885. }
  19886. oldValue, err := m.oldValue(ctx)
  19887. if err != nil {
  19888. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19889. }
  19890. return oldValue.Status, nil
  19891. }
  19892. // AddStatus adds u to the "status" field.
  19893. func (m *LabelTaggingMutation) AddStatus(u int8) {
  19894. if m.addstatus != nil {
  19895. *m.addstatus += u
  19896. } else {
  19897. m.addstatus = &u
  19898. }
  19899. }
  19900. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19901. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  19902. v := m.addstatus
  19903. if v == nil {
  19904. return
  19905. }
  19906. return *v, true
  19907. }
  19908. // ClearStatus clears the value of the "status" field.
  19909. func (m *LabelTaggingMutation) ClearStatus() {
  19910. m.status = nil
  19911. m.addstatus = nil
  19912. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  19913. }
  19914. // StatusCleared returns if the "status" field was cleared in this mutation.
  19915. func (m *LabelTaggingMutation) StatusCleared() bool {
  19916. _, ok := m.clearedFields[labeltagging.FieldStatus]
  19917. return ok
  19918. }
  19919. // ResetStatus resets all changes to the "status" field.
  19920. func (m *LabelTaggingMutation) ResetStatus() {
  19921. m.status = nil
  19922. m.addstatus = nil
  19923. delete(m.clearedFields, labeltagging.FieldStatus)
  19924. }
  19925. // SetDeletedAt sets the "deleted_at" field.
  19926. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  19927. m.deleted_at = &t
  19928. }
  19929. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19930. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  19931. v := m.deleted_at
  19932. if v == nil {
  19933. return
  19934. }
  19935. return *v, true
  19936. }
  19937. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  19938. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19940. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19941. if !m.op.Is(OpUpdateOne) {
  19942. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19943. }
  19944. if m.id == nil || m.oldValue == nil {
  19945. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19946. }
  19947. oldValue, err := m.oldValue(ctx)
  19948. if err != nil {
  19949. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19950. }
  19951. return oldValue.DeletedAt, nil
  19952. }
  19953. // ClearDeletedAt clears the value of the "deleted_at" field.
  19954. func (m *LabelTaggingMutation) ClearDeletedAt() {
  19955. m.deleted_at = nil
  19956. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  19957. }
  19958. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19959. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  19960. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  19961. return ok
  19962. }
  19963. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19964. func (m *LabelTaggingMutation) ResetDeletedAt() {
  19965. m.deleted_at = nil
  19966. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  19967. }
  19968. // SetOrganizationID sets the "organization_id" field.
  19969. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  19970. m.organization_id = &u
  19971. m.addorganization_id = nil
  19972. }
  19973. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19974. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  19975. v := m.organization_id
  19976. if v == nil {
  19977. return
  19978. }
  19979. return *v, true
  19980. }
  19981. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  19982. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19984. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19985. if !m.op.Is(OpUpdateOne) {
  19986. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19987. }
  19988. if m.id == nil || m.oldValue == nil {
  19989. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19990. }
  19991. oldValue, err := m.oldValue(ctx)
  19992. if err != nil {
  19993. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19994. }
  19995. return oldValue.OrganizationID, nil
  19996. }
  19997. // AddOrganizationID adds u to the "organization_id" field.
  19998. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  19999. if m.addorganization_id != nil {
  20000. *m.addorganization_id += u
  20001. } else {
  20002. m.addorganization_id = &u
  20003. }
  20004. }
  20005. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20006. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  20007. v := m.addorganization_id
  20008. if v == nil {
  20009. return
  20010. }
  20011. return *v, true
  20012. }
  20013. // ResetOrganizationID resets all changes to the "organization_id" field.
  20014. func (m *LabelTaggingMutation) ResetOrganizationID() {
  20015. m.organization_id = nil
  20016. m.addorganization_id = nil
  20017. }
  20018. // SetType sets the "type" field.
  20019. func (m *LabelTaggingMutation) SetType(i int) {
  20020. m._type = &i
  20021. m.add_type = nil
  20022. }
  20023. // GetType returns the value of the "type" field in the mutation.
  20024. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  20025. v := m._type
  20026. if v == nil {
  20027. return
  20028. }
  20029. return *v, true
  20030. }
  20031. // OldType returns the old "type" field's value of the LabelTagging entity.
  20032. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20034. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  20035. if !m.op.Is(OpUpdateOne) {
  20036. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20037. }
  20038. if m.id == nil || m.oldValue == nil {
  20039. return v, errors.New("OldType requires an ID field in the mutation")
  20040. }
  20041. oldValue, err := m.oldValue(ctx)
  20042. if err != nil {
  20043. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20044. }
  20045. return oldValue.Type, nil
  20046. }
  20047. // AddType adds i to the "type" field.
  20048. func (m *LabelTaggingMutation) AddType(i int) {
  20049. if m.add_type != nil {
  20050. *m.add_type += i
  20051. } else {
  20052. m.add_type = &i
  20053. }
  20054. }
  20055. // AddedType returns the value that was added to the "type" field in this mutation.
  20056. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  20057. v := m.add_type
  20058. if v == nil {
  20059. return
  20060. }
  20061. return *v, true
  20062. }
  20063. // ResetType resets all changes to the "type" field.
  20064. func (m *LabelTaggingMutation) ResetType() {
  20065. m._type = nil
  20066. m.add_type = nil
  20067. }
  20068. // SetConditions sets the "conditions" field.
  20069. func (m *LabelTaggingMutation) SetConditions(s string) {
  20070. m.conditions = &s
  20071. }
  20072. // Conditions returns the value of the "conditions" field in the mutation.
  20073. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  20074. v := m.conditions
  20075. if v == nil {
  20076. return
  20077. }
  20078. return *v, true
  20079. }
  20080. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  20081. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20083. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  20084. if !m.op.Is(OpUpdateOne) {
  20085. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20086. }
  20087. if m.id == nil || m.oldValue == nil {
  20088. return v, errors.New("OldConditions requires an ID field in the mutation")
  20089. }
  20090. oldValue, err := m.oldValue(ctx)
  20091. if err != nil {
  20092. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20093. }
  20094. return oldValue.Conditions, nil
  20095. }
  20096. // ResetConditions resets all changes to the "conditions" field.
  20097. func (m *LabelTaggingMutation) ResetConditions() {
  20098. m.conditions = nil
  20099. }
  20100. // SetActionLabelAdd sets the "action_label_add" field.
  20101. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  20102. m.action_label_add = &u
  20103. m.appendaction_label_add = nil
  20104. }
  20105. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20106. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20107. v := m.action_label_add
  20108. if v == nil {
  20109. return
  20110. }
  20111. return *v, true
  20112. }
  20113. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  20114. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20116. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  20117. if !m.op.Is(OpUpdateOne) {
  20118. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  20119. }
  20120. if m.id == nil || m.oldValue == nil {
  20121. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  20122. }
  20123. oldValue, err := m.oldValue(ctx)
  20124. if err != nil {
  20125. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  20126. }
  20127. return oldValue.ActionLabelAdd, nil
  20128. }
  20129. // AppendActionLabelAdd adds u to the "action_label_add" field.
  20130. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  20131. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  20132. }
  20133. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  20134. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  20135. if len(m.appendaction_label_add) == 0 {
  20136. return nil, false
  20137. }
  20138. return m.appendaction_label_add, true
  20139. }
  20140. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  20141. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  20142. m.action_label_add = nil
  20143. m.appendaction_label_add = nil
  20144. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  20145. }
  20146. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  20147. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  20148. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  20149. return ok
  20150. }
  20151. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  20152. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  20153. m.action_label_add = nil
  20154. m.appendaction_label_add = nil
  20155. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  20156. }
  20157. // SetActionLabelDel sets the "action_label_del" field.
  20158. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  20159. m.action_label_del = &u
  20160. m.appendaction_label_del = nil
  20161. }
  20162. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  20163. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  20164. v := m.action_label_del
  20165. if v == nil {
  20166. return
  20167. }
  20168. return *v, true
  20169. }
  20170. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  20171. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  20172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20173. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  20174. if !m.op.Is(OpUpdateOne) {
  20175. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  20176. }
  20177. if m.id == nil || m.oldValue == nil {
  20178. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  20179. }
  20180. oldValue, err := m.oldValue(ctx)
  20181. if err != nil {
  20182. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  20183. }
  20184. return oldValue.ActionLabelDel, nil
  20185. }
  20186. // AppendActionLabelDel adds u to the "action_label_del" field.
  20187. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  20188. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  20189. }
  20190. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  20191. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  20192. if len(m.appendaction_label_del) == 0 {
  20193. return nil, false
  20194. }
  20195. return m.appendaction_label_del, true
  20196. }
  20197. // ClearActionLabelDel clears the value of the "action_label_del" field.
  20198. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  20199. m.action_label_del = nil
  20200. m.appendaction_label_del = nil
  20201. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  20202. }
  20203. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  20204. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  20205. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  20206. return ok
  20207. }
  20208. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  20209. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  20210. m.action_label_del = nil
  20211. m.appendaction_label_del = nil
  20212. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  20213. }
  20214. // Where appends a list predicates to the LabelTaggingMutation builder.
  20215. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  20216. m.predicates = append(m.predicates, ps...)
  20217. }
  20218. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  20219. // users can use type-assertion to append predicates that do not depend on any generated package.
  20220. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  20221. p := make([]predicate.LabelTagging, len(ps))
  20222. for i := range ps {
  20223. p[i] = ps[i]
  20224. }
  20225. m.Where(p...)
  20226. }
  20227. // Op returns the operation name.
  20228. func (m *LabelTaggingMutation) Op() Op {
  20229. return m.op
  20230. }
  20231. // SetOp allows setting the mutation operation.
  20232. func (m *LabelTaggingMutation) SetOp(op Op) {
  20233. m.op = op
  20234. }
  20235. // Type returns the node type of this mutation (LabelTagging).
  20236. func (m *LabelTaggingMutation) Type() string {
  20237. return m.typ
  20238. }
  20239. // Fields returns all fields that were changed during this mutation. Note that in
  20240. // order to get all numeric fields that were incremented/decremented, call
  20241. // AddedFields().
  20242. func (m *LabelTaggingMutation) Fields() []string {
  20243. fields := make([]string, 0, 9)
  20244. if m.created_at != nil {
  20245. fields = append(fields, labeltagging.FieldCreatedAt)
  20246. }
  20247. if m.updated_at != nil {
  20248. fields = append(fields, labeltagging.FieldUpdatedAt)
  20249. }
  20250. if m.status != nil {
  20251. fields = append(fields, labeltagging.FieldStatus)
  20252. }
  20253. if m.deleted_at != nil {
  20254. fields = append(fields, labeltagging.FieldDeletedAt)
  20255. }
  20256. if m.organization_id != nil {
  20257. fields = append(fields, labeltagging.FieldOrganizationID)
  20258. }
  20259. if m._type != nil {
  20260. fields = append(fields, labeltagging.FieldType)
  20261. }
  20262. if m.conditions != nil {
  20263. fields = append(fields, labeltagging.FieldConditions)
  20264. }
  20265. if m.action_label_add != nil {
  20266. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20267. }
  20268. if m.action_label_del != nil {
  20269. fields = append(fields, labeltagging.FieldActionLabelDel)
  20270. }
  20271. return fields
  20272. }
  20273. // Field returns the value of a field with the given name. The second boolean
  20274. // return value indicates that this field was not set, or was not defined in the
  20275. // schema.
  20276. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  20277. switch name {
  20278. case labeltagging.FieldCreatedAt:
  20279. return m.CreatedAt()
  20280. case labeltagging.FieldUpdatedAt:
  20281. return m.UpdatedAt()
  20282. case labeltagging.FieldStatus:
  20283. return m.Status()
  20284. case labeltagging.FieldDeletedAt:
  20285. return m.DeletedAt()
  20286. case labeltagging.FieldOrganizationID:
  20287. return m.OrganizationID()
  20288. case labeltagging.FieldType:
  20289. return m.GetType()
  20290. case labeltagging.FieldConditions:
  20291. return m.Conditions()
  20292. case labeltagging.FieldActionLabelAdd:
  20293. return m.ActionLabelAdd()
  20294. case labeltagging.FieldActionLabelDel:
  20295. return m.ActionLabelDel()
  20296. }
  20297. return nil, false
  20298. }
  20299. // OldField returns the old value of the field from the database. An error is
  20300. // returned if the mutation operation is not UpdateOne, or the query to the
  20301. // database failed.
  20302. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20303. switch name {
  20304. case labeltagging.FieldCreatedAt:
  20305. return m.OldCreatedAt(ctx)
  20306. case labeltagging.FieldUpdatedAt:
  20307. return m.OldUpdatedAt(ctx)
  20308. case labeltagging.FieldStatus:
  20309. return m.OldStatus(ctx)
  20310. case labeltagging.FieldDeletedAt:
  20311. return m.OldDeletedAt(ctx)
  20312. case labeltagging.FieldOrganizationID:
  20313. return m.OldOrganizationID(ctx)
  20314. case labeltagging.FieldType:
  20315. return m.OldType(ctx)
  20316. case labeltagging.FieldConditions:
  20317. return m.OldConditions(ctx)
  20318. case labeltagging.FieldActionLabelAdd:
  20319. return m.OldActionLabelAdd(ctx)
  20320. case labeltagging.FieldActionLabelDel:
  20321. return m.OldActionLabelDel(ctx)
  20322. }
  20323. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  20324. }
  20325. // SetField sets the value of a field with the given name. It returns an error if
  20326. // the field is not defined in the schema, or if the type mismatched the field
  20327. // type.
  20328. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  20329. switch name {
  20330. case labeltagging.FieldCreatedAt:
  20331. v, ok := value.(time.Time)
  20332. if !ok {
  20333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20334. }
  20335. m.SetCreatedAt(v)
  20336. return nil
  20337. case labeltagging.FieldUpdatedAt:
  20338. v, ok := value.(time.Time)
  20339. if !ok {
  20340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20341. }
  20342. m.SetUpdatedAt(v)
  20343. return nil
  20344. case labeltagging.FieldStatus:
  20345. v, ok := value.(uint8)
  20346. if !ok {
  20347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20348. }
  20349. m.SetStatus(v)
  20350. return nil
  20351. case labeltagging.FieldDeletedAt:
  20352. v, ok := value.(time.Time)
  20353. if !ok {
  20354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20355. }
  20356. m.SetDeletedAt(v)
  20357. return nil
  20358. case labeltagging.FieldOrganizationID:
  20359. v, ok := value.(uint64)
  20360. if !ok {
  20361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20362. }
  20363. m.SetOrganizationID(v)
  20364. return nil
  20365. case labeltagging.FieldType:
  20366. v, ok := value.(int)
  20367. if !ok {
  20368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20369. }
  20370. m.SetType(v)
  20371. return nil
  20372. case labeltagging.FieldConditions:
  20373. v, ok := value.(string)
  20374. if !ok {
  20375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20376. }
  20377. m.SetConditions(v)
  20378. return nil
  20379. case labeltagging.FieldActionLabelAdd:
  20380. v, ok := value.([]uint64)
  20381. if !ok {
  20382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20383. }
  20384. m.SetActionLabelAdd(v)
  20385. return nil
  20386. case labeltagging.FieldActionLabelDel:
  20387. v, ok := value.([]uint64)
  20388. if !ok {
  20389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20390. }
  20391. m.SetActionLabelDel(v)
  20392. return nil
  20393. }
  20394. return fmt.Errorf("unknown LabelTagging field %s", name)
  20395. }
  20396. // AddedFields returns all numeric fields that were incremented/decremented during
  20397. // this mutation.
  20398. func (m *LabelTaggingMutation) AddedFields() []string {
  20399. var fields []string
  20400. if m.addstatus != nil {
  20401. fields = append(fields, labeltagging.FieldStatus)
  20402. }
  20403. if m.addorganization_id != nil {
  20404. fields = append(fields, labeltagging.FieldOrganizationID)
  20405. }
  20406. if m.add_type != nil {
  20407. fields = append(fields, labeltagging.FieldType)
  20408. }
  20409. return fields
  20410. }
  20411. // AddedField returns the numeric value that was incremented/decremented on a field
  20412. // with the given name. The second boolean return value indicates that this field
  20413. // was not set, or was not defined in the schema.
  20414. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  20415. switch name {
  20416. case labeltagging.FieldStatus:
  20417. return m.AddedStatus()
  20418. case labeltagging.FieldOrganizationID:
  20419. return m.AddedOrganizationID()
  20420. case labeltagging.FieldType:
  20421. return m.AddedType()
  20422. }
  20423. return nil, false
  20424. }
  20425. // AddField adds the value to the field with the given name. It returns an error if
  20426. // the field is not defined in the schema, or if the type mismatched the field
  20427. // type.
  20428. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  20429. switch name {
  20430. case labeltagging.FieldStatus:
  20431. v, ok := value.(int8)
  20432. if !ok {
  20433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20434. }
  20435. m.AddStatus(v)
  20436. return nil
  20437. case labeltagging.FieldOrganizationID:
  20438. v, ok := value.(int64)
  20439. if !ok {
  20440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20441. }
  20442. m.AddOrganizationID(v)
  20443. return nil
  20444. case labeltagging.FieldType:
  20445. v, ok := value.(int)
  20446. if !ok {
  20447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20448. }
  20449. m.AddType(v)
  20450. return nil
  20451. }
  20452. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  20453. }
  20454. // ClearedFields returns all nullable fields that were cleared during this
  20455. // mutation.
  20456. func (m *LabelTaggingMutation) ClearedFields() []string {
  20457. var fields []string
  20458. if m.FieldCleared(labeltagging.FieldStatus) {
  20459. fields = append(fields, labeltagging.FieldStatus)
  20460. }
  20461. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  20462. fields = append(fields, labeltagging.FieldDeletedAt)
  20463. }
  20464. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  20465. fields = append(fields, labeltagging.FieldActionLabelAdd)
  20466. }
  20467. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  20468. fields = append(fields, labeltagging.FieldActionLabelDel)
  20469. }
  20470. return fields
  20471. }
  20472. // FieldCleared returns a boolean indicating if a field with the given name was
  20473. // cleared in this mutation.
  20474. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  20475. _, ok := m.clearedFields[name]
  20476. return ok
  20477. }
  20478. // ClearField clears the value of the field with the given name. It returns an
  20479. // error if the field is not defined in the schema.
  20480. func (m *LabelTaggingMutation) ClearField(name string) error {
  20481. switch name {
  20482. case labeltagging.FieldStatus:
  20483. m.ClearStatus()
  20484. return nil
  20485. case labeltagging.FieldDeletedAt:
  20486. m.ClearDeletedAt()
  20487. return nil
  20488. case labeltagging.FieldActionLabelAdd:
  20489. m.ClearActionLabelAdd()
  20490. return nil
  20491. case labeltagging.FieldActionLabelDel:
  20492. m.ClearActionLabelDel()
  20493. return nil
  20494. }
  20495. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  20496. }
  20497. // ResetField resets all changes in the mutation for the field with the given name.
  20498. // It returns an error if the field is not defined in the schema.
  20499. func (m *LabelTaggingMutation) ResetField(name string) error {
  20500. switch name {
  20501. case labeltagging.FieldCreatedAt:
  20502. m.ResetCreatedAt()
  20503. return nil
  20504. case labeltagging.FieldUpdatedAt:
  20505. m.ResetUpdatedAt()
  20506. return nil
  20507. case labeltagging.FieldStatus:
  20508. m.ResetStatus()
  20509. return nil
  20510. case labeltagging.FieldDeletedAt:
  20511. m.ResetDeletedAt()
  20512. return nil
  20513. case labeltagging.FieldOrganizationID:
  20514. m.ResetOrganizationID()
  20515. return nil
  20516. case labeltagging.FieldType:
  20517. m.ResetType()
  20518. return nil
  20519. case labeltagging.FieldConditions:
  20520. m.ResetConditions()
  20521. return nil
  20522. case labeltagging.FieldActionLabelAdd:
  20523. m.ResetActionLabelAdd()
  20524. return nil
  20525. case labeltagging.FieldActionLabelDel:
  20526. m.ResetActionLabelDel()
  20527. return nil
  20528. }
  20529. return fmt.Errorf("unknown LabelTagging field %s", name)
  20530. }
  20531. // AddedEdges returns all edge names that were set/added in this mutation.
  20532. func (m *LabelTaggingMutation) AddedEdges() []string {
  20533. edges := make([]string, 0, 0)
  20534. return edges
  20535. }
  20536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20537. // name in this mutation.
  20538. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  20539. return nil
  20540. }
  20541. // RemovedEdges returns all edge names that were removed in this mutation.
  20542. func (m *LabelTaggingMutation) RemovedEdges() []string {
  20543. edges := make([]string, 0, 0)
  20544. return edges
  20545. }
  20546. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20547. // the given name in this mutation.
  20548. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  20549. return nil
  20550. }
  20551. // ClearedEdges returns all edge names that were cleared in this mutation.
  20552. func (m *LabelTaggingMutation) ClearedEdges() []string {
  20553. edges := make([]string, 0, 0)
  20554. return edges
  20555. }
  20556. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20557. // was cleared in this mutation.
  20558. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  20559. return false
  20560. }
  20561. // ClearEdge clears the value of the edge with the given name. It returns an error
  20562. // if that edge is not defined in the schema.
  20563. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  20564. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  20565. }
  20566. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20567. // It returns an error if the edge is not defined in the schema.
  20568. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  20569. return fmt.Errorf("unknown LabelTagging edge %s", name)
  20570. }
  20571. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  20572. type MessageMutation struct {
  20573. config
  20574. op Op
  20575. typ string
  20576. id *int
  20577. wx_wxid *string
  20578. wxid *string
  20579. content *string
  20580. clearedFields map[string]struct{}
  20581. done bool
  20582. oldValue func(context.Context) (*Message, error)
  20583. predicates []predicate.Message
  20584. }
  20585. var _ ent.Mutation = (*MessageMutation)(nil)
  20586. // messageOption allows management of the mutation configuration using functional options.
  20587. type messageOption func(*MessageMutation)
  20588. // newMessageMutation creates new mutation for the Message entity.
  20589. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  20590. m := &MessageMutation{
  20591. config: c,
  20592. op: op,
  20593. typ: TypeMessage,
  20594. clearedFields: make(map[string]struct{}),
  20595. }
  20596. for _, opt := range opts {
  20597. opt(m)
  20598. }
  20599. return m
  20600. }
  20601. // withMessageID sets the ID field of the mutation.
  20602. func withMessageID(id int) messageOption {
  20603. return func(m *MessageMutation) {
  20604. var (
  20605. err error
  20606. once sync.Once
  20607. value *Message
  20608. )
  20609. m.oldValue = func(ctx context.Context) (*Message, error) {
  20610. once.Do(func() {
  20611. if m.done {
  20612. err = errors.New("querying old values post mutation is not allowed")
  20613. } else {
  20614. value, err = m.Client().Message.Get(ctx, id)
  20615. }
  20616. })
  20617. return value, err
  20618. }
  20619. m.id = &id
  20620. }
  20621. }
  20622. // withMessage sets the old Message of the mutation.
  20623. func withMessage(node *Message) messageOption {
  20624. return func(m *MessageMutation) {
  20625. m.oldValue = func(context.Context) (*Message, error) {
  20626. return node, nil
  20627. }
  20628. m.id = &node.ID
  20629. }
  20630. }
  20631. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20632. // executed in a transaction (ent.Tx), a transactional client is returned.
  20633. func (m MessageMutation) Client() *Client {
  20634. client := &Client{config: m.config}
  20635. client.init()
  20636. return client
  20637. }
  20638. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20639. // it returns an error otherwise.
  20640. func (m MessageMutation) Tx() (*Tx, error) {
  20641. if _, ok := m.driver.(*txDriver); !ok {
  20642. return nil, errors.New("ent: mutation is not running in a transaction")
  20643. }
  20644. tx := &Tx{config: m.config}
  20645. tx.init()
  20646. return tx, nil
  20647. }
  20648. // ID returns the ID value in the mutation. Note that the ID is only available
  20649. // if it was provided to the builder or after it was returned from the database.
  20650. func (m *MessageMutation) ID() (id int, exists bool) {
  20651. if m.id == nil {
  20652. return
  20653. }
  20654. return *m.id, true
  20655. }
  20656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20657. // That means, if the mutation is applied within a transaction with an isolation level such
  20658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20659. // or updated by the mutation.
  20660. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  20661. switch {
  20662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20663. id, exists := m.ID()
  20664. if exists {
  20665. return []int{id}, nil
  20666. }
  20667. fallthrough
  20668. case m.op.Is(OpUpdate | OpDelete):
  20669. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  20670. default:
  20671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20672. }
  20673. }
  20674. // SetWxWxid sets the "wx_wxid" field.
  20675. func (m *MessageMutation) SetWxWxid(s string) {
  20676. m.wx_wxid = &s
  20677. }
  20678. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  20679. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  20680. v := m.wx_wxid
  20681. if v == nil {
  20682. return
  20683. }
  20684. return *v, true
  20685. }
  20686. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  20687. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20689. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  20690. if !m.op.Is(OpUpdateOne) {
  20691. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  20692. }
  20693. if m.id == nil || m.oldValue == nil {
  20694. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  20695. }
  20696. oldValue, err := m.oldValue(ctx)
  20697. if err != nil {
  20698. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  20699. }
  20700. return oldValue.WxWxid, nil
  20701. }
  20702. // ClearWxWxid clears the value of the "wx_wxid" field.
  20703. func (m *MessageMutation) ClearWxWxid() {
  20704. m.wx_wxid = nil
  20705. m.clearedFields[message.FieldWxWxid] = struct{}{}
  20706. }
  20707. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  20708. func (m *MessageMutation) WxWxidCleared() bool {
  20709. _, ok := m.clearedFields[message.FieldWxWxid]
  20710. return ok
  20711. }
  20712. // ResetWxWxid resets all changes to the "wx_wxid" field.
  20713. func (m *MessageMutation) ResetWxWxid() {
  20714. m.wx_wxid = nil
  20715. delete(m.clearedFields, message.FieldWxWxid)
  20716. }
  20717. // SetWxid sets the "wxid" field.
  20718. func (m *MessageMutation) SetWxid(s string) {
  20719. m.wxid = &s
  20720. }
  20721. // Wxid returns the value of the "wxid" field in the mutation.
  20722. func (m *MessageMutation) Wxid() (r string, exists bool) {
  20723. v := m.wxid
  20724. if v == nil {
  20725. return
  20726. }
  20727. return *v, true
  20728. }
  20729. // OldWxid returns the old "wxid" field's value of the Message entity.
  20730. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20732. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  20733. if !m.op.Is(OpUpdateOne) {
  20734. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  20735. }
  20736. if m.id == nil || m.oldValue == nil {
  20737. return v, errors.New("OldWxid requires an ID field in the mutation")
  20738. }
  20739. oldValue, err := m.oldValue(ctx)
  20740. if err != nil {
  20741. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  20742. }
  20743. return oldValue.Wxid, nil
  20744. }
  20745. // ResetWxid resets all changes to the "wxid" field.
  20746. func (m *MessageMutation) ResetWxid() {
  20747. m.wxid = nil
  20748. }
  20749. // SetContent sets the "content" field.
  20750. func (m *MessageMutation) SetContent(s string) {
  20751. m.content = &s
  20752. }
  20753. // Content returns the value of the "content" field in the mutation.
  20754. func (m *MessageMutation) Content() (r string, exists bool) {
  20755. v := m.content
  20756. if v == nil {
  20757. return
  20758. }
  20759. return *v, true
  20760. }
  20761. // OldContent returns the old "content" field's value of the Message entity.
  20762. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  20763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20764. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  20765. if !m.op.Is(OpUpdateOne) {
  20766. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20767. }
  20768. if m.id == nil || m.oldValue == nil {
  20769. return v, errors.New("OldContent requires an ID field in the mutation")
  20770. }
  20771. oldValue, err := m.oldValue(ctx)
  20772. if err != nil {
  20773. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20774. }
  20775. return oldValue.Content, nil
  20776. }
  20777. // ResetContent resets all changes to the "content" field.
  20778. func (m *MessageMutation) ResetContent() {
  20779. m.content = nil
  20780. }
  20781. // Where appends a list predicates to the MessageMutation builder.
  20782. func (m *MessageMutation) Where(ps ...predicate.Message) {
  20783. m.predicates = append(m.predicates, ps...)
  20784. }
  20785. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  20786. // users can use type-assertion to append predicates that do not depend on any generated package.
  20787. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  20788. p := make([]predicate.Message, len(ps))
  20789. for i := range ps {
  20790. p[i] = ps[i]
  20791. }
  20792. m.Where(p...)
  20793. }
  20794. // Op returns the operation name.
  20795. func (m *MessageMutation) Op() Op {
  20796. return m.op
  20797. }
  20798. // SetOp allows setting the mutation operation.
  20799. func (m *MessageMutation) SetOp(op Op) {
  20800. m.op = op
  20801. }
  20802. // Type returns the node type of this mutation (Message).
  20803. func (m *MessageMutation) Type() string {
  20804. return m.typ
  20805. }
  20806. // Fields returns all fields that were changed during this mutation. Note that in
  20807. // order to get all numeric fields that were incremented/decremented, call
  20808. // AddedFields().
  20809. func (m *MessageMutation) Fields() []string {
  20810. fields := make([]string, 0, 3)
  20811. if m.wx_wxid != nil {
  20812. fields = append(fields, message.FieldWxWxid)
  20813. }
  20814. if m.wxid != nil {
  20815. fields = append(fields, message.FieldWxid)
  20816. }
  20817. if m.content != nil {
  20818. fields = append(fields, message.FieldContent)
  20819. }
  20820. return fields
  20821. }
  20822. // Field returns the value of a field with the given name. The second boolean
  20823. // return value indicates that this field was not set, or was not defined in the
  20824. // schema.
  20825. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  20826. switch name {
  20827. case message.FieldWxWxid:
  20828. return m.WxWxid()
  20829. case message.FieldWxid:
  20830. return m.Wxid()
  20831. case message.FieldContent:
  20832. return m.Content()
  20833. }
  20834. return nil, false
  20835. }
  20836. // OldField returns the old value of the field from the database. An error is
  20837. // returned if the mutation operation is not UpdateOne, or the query to the
  20838. // database failed.
  20839. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20840. switch name {
  20841. case message.FieldWxWxid:
  20842. return m.OldWxWxid(ctx)
  20843. case message.FieldWxid:
  20844. return m.OldWxid(ctx)
  20845. case message.FieldContent:
  20846. return m.OldContent(ctx)
  20847. }
  20848. return nil, fmt.Errorf("unknown Message field %s", name)
  20849. }
  20850. // SetField sets the value of a field with the given name. It returns an error if
  20851. // the field is not defined in the schema, or if the type mismatched the field
  20852. // type.
  20853. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  20854. switch name {
  20855. case message.FieldWxWxid:
  20856. v, ok := value.(string)
  20857. if !ok {
  20858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20859. }
  20860. m.SetWxWxid(v)
  20861. return nil
  20862. case message.FieldWxid:
  20863. v, ok := value.(string)
  20864. if !ok {
  20865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20866. }
  20867. m.SetWxid(v)
  20868. return nil
  20869. case message.FieldContent:
  20870. v, ok := value.(string)
  20871. if !ok {
  20872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20873. }
  20874. m.SetContent(v)
  20875. return nil
  20876. }
  20877. return fmt.Errorf("unknown Message field %s", name)
  20878. }
  20879. // AddedFields returns all numeric fields that were incremented/decremented during
  20880. // this mutation.
  20881. func (m *MessageMutation) AddedFields() []string {
  20882. return nil
  20883. }
  20884. // AddedField returns the numeric value that was incremented/decremented on a field
  20885. // with the given name. The second boolean return value indicates that this field
  20886. // was not set, or was not defined in the schema.
  20887. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  20888. return nil, false
  20889. }
  20890. // AddField adds the value to the field with the given name. It returns an error if
  20891. // the field is not defined in the schema, or if the type mismatched the field
  20892. // type.
  20893. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  20894. switch name {
  20895. }
  20896. return fmt.Errorf("unknown Message numeric field %s", name)
  20897. }
  20898. // ClearedFields returns all nullable fields that were cleared during this
  20899. // mutation.
  20900. func (m *MessageMutation) ClearedFields() []string {
  20901. var fields []string
  20902. if m.FieldCleared(message.FieldWxWxid) {
  20903. fields = append(fields, message.FieldWxWxid)
  20904. }
  20905. return fields
  20906. }
  20907. // FieldCleared returns a boolean indicating if a field with the given name was
  20908. // cleared in this mutation.
  20909. func (m *MessageMutation) FieldCleared(name string) bool {
  20910. _, ok := m.clearedFields[name]
  20911. return ok
  20912. }
  20913. // ClearField clears the value of the field with the given name. It returns an
  20914. // error if the field is not defined in the schema.
  20915. func (m *MessageMutation) ClearField(name string) error {
  20916. switch name {
  20917. case message.FieldWxWxid:
  20918. m.ClearWxWxid()
  20919. return nil
  20920. }
  20921. return fmt.Errorf("unknown Message nullable field %s", name)
  20922. }
  20923. // ResetField resets all changes in the mutation for the field with the given name.
  20924. // It returns an error if the field is not defined in the schema.
  20925. func (m *MessageMutation) ResetField(name string) error {
  20926. switch name {
  20927. case message.FieldWxWxid:
  20928. m.ResetWxWxid()
  20929. return nil
  20930. case message.FieldWxid:
  20931. m.ResetWxid()
  20932. return nil
  20933. case message.FieldContent:
  20934. m.ResetContent()
  20935. return nil
  20936. }
  20937. return fmt.Errorf("unknown Message field %s", name)
  20938. }
  20939. // AddedEdges returns all edge names that were set/added in this mutation.
  20940. func (m *MessageMutation) AddedEdges() []string {
  20941. edges := make([]string, 0, 0)
  20942. return edges
  20943. }
  20944. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20945. // name in this mutation.
  20946. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  20947. return nil
  20948. }
  20949. // RemovedEdges returns all edge names that were removed in this mutation.
  20950. func (m *MessageMutation) RemovedEdges() []string {
  20951. edges := make([]string, 0, 0)
  20952. return edges
  20953. }
  20954. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20955. // the given name in this mutation.
  20956. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  20957. return nil
  20958. }
  20959. // ClearedEdges returns all edge names that were cleared in this mutation.
  20960. func (m *MessageMutation) ClearedEdges() []string {
  20961. edges := make([]string, 0, 0)
  20962. return edges
  20963. }
  20964. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20965. // was cleared in this mutation.
  20966. func (m *MessageMutation) EdgeCleared(name string) bool {
  20967. return false
  20968. }
  20969. // ClearEdge clears the value of the edge with the given name. It returns an error
  20970. // if that edge is not defined in the schema.
  20971. func (m *MessageMutation) ClearEdge(name string) error {
  20972. return fmt.Errorf("unknown Message unique edge %s", name)
  20973. }
  20974. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20975. // It returns an error if the edge is not defined in the schema.
  20976. func (m *MessageMutation) ResetEdge(name string) error {
  20977. return fmt.Errorf("unknown Message edge %s", name)
  20978. }
  20979. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  20980. type MessageRecordsMutation struct {
  20981. config
  20982. op Op
  20983. typ string
  20984. id *uint64
  20985. created_at *time.Time
  20986. updated_at *time.Time
  20987. status *uint8
  20988. addstatus *int8
  20989. bot_wxid *string
  20990. contact_type *int
  20991. addcontact_type *int
  20992. contact_wxid *string
  20993. content_type *int
  20994. addcontent_type *int
  20995. content *string
  20996. meta *custom_types.Meta
  20997. error_detail *string
  20998. send_time *time.Time
  20999. source_type *int
  21000. addsource_type *int
  21001. organization_id *uint64
  21002. addorganization_id *int64
  21003. clearedFields map[string]struct{}
  21004. sop_stage *uint64
  21005. clearedsop_stage bool
  21006. sop_node *uint64
  21007. clearedsop_node bool
  21008. message_contact *uint64
  21009. clearedmessage_contact bool
  21010. done bool
  21011. oldValue func(context.Context) (*MessageRecords, error)
  21012. predicates []predicate.MessageRecords
  21013. }
  21014. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  21015. // messagerecordsOption allows management of the mutation configuration using functional options.
  21016. type messagerecordsOption func(*MessageRecordsMutation)
  21017. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  21018. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  21019. m := &MessageRecordsMutation{
  21020. config: c,
  21021. op: op,
  21022. typ: TypeMessageRecords,
  21023. clearedFields: make(map[string]struct{}),
  21024. }
  21025. for _, opt := range opts {
  21026. opt(m)
  21027. }
  21028. return m
  21029. }
  21030. // withMessageRecordsID sets the ID field of the mutation.
  21031. func withMessageRecordsID(id uint64) messagerecordsOption {
  21032. return func(m *MessageRecordsMutation) {
  21033. var (
  21034. err error
  21035. once sync.Once
  21036. value *MessageRecords
  21037. )
  21038. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  21039. once.Do(func() {
  21040. if m.done {
  21041. err = errors.New("querying old values post mutation is not allowed")
  21042. } else {
  21043. value, err = m.Client().MessageRecords.Get(ctx, id)
  21044. }
  21045. })
  21046. return value, err
  21047. }
  21048. m.id = &id
  21049. }
  21050. }
  21051. // withMessageRecords sets the old MessageRecords of the mutation.
  21052. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  21053. return func(m *MessageRecordsMutation) {
  21054. m.oldValue = func(context.Context) (*MessageRecords, error) {
  21055. return node, nil
  21056. }
  21057. m.id = &node.ID
  21058. }
  21059. }
  21060. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21061. // executed in a transaction (ent.Tx), a transactional client is returned.
  21062. func (m MessageRecordsMutation) Client() *Client {
  21063. client := &Client{config: m.config}
  21064. client.init()
  21065. return client
  21066. }
  21067. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21068. // it returns an error otherwise.
  21069. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  21070. if _, ok := m.driver.(*txDriver); !ok {
  21071. return nil, errors.New("ent: mutation is not running in a transaction")
  21072. }
  21073. tx := &Tx{config: m.config}
  21074. tx.init()
  21075. return tx, nil
  21076. }
  21077. // SetID sets the value of the id field. Note that this
  21078. // operation is only accepted on creation of MessageRecords entities.
  21079. func (m *MessageRecordsMutation) SetID(id uint64) {
  21080. m.id = &id
  21081. }
  21082. // ID returns the ID value in the mutation. Note that the ID is only available
  21083. // if it was provided to the builder or after it was returned from the database.
  21084. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  21085. if m.id == nil {
  21086. return
  21087. }
  21088. return *m.id, true
  21089. }
  21090. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21091. // That means, if the mutation is applied within a transaction with an isolation level such
  21092. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21093. // or updated by the mutation.
  21094. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  21095. switch {
  21096. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21097. id, exists := m.ID()
  21098. if exists {
  21099. return []uint64{id}, nil
  21100. }
  21101. fallthrough
  21102. case m.op.Is(OpUpdate | OpDelete):
  21103. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  21104. default:
  21105. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21106. }
  21107. }
  21108. // SetCreatedAt sets the "created_at" field.
  21109. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  21110. m.created_at = &t
  21111. }
  21112. // CreatedAt returns the value of the "created_at" field in the mutation.
  21113. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  21114. v := m.created_at
  21115. if v == nil {
  21116. return
  21117. }
  21118. return *v, true
  21119. }
  21120. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  21121. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21123. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21124. if !m.op.Is(OpUpdateOne) {
  21125. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21126. }
  21127. if m.id == nil || m.oldValue == nil {
  21128. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21129. }
  21130. oldValue, err := m.oldValue(ctx)
  21131. if err != nil {
  21132. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21133. }
  21134. return oldValue.CreatedAt, nil
  21135. }
  21136. // ResetCreatedAt resets all changes to the "created_at" field.
  21137. func (m *MessageRecordsMutation) ResetCreatedAt() {
  21138. m.created_at = nil
  21139. }
  21140. // SetUpdatedAt sets the "updated_at" field.
  21141. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  21142. m.updated_at = &t
  21143. }
  21144. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21145. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  21146. v := m.updated_at
  21147. if v == nil {
  21148. return
  21149. }
  21150. return *v, true
  21151. }
  21152. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  21153. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21155. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21156. if !m.op.Is(OpUpdateOne) {
  21157. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21158. }
  21159. if m.id == nil || m.oldValue == nil {
  21160. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21161. }
  21162. oldValue, err := m.oldValue(ctx)
  21163. if err != nil {
  21164. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21165. }
  21166. return oldValue.UpdatedAt, nil
  21167. }
  21168. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21169. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  21170. m.updated_at = nil
  21171. }
  21172. // SetStatus sets the "status" field.
  21173. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  21174. m.status = &u
  21175. m.addstatus = nil
  21176. }
  21177. // Status returns the value of the "status" field in the mutation.
  21178. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  21179. v := m.status
  21180. if v == nil {
  21181. return
  21182. }
  21183. return *v, true
  21184. }
  21185. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  21186. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21188. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21189. if !m.op.Is(OpUpdateOne) {
  21190. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21191. }
  21192. if m.id == nil || m.oldValue == nil {
  21193. return v, errors.New("OldStatus requires an ID field in the mutation")
  21194. }
  21195. oldValue, err := m.oldValue(ctx)
  21196. if err != nil {
  21197. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21198. }
  21199. return oldValue.Status, nil
  21200. }
  21201. // AddStatus adds u to the "status" field.
  21202. func (m *MessageRecordsMutation) AddStatus(u int8) {
  21203. if m.addstatus != nil {
  21204. *m.addstatus += u
  21205. } else {
  21206. m.addstatus = &u
  21207. }
  21208. }
  21209. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21210. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  21211. v := m.addstatus
  21212. if v == nil {
  21213. return
  21214. }
  21215. return *v, true
  21216. }
  21217. // ClearStatus clears the value of the "status" field.
  21218. func (m *MessageRecordsMutation) ClearStatus() {
  21219. m.status = nil
  21220. m.addstatus = nil
  21221. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  21222. }
  21223. // StatusCleared returns if the "status" field was cleared in this mutation.
  21224. func (m *MessageRecordsMutation) StatusCleared() bool {
  21225. _, ok := m.clearedFields[messagerecords.FieldStatus]
  21226. return ok
  21227. }
  21228. // ResetStatus resets all changes to the "status" field.
  21229. func (m *MessageRecordsMutation) ResetStatus() {
  21230. m.status = nil
  21231. m.addstatus = nil
  21232. delete(m.clearedFields, messagerecords.FieldStatus)
  21233. }
  21234. // SetBotWxid sets the "bot_wxid" field.
  21235. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  21236. m.bot_wxid = &s
  21237. }
  21238. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  21239. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  21240. v := m.bot_wxid
  21241. if v == nil {
  21242. return
  21243. }
  21244. return *v, true
  21245. }
  21246. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  21247. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21249. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  21250. if !m.op.Is(OpUpdateOne) {
  21251. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  21252. }
  21253. if m.id == nil || m.oldValue == nil {
  21254. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  21255. }
  21256. oldValue, err := m.oldValue(ctx)
  21257. if err != nil {
  21258. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  21259. }
  21260. return oldValue.BotWxid, nil
  21261. }
  21262. // ResetBotWxid resets all changes to the "bot_wxid" field.
  21263. func (m *MessageRecordsMutation) ResetBotWxid() {
  21264. m.bot_wxid = nil
  21265. }
  21266. // SetContactID sets the "contact_id" field.
  21267. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  21268. m.message_contact = &u
  21269. }
  21270. // ContactID returns the value of the "contact_id" field in the mutation.
  21271. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  21272. v := m.message_contact
  21273. if v == nil {
  21274. return
  21275. }
  21276. return *v, true
  21277. }
  21278. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  21279. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21281. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  21282. if !m.op.Is(OpUpdateOne) {
  21283. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  21284. }
  21285. if m.id == nil || m.oldValue == nil {
  21286. return v, errors.New("OldContactID requires an ID field in the mutation")
  21287. }
  21288. oldValue, err := m.oldValue(ctx)
  21289. if err != nil {
  21290. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  21291. }
  21292. return oldValue.ContactID, nil
  21293. }
  21294. // ClearContactID clears the value of the "contact_id" field.
  21295. func (m *MessageRecordsMutation) ClearContactID() {
  21296. m.message_contact = nil
  21297. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21298. }
  21299. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  21300. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  21301. _, ok := m.clearedFields[messagerecords.FieldContactID]
  21302. return ok
  21303. }
  21304. // ResetContactID resets all changes to the "contact_id" field.
  21305. func (m *MessageRecordsMutation) ResetContactID() {
  21306. m.message_contact = nil
  21307. delete(m.clearedFields, messagerecords.FieldContactID)
  21308. }
  21309. // SetContactType sets the "contact_type" field.
  21310. func (m *MessageRecordsMutation) SetContactType(i int) {
  21311. m.contact_type = &i
  21312. m.addcontact_type = nil
  21313. }
  21314. // ContactType returns the value of the "contact_type" field in the mutation.
  21315. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  21316. v := m.contact_type
  21317. if v == nil {
  21318. return
  21319. }
  21320. return *v, true
  21321. }
  21322. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  21323. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21325. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  21326. if !m.op.Is(OpUpdateOne) {
  21327. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  21328. }
  21329. if m.id == nil || m.oldValue == nil {
  21330. return v, errors.New("OldContactType requires an ID field in the mutation")
  21331. }
  21332. oldValue, err := m.oldValue(ctx)
  21333. if err != nil {
  21334. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  21335. }
  21336. return oldValue.ContactType, nil
  21337. }
  21338. // AddContactType adds i to the "contact_type" field.
  21339. func (m *MessageRecordsMutation) AddContactType(i int) {
  21340. if m.addcontact_type != nil {
  21341. *m.addcontact_type += i
  21342. } else {
  21343. m.addcontact_type = &i
  21344. }
  21345. }
  21346. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  21347. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  21348. v := m.addcontact_type
  21349. if v == nil {
  21350. return
  21351. }
  21352. return *v, true
  21353. }
  21354. // ResetContactType resets all changes to the "contact_type" field.
  21355. func (m *MessageRecordsMutation) ResetContactType() {
  21356. m.contact_type = nil
  21357. m.addcontact_type = nil
  21358. }
  21359. // SetContactWxid sets the "contact_wxid" field.
  21360. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  21361. m.contact_wxid = &s
  21362. }
  21363. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  21364. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  21365. v := m.contact_wxid
  21366. if v == nil {
  21367. return
  21368. }
  21369. return *v, true
  21370. }
  21371. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  21372. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21374. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  21375. if !m.op.Is(OpUpdateOne) {
  21376. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  21377. }
  21378. if m.id == nil || m.oldValue == nil {
  21379. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  21380. }
  21381. oldValue, err := m.oldValue(ctx)
  21382. if err != nil {
  21383. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  21384. }
  21385. return oldValue.ContactWxid, nil
  21386. }
  21387. // ResetContactWxid resets all changes to the "contact_wxid" field.
  21388. func (m *MessageRecordsMutation) ResetContactWxid() {
  21389. m.contact_wxid = nil
  21390. }
  21391. // SetContentType sets the "content_type" field.
  21392. func (m *MessageRecordsMutation) SetContentType(i int) {
  21393. m.content_type = &i
  21394. m.addcontent_type = nil
  21395. }
  21396. // ContentType returns the value of the "content_type" field in the mutation.
  21397. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  21398. v := m.content_type
  21399. if v == nil {
  21400. return
  21401. }
  21402. return *v, true
  21403. }
  21404. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  21405. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21407. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  21408. if !m.op.Is(OpUpdateOne) {
  21409. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  21410. }
  21411. if m.id == nil || m.oldValue == nil {
  21412. return v, errors.New("OldContentType requires an ID field in the mutation")
  21413. }
  21414. oldValue, err := m.oldValue(ctx)
  21415. if err != nil {
  21416. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  21417. }
  21418. return oldValue.ContentType, nil
  21419. }
  21420. // AddContentType adds i to the "content_type" field.
  21421. func (m *MessageRecordsMutation) AddContentType(i int) {
  21422. if m.addcontent_type != nil {
  21423. *m.addcontent_type += i
  21424. } else {
  21425. m.addcontent_type = &i
  21426. }
  21427. }
  21428. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  21429. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  21430. v := m.addcontent_type
  21431. if v == nil {
  21432. return
  21433. }
  21434. return *v, true
  21435. }
  21436. // ResetContentType resets all changes to the "content_type" field.
  21437. func (m *MessageRecordsMutation) ResetContentType() {
  21438. m.content_type = nil
  21439. m.addcontent_type = nil
  21440. }
  21441. // SetContent sets the "content" field.
  21442. func (m *MessageRecordsMutation) SetContent(s string) {
  21443. m.content = &s
  21444. }
  21445. // Content returns the value of the "content" field in the mutation.
  21446. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  21447. v := m.content
  21448. if v == nil {
  21449. return
  21450. }
  21451. return *v, true
  21452. }
  21453. // OldContent returns the old "content" field's value of the MessageRecords entity.
  21454. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21456. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  21457. if !m.op.Is(OpUpdateOne) {
  21458. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  21459. }
  21460. if m.id == nil || m.oldValue == nil {
  21461. return v, errors.New("OldContent requires an ID field in the mutation")
  21462. }
  21463. oldValue, err := m.oldValue(ctx)
  21464. if err != nil {
  21465. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  21466. }
  21467. return oldValue.Content, nil
  21468. }
  21469. // ResetContent resets all changes to the "content" field.
  21470. func (m *MessageRecordsMutation) ResetContent() {
  21471. m.content = nil
  21472. }
  21473. // SetMeta sets the "meta" field.
  21474. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  21475. m.meta = &ct
  21476. }
  21477. // Meta returns the value of the "meta" field in the mutation.
  21478. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  21479. v := m.meta
  21480. if v == nil {
  21481. return
  21482. }
  21483. return *v, true
  21484. }
  21485. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  21486. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21488. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  21489. if !m.op.Is(OpUpdateOne) {
  21490. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  21491. }
  21492. if m.id == nil || m.oldValue == nil {
  21493. return v, errors.New("OldMeta requires an ID field in the mutation")
  21494. }
  21495. oldValue, err := m.oldValue(ctx)
  21496. if err != nil {
  21497. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  21498. }
  21499. return oldValue.Meta, nil
  21500. }
  21501. // ClearMeta clears the value of the "meta" field.
  21502. func (m *MessageRecordsMutation) ClearMeta() {
  21503. m.meta = nil
  21504. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  21505. }
  21506. // MetaCleared returns if the "meta" field was cleared in this mutation.
  21507. func (m *MessageRecordsMutation) MetaCleared() bool {
  21508. _, ok := m.clearedFields[messagerecords.FieldMeta]
  21509. return ok
  21510. }
  21511. // ResetMeta resets all changes to the "meta" field.
  21512. func (m *MessageRecordsMutation) ResetMeta() {
  21513. m.meta = nil
  21514. delete(m.clearedFields, messagerecords.FieldMeta)
  21515. }
  21516. // SetErrorDetail sets the "error_detail" field.
  21517. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  21518. m.error_detail = &s
  21519. }
  21520. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  21521. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  21522. v := m.error_detail
  21523. if v == nil {
  21524. return
  21525. }
  21526. return *v, true
  21527. }
  21528. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  21529. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21531. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  21532. if !m.op.Is(OpUpdateOne) {
  21533. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  21534. }
  21535. if m.id == nil || m.oldValue == nil {
  21536. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  21537. }
  21538. oldValue, err := m.oldValue(ctx)
  21539. if err != nil {
  21540. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  21541. }
  21542. return oldValue.ErrorDetail, nil
  21543. }
  21544. // ResetErrorDetail resets all changes to the "error_detail" field.
  21545. func (m *MessageRecordsMutation) ResetErrorDetail() {
  21546. m.error_detail = nil
  21547. }
  21548. // SetSendTime sets the "send_time" field.
  21549. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  21550. m.send_time = &t
  21551. }
  21552. // SendTime returns the value of the "send_time" field in the mutation.
  21553. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  21554. v := m.send_time
  21555. if v == nil {
  21556. return
  21557. }
  21558. return *v, true
  21559. }
  21560. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  21561. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21563. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  21564. if !m.op.Is(OpUpdateOne) {
  21565. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  21566. }
  21567. if m.id == nil || m.oldValue == nil {
  21568. return v, errors.New("OldSendTime requires an ID field in the mutation")
  21569. }
  21570. oldValue, err := m.oldValue(ctx)
  21571. if err != nil {
  21572. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  21573. }
  21574. return oldValue.SendTime, nil
  21575. }
  21576. // ClearSendTime clears the value of the "send_time" field.
  21577. func (m *MessageRecordsMutation) ClearSendTime() {
  21578. m.send_time = nil
  21579. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  21580. }
  21581. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  21582. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  21583. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  21584. return ok
  21585. }
  21586. // ResetSendTime resets all changes to the "send_time" field.
  21587. func (m *MessageRecordsMutation) ResetSendTime() {
  21588. m.send_time = nil
  21589. delete(m.clearedFields, messagerecords.FieldSendTime)
  21590. }
  21591. // SetSourceType sets the "source_type" field.
  21592. func (m *MessageRecordsMutation) SetSourceType(i int) {
  21593. m.source_type = &i
  21594. m.addsource_type = nil
  21595. }
  21596. // SourceType returns the value of the "source_type" field in the mutation.
  21597. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  21598. v := m.source_type
  21599. if v == nil {
  21600. return
  21601. }
  21602. return *v, true
  21603. }
  21604. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  21605. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21607. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  21608. if !m.op.Is(OpUpdateOne) {
  21609. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  21610. }
  21611. if m.id == nil || m.oldValue == nil {
  21612. return v, errors.New("OldSourceType requires an ID field in the mutation")
  21613. }
  21614. oldValue, err := m.oldValue(ctx)
  21615. if err != nil {
  21616. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  21617. }
  21618. return oldValue.SourceType, nil
  21619. }
  21620. // AddSourceType adds i to the "source_type" field.
  21621. func (m *MessageRecordsMutation) AddSourceType(i int) {
  21622. if m.addsource_type != nil {
  21623. *m.addsource_type += i
  21624. } else {
  21625. m.addsource_type = &i
  21626. }
  21627. }
  21628. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  21629. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  21630. v := m.addsource_type
  21631. if v == nil {
  21632. return
  21633. }
  21634. return *v, true
  21635. }
  21636. // ResetSourceType resets all changes to the "source_type" field.
  21637. func (m *MessageRecordsMutation) ResetSourceType() {
  21638. m.source_type = nil
  21639. m.addsource_type = nil
  21640. }
  21641. // SetSourceID sets the "source_id" field.
  21642. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  21643. m.sop_stage = &u
  21644. }
  21645. // SourceID returns the value of the "source_id" field in the mutation.
  21646. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  21647. v := m.sop_stage
  21648. if v == nil {
  21649. return
  21650. }
  21651. return *v, true
  21652. }
  21653. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  21654. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21656. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  21657. if !m.op.Is(OpUpdateOne) {
  21658. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  21659. }
  21660. if m.id == nil || m.oldValue == nil {
  21661. return v, errors.New("OldSourceID requires an ID field in the mutation")
  21662. }
  21663. oldValue, err := m.oldValue(ctx)
  21664. if err != nil {
  21665. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  21666. }
  21667. return oldValue.SourceID, nil
  21668. }
  21669. // ClearSourceID clears the value of the "source_id" field.
  21670. func (m *MessageRecordsMutation) ClearSourceID() {
  21671. m.sop_stage = nil
  21672. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21673. }
  21674. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  21675. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  21676. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  21677. return ok
  21678. }
  21679. // ResetSourceID resets all changes to the "source_id" field.
  21680. func (m *MessageRecordsMutation) ResetSourceID() {
  21681. m.sop_stage = nil
  21682. delete(m.clearedFields, messagerecords.FieldSourceID)
  21683. }
  21684. // SetSubSourceID sets the "sub_source_id" field.
  21685. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  21686. m.sop_node = &u
  21687. }
  21688. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  21689. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  21690. v := m.sop_node
  21691. if v == nil {
  21692. return
  21693. }
  21694. return *v, true
  21695. }
  21696. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  21697. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21699. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  21700. if !m.op.Is(OpUpdateOne) {
  21701. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  21702. }
  21703. if m.id == nil || m.oldValue == nil {
  21704. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  21705. }
  21706. oldValue, err := m.oldValue(ctx)
  21707. if err != nil {
  21708. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  21709. }
  21710. return oldValue.SubSourceID, nil
  21711. }
  21712. // ClearSubSourceID clears the value of the "sub_source_id" field.
  21713. func (m *MessageRecordsMutation) ClearSubSourceID() {
  21714. m.sop_node = nil
  21715. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21716. }
  21717. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  21718. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  21719. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  21720. return ok
  21721. }
  21722. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  21723. func (m *MessageRecordsMutation) ResetSubSourceID() {
  21724. m.sop_node = nil
  21725. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  21726. }
  21727. // SetOrganizationID sets the "organization_id" field.
  21728. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  21729. m.organization_id = &u
  21730. m.addorganization_id = nil
  21731. }
  21732. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21733. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  21734. v := m.organization_id
  21735. if v == nil {
  21736. return
  21737. }
  21738. return *v, true
  21739. }
  21740. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  21741. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  21742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21743. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21744. if !m.op.Is(OpUpdateOne) {
  21745. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21746. }
  21747. if m.id == nil || m.oldValue == nil {
  21748. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21749. }
  21750. oldValue, err := m.oldValue(ctx)
  21751. if err != nil {
  21752. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21753. }
  21754. return oldValue.OrganizationID, nil
  21755. }
  21756. // AddOrganizationID adds u to the "organization_id" field.
  21757. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  21758. if m.addorganization_id != nil {
  21759. *m.addorganization_id += u
  21760. } else {
  21761. m.addorganization_id = &u
  21762. }
  21763. }
  21764. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21765. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  21766. v := m.addorganization_id
  21767. if v == nil {
  21768. return
  21769. }
  21770. return *v, true
  21771. }
  21772. // ClearOrganizationID clears the value of the "organization_id" field.
  21773. func (m *MessageRecordsMutation) ClearOrganizationID() {
  21774. m.organization_id = nil
  21775. m.addorganization_id = nil
  21776. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  21777. }
  21778. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21779. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  21780. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  21781. return ok
  21782. }
  21783. // ResetOrganizationID resets all changes to the "organization_id" field.
  21784. func (m *MessageRecordsMutation) ResetOrganizationID() {
  21785. m.organization_id = nil
  21786. m.addorganization_id = nil
  21787. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  21788. }
  21789. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21790. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  21791. m.sop_stage = &id
  21792. }
  21793. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21794. func (m *MessageRecordsMutation) ClearSopStage() {
  21795. m.clearedsop_stage = true
  21796. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  21797. }
  21798. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21799. func (m *MessageRecordsMutation) SopStageCleared() bool {
  21800. return m.SourceIDCleared() || m.clearedsop_stage
  21801. }
  21802. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21803. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  21804. if m.sop_stage != nil {
  21805. return *m.sop_stage, true
  21806. }
  21807. return
  21808. }
  21809. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21810. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21811. // SopStageID instead. It exists only for internal usage by the builders.
  21812. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  21813. if id := m.sop_stage; id != nil {
  21814. ids = append(ids, *id)
  21815. }
  21816. return
  21817. }
  21818. // ResetSopStage resets all changes to the "sop_stage" edge.
  21819. func (m *MessageRecordsMutation) ResetSopStage() {
  21820. m.sop_stage = nil
  21821. m.clearedsop_stage = false
  21822. }
  21823. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  21824. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  21825. m.sop_node = &id
  21826. }
  21827. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  21828. func (m *MessageRecordsMutation) ClearSopNode() {
  21829. m.clearedsop_node = true
  21830. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  21831. }
  21832. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  21833. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  21834. return m.SubSourceIDCleared() || m.clearedsop_node
  21835. }
  21836. // SopNodeID returns the "sop_node" edge ID in the mutation.
  21837. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  21838. if m.sop_node != nil {
  21839. return *m.sop_node, true
  21840. }
  21841. return
  21842. }
  21843. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  21844. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21845. // SopNodeID instead. It exists only for internal usage by the builders.
  21846. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  21847. if id := m.sop_node; id != nil {
  21848. ids = append(ids, *id)
  21849. }
  21850. return
  21851. }
  21852. // ResetSopNode resets all changes to the "sop_node" edge.
  21853. func (m *MessageRecordsMutation) ResetSopNode() {
  21854. m.sop_node = nil
  21855. m.clearedsop_node = false
  21856. }
  21857. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  21858. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  21859. m.message_contact = &id
  21860. }
  21861. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  21862. func (m *MessageRecordsMutation) ClearMessageContact() {
  21863. m.clearedmessage_contact = true
  21864. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  21865. }
  21866. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  21867. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  21868. return m.ContactIDCleared() || m.clearedmessage_contact
  21869. }
  21870. // MessageContactID returns the "message_contact" edge ID in the mutation.
  21871. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  21872. if m.message_contact != nil {
  21873. return *m.message_contact, true
  21874. }
  21875. return
  21876. }
  21877. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  21878. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21879. // MessageContactID instead. It exists only for internal usage by the builders.
  21880. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  21881. if id := m.message_contact; id != nil {
  21882. ids = append(ids, *id)
  21883. }
  21884. return
  21885. }
  21886. // ResetMessageContact resets all changes to the "message_contact" edge.
  21887. func (m *MessageRecordsMutation) ResetMessageContact() {
  21888. m.message_contact = nil
  21889. m.clearedmessage_contact = false
  21890. }
  21891. // Where appends a list predicates to the MessageRecordsMutation builder.
  21892. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  21893. m.predicates = append(m.predicates, ps...)
  21894. }
  21895. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  21896. // users can use type-assertion to append predicates that do not depend on any generated package.
  21897. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  21898. p := make([]predicate.MessageRecords, len(ps))
  21899. for i := range ps {
  21900. p[i] = ps[i]
  21901. }
  21902. m.Where(p...)
  21903. }
  21904. // Op returns the operation name.
  21905. func (m *MessageRecordsMutation) Op() Op {
  21906. return m.op
  21907. }
  21908. // SetOp allows setting the mutation operation.
  21909. func (m *MessageRecordsMutation) SetOp(op Op) {
  21910. m.op = op
  21911. }
  21912. // Type returns the node type of this mutation (MessageRecords).
  21913. func (m *MessageRecordsMutation) Type() string {
  21914. return m.typ
  21915. }
  21916. // Fields returns all fields that were changed during this mutation. Note that in
  21917. // order to get all numeric fields that were incremented/decremented, call
  21918. // AddedFields().
  21919. func (m *MessageRecordsMutation) Fields() []string {
  21920. fields := make([]string, 0, 16)
  21921. if m.created_at != nil {
  21922. fields = append(fields, messagerecords.FieldCreatedAt)
  21923. }
  21924. if m.updated_at != nil {
  21925. fields = append(fields, messagerecords.FieldUpdatedAt)
  21926. }
  21927. if m.status != nil {
  21928. fields = append(fields, messagerecords.FieldStatus)
  21929. }
  21930. if m.bot_wxid != nil {
  21931. fields = append(fields, messagerecords.FieldBotWxid)
  21932. }
  21933. if m.message_contact != nil {
  21934. fields = append(fields, messagerecords.FieldContactID)
  21935. }
  21936. if m.contact_type != nil {
  21937. fields = append(fields, messagerecords.FieldContactType)
  21938. }
  21939. if m.contact_wxid != nil {
  21940. fields = append(fields, messagerecords.FieldContactWxid)
  21941. }
  21942. if m.content_type != nil {
  21943. fields = append(fields, messagerecords.FieldContentType)
  21944. }
  21945. if m.content != nil {
  21946. fields = append(fields, messagerecords.FieldContent)
  21947. }
  21948. if m.meta != nil {
  21949. fields = append(fields, messagerecords.FieldMeta)
  21950. }
  21951. if m.error_detail != nil {
  21952. fields = append(fields, messagerecords.FieldErrorDetail)
  21953. }
  21954. if m.send_time != nil {
  21955. fields = append(fields, messagerecords.FieldSendTime)
  21956. }
  21957. if m.source_type != nil {
  21958. fields = append(fields, messagerecords.FieldSourceType)
  21959. }
  21960. if m.sop_stage != nil {
  21961. fields = append(fields, messagerecords.FieldSourceID)
  21962. }
  21963. if m.sop_node != nil {
  21964. fields = append(fields, messagerecords.FieldSubSourceID)
  21965. }
  21966. if m.organization_id != nil {
  21967. fields = append(fields, messagerecords.FieldOrganizationID)
  21968. }
  21969. return fields
  21970. }
  21971. // Field returns the value of a field with the given name. The second boolean
  21972. // return value indicates that this field was not set, or was not defined in the
  21973. // schema.
  21974. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  21975. switch name {
  21976. case messagerecords.FieldCreatedAt:
  21977. return m.CreatedAt()
  21978. case messagerecords.FieldUpdatedAt:
  21979. return m.UpdatedAt()
  21980. case messagerecords.FieldStatus:
  21981. return m.Status()
  21982. case messagerecords.FieldBotWxid:
  21983. return m.BotWxid()
  21984. case messagerecords.FieldContactID:
  21985. return m.ContactID()
  21986. case messagerecords.FieldContactType:
  21987. return m.ContactType()
  21988. case messagerecords.FieldContactWxid:
  21989. return m.ContactWxid()
  21990. case messagerecords.FieldContentType:
  21991. return m.ContentType()
  21992. case messagerecords.FieldContent:
  21993. return m.Content()
  21994. case messagerecords.FieldMeta:
  21995. return m.Meta()
  21996. case messagerecords.FieldErrorDetail:
  21997. return m.ErrorDetail()
  21998. case messagerecords.FieldSendTime:
  21999. return m.SendTime()
  22000. case messagerecords.FieldSourceType:
  22001. return m.SourceType()
  22002. case messagerecords.FieldSourceID:
  22003. return m.SourceID()
  22004. case messagerecords.FieldSubSourceID:
  22005. return m.SubSourceID()
  22006. case messagerecords.FieldOrganizationID:
  22007. return m.OrganizationID()
  22008. }
  22009. return nil, false
  22010. }
  22011. // OldField returns the old value of the field from the database. An error is
  22012. // returned if the mutation operation is not UpdateOne, or the query to the
  22013. // database failed.
  22014. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22015. switch name {
  22016. case messagerecords.FieldCreatedAt:
  22017. return m.OldCreatedAt(ctx)
  22018. case messagerecords.FieldUpdatedAt:
  22019. return m.OldUpdatedAt(ctx)
  22020. case messagerecords.FieldStatus:
  22021. return m.OldStatus(ctx)
  22022. case messagerecords.FieldBotWxid:
  22023. return m.OldBotWxid(ctx)
  22024. case messagerecords.FieldContactID:
  22025. return m.OldContactID(ctx)
  22026. case messagerecords.FieldContactType:
  22027. return m.OldContactType(ctx)
  22028. case messagerecords.FieldContactWxid:
  22029. return m.OldContactWxid(ctx)
  22030. case messagerecords.FieldContentType:
  22031. return m.OldContentType(ctx)
  22032. case messagerecords.FieldContent:
  22033. return m.OldContent(ctx)
  22034. case messagerecords.FieldMeta:
  22035. return m.OldMeta(ctx)
  22036. case messagerecords.FieldErrorDetail:
  22037. return m.OldErrorDetail(ctx)
  22038. case messagerecords.FieldSendTime:
  22039. return m.OldSendTime(ctx)
  22040. case messagerecords.FieldSourceType:
  22041. return m.OldSourceType(ctx)
  22042. case messagerecords.FieldSourceID:
  22043. return m.OldSourceID(ctx)
  22044. case messagerecords.FieldSubSourceID:
  22045. return m.OldSubSourceID(ctx)
  22046. case messagerecords.FieldOrganizationID:
  22047. return m.OldOrganizationID(ctx)
  22048. }
  22049. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  22050. }
  22051. // SetField sets the value of a field with the given name. It returns an error if
  22052. // the field is not defined in the schema, or if the type mismatched the field
  22053. // type.
  22054. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  22055. switch name {
  22056. case messagerecords.FieldCreatedAt:
  22057. v, ok := value.(time.Time)
  22058. if !ok {
  22059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22060. }
  22061. m.SetCreatedAt(v)
  22062. return nil
  22063. case messagerecords.FieldUpdatedAt:
  22064. v, ok := value.(time.Time)
  22065. if !ok {
  22066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22067. }
  22068. m.SetUpdatedAt(v)
  22069. return nil
  22070. case messagerecords.FieldStatus:
  22071. v, ok := value.(uint8)
  22072. if !ok {
  22073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22074. }
  22075. m.SetStatus(v)
  22076. return nil
  22077. case messagerecords.FieldBotWxid:
  22078. v, ok := value.(string)
  22079. if !ok {
  22080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22081. }
  22082. m.SetBotWxid(v)
  22083. return nil
  22084. case messagerecords.FieldContactID:
  22085. v, ok := value.(uint64)
  22086. if !ok {
  22087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22088. }
  22089. m.SetContactID(v)
  22090. return nil
  22091. case messagerecords.FieldContactType:
  22092. v, ok := value.(int)
  22093. if !ok {
  22094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22095. }
  22096. m.SetContactType(v)
  22097. return nil
  22098. case messagerecords.FieldContactWxid:
  22099. v, ok := value.(string)
  22100. if !ok {
  22101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22102. }
  22103. m.SetContactWxid(v)
  22104. return nil
  22105. case messagerecords.FieldContentType:
  22106. v, ok := value.(int)
  22107. if !ok {
  22108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22109. }
  22110. m.SetContentType(v)
  22111. return nil
  22112. case messagerecords.FieldContent:
  22113. v, ok := value.(string)
  22114. if !ok {
  22115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22116. }
  22117. m.SetContent(v)
  22118. return nil
  22119. case messagerecords.FieldMeta:
  22120. v, ok := value.(custom_types.Meta)
  22121. if !ok {
  22122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22123. }
  22124. m.SetMeta(v)
  22125. return nil
  22126. case messagerecords.FieldErrorDetail:
  22127. v, ok := value.(string)
  22128. if !ok {
  22129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22130. }
  22131. m.SetErrorDetail(v)
  22132. return nil
  22133. case messagerecords.FieldSendTime:
  22134. v, ok := value.(time.Time)
  22135. if !ok {
  22136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22137. }
  22138. m.SetSendTime(v)
  22139. return nil
  22140. case messagerecords.FieldSourceType:
  22141. v, ok := value.(int)
  22142. if !ok {
  22143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22144. }
  22145. m.SetSourceType(v)
  22146. return nil
  22147. case messagerecords.FieldSourceID:
  22148. v, ok := value.(uint64)
  22149. if !ok {
  22150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22151. }
  22152. m.SetSourceID(v)
  22153. return nil
  22154. case messagerecords.FieldSubSourceID:
  22155. v, ok := value.(uint64)
  22156. if !ok {
  22157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22158. }
  22159. m.SetSubSourceID(v)
  22160. return nil
  22161. case messagerecords.FieldOrganizationID:
  22162. v, ok := value.(uint64)
  22163. if !ok {
  22164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22165. }
  22166. m.SetOrganizationID(v)
  22167. return nil
  22168. }
  22169. return fmt.Errorf("unknown MessageRecords field %s", name)
  22170. }
  22171. // AddedFields returns all numeric fields that were incremented/decremented during
  22172. // this mutation.
  22173. func (m *MessageRecordsMutation) AddedFields() []string {
  22174. var fields []string
  22175. if m.addstatus != nil {
  22176. fields = append(fields, messagerecords.FieldStatus)
  22177. }
  22178. if m.addcontact_type != nil {
  22179. fields = append(fields, messagerecords.FieldContactType)
  22180. }
  22181. if m.addcontent_type != nil {
  22182. fields = append(fields, messagerecords.FieldContentType)
  22183. }
  22184. if m.addsource_type != nil {
  22185. fields = append(fields, messagerecords.FieldSourceType)
  22186. }
  22187. if m.addorganization_id != nil {
  22188. fields = append(fields, messagerecords.FieldOrganizationID)
  22189. }
  22190. return fields
  22191. }
  22192. // AddedField returns the numeric value that was incremented/decremented on a field
  22193. // with the given name. The second boolean return value indicates that this field
  22194. // was not set, or was not defined in the schema.
  22195. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  22196. switch name {
  22197. case messagerecords.FieldStatus:
  22198. return m.AddedStatus()
  22199. case messagerecords.FieldContactType:
  22200. return m.AddedContactType()
  22201. case messagerecords.FieldContentType:
  22202. return m.AddedContentType()
  22203. case messagerecords.FieldSourceType:
  22204. return m.AddedSourceType()
  22205. case messagerecords.FieldOrganizationID:
  22206. return m.AddedOrganizationID()
  22207. }
  22208. return nil, false
  22209. }
  22210. // AddField adds the value to the field with the given name. It returns an error if
  22211. // the field is not defined in the schema, or if the type mismatched the field
  22212. // type.
  22213. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  22214. switch name {
  22215. case messagerecords.FieldStatus:
  22216. v, ok := value.(int8)
  22217. if !ok {
  22218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22219. }
  22220. m.AddStatus(v)
  22221. return nil
  22222. case messagerecords.FieldContactType:
  22223. v, ok := value.(int)
  22224. if !ok {
  22225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22226. }
  22227. m.AddContactType(v)
  22228. return nil
  22229. case messagerecords.FieldContentType:
  22230. v, ok := value.(int)
  22231. if !ok {
  22232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22233. }
  22234. m.AddContentType(v)
  22235. return nil
  22236. case messagerecords.FieldSourceType:
  22237. v, ok := value.(int)
  22238. if !ok {
  22239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22240. }
  22241. m.AddSourceType(v)
  22242. return nil
  22243. case messagerecords.FieldOrganizationID:
  22244. v, ok := value.(int64)
  22245. if !ok {
  22246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22247. }
  22248. m.AddOrganizationID(v)
  22249. return nil
  22250. }
  22251. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  22252. }
  22253. // ClearedFields returns all nullable fields that were cleared during this
  22254. // mutation.
  22255. func (m *MessageRecordsMutation) ClearedFields() []string {
  22256. var fields []string
  22257. if m.FieldCleared(messagerecords.FieldStatus) {
  22258. fields = append(fields, messagerecords.FieldStatus)
  22259. }
  22260. if m.FieldCleared(messagerecords.FieldContactID) {
  22261. fields = append(fields, messagerecords.FieldContactID)
  22262. }
  22263. if m.FieldCleared(messagerecords.FieldMeta) {
  22264. fields = append(fields, messagerecords.FieldMeta)
  22265. }
  22266. if m.FieldCleared(messagerecords.FieldSendTime) {
  22267. fields = append(fields, messagerecords.FieldSendTime)
  22268. }
  22269. if m.FieldCleared(messagerecords.FieldSourceID) {
  22270. fields = append(fields, messagerecords.FieldSourceID)
  22271. }
  22272. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  22273. fields = append(fields, messagerecords.FieldSubSourceID)
  22274. }
  22275. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  22276. fields = append(fields, messagerecords.FieldOrganizationID)
  22277. }
  22278. return fields
  22279. }
  22280. // FieldCleared returns a boolean indicating if a field with the given name was
  22281. // cleared in this mutation.
  22282. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  22283. _, ok := m.clearedFields[name]
  22284. return ok
  22285. }
  22286. // ClearField clears the value of the field with the given name. It returns an
  22287. // error if the field is not defined in the schema.
  22288. func (m *MessageRecordsMutation) ClearField(name string) error {
  22289. switch name {
  22290. case messagerecords.FieldStatus:
  22291. m.ClearStatus()
  22292. return nil
  22293. case messagerecords.FieldContactID:
  22294. m.ClearContactID()
  22295. return nil
  22296. case messagerecords.FieldMeta:
  22297. m.ClearMeta()
  22298. return nil
  22299. case messagerecords.FieldSendTime:
  22300. m.ClearSendTime()
  22301. return nil
  22302. case messagerecords.FieldSourceID:
  22303. m.ClearSourceID()
  22304. return nil
  22305. case messagerecords.FieldSubSourceID:
  22306. m.ClearSubSourceID()
  22307. return nil
  22308. case messagerecords.FieldOrganizationID:
  22309. m.ClearOrganizationID()
  22310. return nil
  22311. }
  22312. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  22313. }
  22314. // ResetField resets all changes in the mutation for the field with the given name.
  22315. // It returns an error if the field is not defined in the schema.
  22316. func (m *MessageRecordsMutation) ResetField(name string) error {
  22317. switch name {
  22318. case messagerecords.FieldCreatedAt:
  22319. m.ResetCreatedAt()
  22320. return nil
  22321. case messagerecords.FieldUpdatedAt:
  22322. m.ResetUpdatedAt()
  22323. return nil
  22324. case messagerecords.FieldStatus:
  22325. m.ResetStatus()
  22326. return nil
  22327. case messagerecords.FieldBotWxid:
  22328. m.ResetBotWxid()
  22329. return nil
  22330. case messagerecords.FieldContactID:
  22331. m.ResetContactID()
  22332. return nil
  22333. case messagerecords.FieldContactType:
  22334. m.ResetContactType()
  22335. return nil
  22336. case messagerecords.FieldContactWxid:
  22337. m.ResetContactWxid()
  22338. return nil
  22339. case messagerecords.FieldContentType:
  22340. m.ResetContentType()
  22341. return nil
  22342. case messagerecords.FieldContent:
  22343. m.ResetContent()
  22344. return nil
  22345. case messagerecords.FieldMeta:
  22346. m.ResetMeta()
  22347. return nil
  22348. case messagerecords.FieldErrorDetail:
  22349. m.ResetErrorDetail()
  22350. return nil
  22351. case messagerecords.FieldSendTime:
  22352. m.ResetSendTime()
  22353. return nil
  22354. case messagerecords.FieldSourceType:
  22355. m.ResetSourceType()
  22356. return nil
  22357. case messagerecords.FieldSourceID:
  22358. m.ResetSourceID()
  22359. return nil
  22360. case messagerecords.FieldSubSourceID:
  22361. m.ResetSubSourceID()
  22362. return nil
  22363. case messagerecords.FieldOrganizationID:
  22364. m.ResetOrganizationID()
  22365. return nil
  22366. }
  22367. return fmt.Errorf("unknown MessageRecords field %s", name)
  22368. }
  22369. // AddedEdges returns all edge names that were set/added in this mutation.
  22370. func (m *MessageRecordsMutation) AddedEdges() []string {
  22371. edges := make([]string, 0, 3)
  22372. if m.sop_stage != nil {
  22373. edges = append(edges, messagerecords.EdgeSopStage)
  22374. }
  22375. if m.sop_node != nil {
  22376. edges = append(edges, messagerecords.EdgeSopNode)
  22377. }
  22378. if m.message_contact != nil {
  22379. edges = append(edges, messagerecords.EdgeMessageContact)
  22380. }
  22381. return edges
  22382. }
  22383. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22384. // name in this mutation.
  22385. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  22386. switch name {
  22387. case messagerecords.EdgeSopStage:
  22388. if id := m.sop_stage; id != nil {
  22389. return []ent.Value{*id}
  22390. }
  22391. case messagerecords.EdgeSopNode:
  22392. if id := m.sop_node; id != nil {
  22393. return []ent.Value{*id}
  22394. }
  22395. case messagerecords.EdgeMessageContact:
  22396. if id := m.message_contact; id != nil {
  22397. return []ent.Value{*id}
  22398. }
  22399. }
  22400. return nil
  22401. }
  22402. // RemovedEdges returns all edge names that were removed in this mutation.
  22403. func (m *MessageRecordsMutation) RemovedEdges() []string {
  22404. edges := make([]string, 0, 3)
  22405. return edges
  22406. }
  22407. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22408. // the given name in this mutation.
  22409. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  22410. return nil
  22411. }
  22412. // ClearedEdges returns all edge names that were cleared in this mutation.
  22413. func (m *MessageRecordsMutation) ClearedEdges() []string {
  22414. edges := make([]string, 0, 3)
  22415. if m.clearedsop_stage {
  22416. edges = append(edges, messagerecords.EdgeSopStage)
  22417. }
  22418. if m.clearedsop_node {
  22419. edges = append(edges, messagerecords.EdgeSopNode)
  22420. }
  22421. if m.clearedmessage_contact {
  22422. edges = append(edges, messagerecords.EdgeMessageContact)
  22423. }
  22424. return edges
  22425. }
  22426. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22427. // was cleared in this mutation.
  22428. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  22429. switch name {
  22430. case messagerecords.EdgeSopStage:
  22431. return m.clearedsop_stage
  22432. case messagerecords.EdgeSopNode:
  22433. return m.clearedsop_node
  22434. case messagerecords.EdgeMessageContact:
  22435. return m.clearedmessage_contact
  22436. }
  22437. return false
  22438. }
  22439. // ClearEdge clears the value of the edge with the given name. It returns an error
  22440. // if that edge is not defined in the schema.
  22441. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  22442. switch name {
  22443. case messagerecords.EdgeSopStage:
  22444. m.ClearSopStage()
  22445. return nil
  22446. case messagerecords.EdgeSopNode:
  22447. m.ClearSopNode()
  22448. return nil
  22449. case messagerecords.EdgeMessageContact:
  22450. m.ClearMessageContact()
  22451. return nil
  22452. }
  22453. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  22454. }
  22455. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22456. // It returns an error if the edge is not defined in the schema.
  22457. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  22458. switch name {
  22459. case messagerecords.EdgeSopStage:
  22460. m.ResetSopStage()
  22461. return nil
  22462. case messagerecords.EdgeSopNode:
  22463. m.ResetSopNode()
  22464. return nil
  22465. case messagerecords.EdgeMessageContact:
  22466. m.ResetMessageContact()
  22467. return nil
  22468. }
  22469. return fmt.Errorf("unknown MessageRecords edge %s", name)
  22470. }
  22471. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  22472. type MsgMutation struct {
  22473. config
  22474. op Op
  22475. typ string
  22476. id *uint64
  22477. created_at *time.Time
  22478. updated_at *time.Time
  22479. deleted_at *time.Time
  22480. status *uint8
  22481. addstatus *int8
  22482. fromwxid *string
  22483. toid *string
  22484. msgtype *int32
  22485. addmsgtype *int32
  22486. msg *string
  22487. batch_no *string
  22488. cc *string
  22489. phone *string
  22490. clearedFields map[string]struct{}
  22491. done bool
  22492. oldValue func(context.Context) (*Msg, error)
  22493. predicates []predicate.Msg
  22494. }
  22495. var _ ent.Mutation = (*MsgMutation)(nil)
  22496. // msgOption allows management of the mutation configuration using functional options.
  22497. type msgOption func(*MsgMutation)
  22498. // newMsgMutation creates new mutation for the Msg entity.
  22499. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  22500. m := &MsgMutation{
  22501. config: c,
  22502. op: op,
  22503. typ: TypeMsg,
  22504. clearedFields: make(map[string]struct{}),
  22505. }
  22506. for _, opt := range opts {
  22507. opt(m)
  22508. }
  22509. return m
  22510. }
  22511. // withMsgID sets the ID field of the mutation.
  22512. func withMsgID(id uint64) msgOption {
  22513. return func(m *MsgMutation) {
  22514. var (
  22515. err error
  22516. once sync.Once
  22517. value *Msg
  22518. )
  22519. m.oldValue = func(ctx context.Context) (*Msg, error) {
  22520. once.Do(func() {
  22521. if m.done {
  22522. err = errors.New("querying old values post mutation is not allowed")
  22523. } else {
  22524. value, err = m.Client().Msg.Get(ctx, id)
  22525. }
  22526. })
  22527. return value, err
  22528. }
  22529. m.id = &id
  22530. }
  22531. }
  22532. // withMsg sets the old Msg of the mutation.
  22533. func withMsg(node *Msg) msgOption {
  22534. return func(m *MsgMutation) {
  22535. m.oldValue = func(context.Context) (*Msg, error) {
  22536. return node, nil
  22537. }
  22538. m.id = &node.ID
  22539. }
  22540. }
  22541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22542. // executed in a transaction (ent.Tx), a transactional client is returned.
  22543. func (m MsgMutation) Client() *Client {
  22544. client := &Client{config: m.config}
  22545. client.init()
  22546. return client
  22547. }
  22548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22549. // it returns an error otherwise.
  22550. func (m MsgMutation) Tx() (*Tx, error) {
  22551. if _, ok := m.driver.(*txDriver); !ok {
  22552. return nil, errors.New("ent: mutation is not running in a transaction")
  22553. }
  22554. tx := &Tx{config: m.config}
  22555. tx.init()
  22556. return tx, nil
  22557. }
  22558. // SetID sets the value of the id field. Note that this
  22559. // operation is only accepted on creation of Msg entities.
  22560. func (m *MsgMutation) SetID(id uint64) {
  22561. m.id = &id
  22562. }
  22563. // ID returns the ID value in the mutation. Note that the ID is only available
  22564. // if it was provided to the builder or after it was returned from the database.
  22565. func (m *MsgMutation) ID() (id uint64, exists bool) {
  22566. if m.id == nil {
  22567. return
  22568. }
  22569. return *m.id, true
  22570. }
  22571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22572. // That means, if the mutation is applied within a transaction with an isolation level such
  22573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22574. // or updated by the mutation.
  22575. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  22576. switch {
  22577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22578. id, exists := m.ID()
  22579. if exists {
  22580. return []uint64{id}, nil
  22581. }
  22582. fallthrough
  22583. case m.op.Is(OpUpdate | OpDelete):
  22584. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  22585. default:
  22586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22587. }
  22588. }
  22589. // SetCreatedAt sets the "created_at" field.
  22590. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  22591. m.created_at = &t
  22592. }
  22593. // CreatedAt returns the value of the "created_at" field in the mutation.
  22594. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  22595. v := m.created_at
  22596. if v == nil {
  22597. return
  22598. }
  22599. return *v, true
  22600. }
  22601. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  22602. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22604. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22605. if !m.op.Is(OpUpdateOne) {
  22606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22607. }
  22608. if m.id == nil || m.oldValue == nil {
  22609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22610. }
  22611. oldValue, err := m.oldValue(ctx)
  22612. if err != nil {
  22613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22614. }
  22615. return oldValue.CreatedAt, nil
  22616. }
  22617. // ResetCreatedAt resets all changes to the "created_at" field.
  22618. func (m *MsgMutation) ResetCreatedAt() {
  22619. m.created_at = nil
  22620. }
  22621. // SetUpdatedAt sets the "updated_at" field.
  22622. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  22623. m.updated_at = &t
  22624. }
  22625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22626. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  22627. v := m.updated_at
  22628. if v == nil {
  22629. return
  22630. }
  22631. return *v, true
  22632. }
  22633. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  22634. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22636. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22637. if !m.op.Is(OpUpdateOne) {
  22638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22639. }
  22640. if m.id == nil || m.oldValue == nil {
  22641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22642. }
  22643. oldValue, err := m.oldValue(ctx)
  22644. if err != nil {
  22645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22646. }
  22647. return oldValue.UpdatedAt, nil
  22648. }
  22649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22650. func (m *MsgMutation) ResetUpdatedAt() {
  22651. m.updated_at = nil
  22652. }
  22653. // SetDeletedAt sets the "deleted_at" field.
  22654. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  22655. m.deleted_at = &t
  22656. }
  22657. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22658. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  22659. v := m.deleted_at
  22660. if v == nil {
  22661. return
  22662. }
  22663. return *v, true
  22664. }
  22665. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  22666. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22668. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22669. if !m.op.Is(OpUpdateOne) {
  22670. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22671. }
  22672. if m.id == nil || m.oldValue == nil {
  22673. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22674. }
  22675. oldValue, err := m.oldValue(ctx)
  22676. if err != nil {
  22677. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22678. }
  22679. return oldValue.DeletedAt, nil
  22680. }
  22681. // ClearDeletedAt clears the value of the "deleted_at" field.
  22682. func (m *MsgMutation) ClearDeletedAt() {
  22683. m.deleted_at = nil
  22684. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  22685. }
  22686. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22687. func (m *MsgMutation) DeletedAtCleared() bool {
  22688. _, ok := m.clearedFields[msg.FieldDeletedAt]
  22689. return ok
  22690. }
  22691. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22692. func (m *MsgMutation) ResetDeletedAt() {
  22693. m.deleted_at = nil
  22694. delete(m.clearedFields, msg.FieldDeletedAt)
  22695. }
  22696. // SetStatus sets the "status" field.
  22697. func (m *MsgMutation) SetStatus(u uint8) {
  22698. m.status = &u
  22699. m.addstatus = nil
  22700. }
  22701. // Status returns the value of the "status" field in the mutation.
  22702. func (m *MsgMutation) Status() (r uint8, exists bool) {
  22703. v := m.status
  22704. if v == nil {
  22705. return
  22706. }
  22707. return *v, true
  22708. }
  22709. // OldStatus returns the old "status" field's value of the Msg entity.
  22710. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22712. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22713. if !m.op.Is(OpUpdateOne) {
  22714. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22715. }
  22716. if m.id == nil || m.oldValue == nil {
  22717. return v, errors.New("OldStatus requires an ID field in the mutation")
  22718. }
  22719. oldValue, err := m.oldValue(ctx)
  22720. if err != nil {
  22721. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22722. }
  22723. return oldValue.Status, nil
  22724. }
  22725. // AddStatus adds u to the "status" field.
  22726. func (m *MsgMutation) AddStatus(u int8) {
  22727. if m.addstatus != nil {
  22728. *m.addstatus += u
  22729. } else {
  22730. m.addstatus = &u
  22731. }
  22732. }
  22733. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22734. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  22735. v := m.addstatus
  22736. if v == nil {
  22737. return
  22738. }
  22739. return *v, true
  22740. }
  22741. // ClearStatus clears the value of the "status" field.
  22742. func (m *MsgMutation) ClearStatus() {
  22743. m.status = nil
  22744. m.addstatus = nil
  22745. m.clearedFields[msg.FieldStatus] = struct{}{}
  22746. }
  22747. // StatusCleared returns if the "status" field was cleared in this mutation.
  22748. func (m *MsgMutation) StatusCleared() bool {
  22749. _, ok := m.clearedFields[msg.FieldStatus]
  22750. return ok
  22751. }
  22752. // ResetStatus resets all changes to the "status" field.
  22753. func (m *MsgMutation) ResetStatus() {
  22754. m.status = nil
  22755. m.addstatus = nil
  22756. delete(m.clearedFields, msg.FieldStatus)
  22757. }
  22758. // SetFromwxid sets the "fromwxid" field.
  22759. func (m *MsgMutation) SetFromwxid(s string) {
  22760. m.fromwxid = &s
  22761. }
  22762. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  22763. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  22764. v := m.fromwxid
  22765. if v == nil {
  22766. return
  22767. }
  22768. return *v, true
  22769. }
  22770. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  22771. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22773. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  22774. if !m.op.Is(OpUpdateOne) {
  22775. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  22776. }
  22777. if m.id == nil || m.oldValue == nil {
  22778. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  22779. }
  22780. oldValue, err := m.oldValue(ctx)
  22781. if err != nil {
  22782. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  22783. }
  22784. return oldValue.Fromwxid, nil
  22785. }
  22786. // ClearFromwxid clears the value of the "fromwxid" field.
  22787. func (m *MsgMutation) ClearFromwxid() {
  22788. m.fromwxid = nil
  22789. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  22790. }
  22791. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  22792. func (m *MsgMutation) FromwxidCleared() bool {
  22793. _, ok := m.clearedFields[msg.FieldFromwxid]
  22794. return ok
  22795. }
  22796. // ResetFromwxid resets all changes to the "fromwxid" field.
  22797. func (m *MsgMutation) ResetFromwxid() {
  22798. m.fromwxid = nil
  22799. delete(m.clearedFields, msg.FieldFromwxid)
  22800. }
  22801. // SetToid sets the "toid" field.
  22802. func (m *MsgMutation) SetToid(s string) {
  22803. m.toid = &s
  22804. }
  22805. // Toid returns the value of the "toid" field in the mutation.
  22806. func (m *MsgMutation) Toid() (r string, exists bool) {
  22807. v := m.toid
  22808. if v == nil {
  22809. return
  22810. }
  22811. return *v, true
  22812. }
  22813. // OldToid returns the old "toid" field's value of the Msg entity.
  22814. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22816. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  22817. if !m.op.Is(OpUpdateOne) {
  22818. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  22819. }
  22820. if m.id == nil || m.oldValue == nil {
  22821. return v, errors.New("OldToid requires an ID field in the mutation")
  22822. }
  22823. oldValue, err := m.oldValue(ctx)
  22824. if err != nil {
  22825. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  22826. }
  22827. return oldValue.Toid, nil
  22828. }
  22829. // ClearToid clears the value of the "toid" field.
  22830. func (m *MsgMutation) ClearToid() {
  22831. m.toid = nil
  22832. m.clearedFields[msg.FieldToid] = struct{}{}
  22833. }
  22834. // ToidCleared returns if the "toid" field was cleared in this mutation.
  22835. func (m *MsgMutation) ToidCleared() bool {
  22836. _, ok := m.clearedFields[msg.FieldToid]
  22837. return ok
  22838. }
  22839. // ResetToid resets all changes to the "toid" field.
  22840. func (m *MsgMutation) ResetToid() {
  22841. m.toid = nil
  22842. delete(m.clearedFields, msg.FieldToid)
  22843. }
  22844. // SetMsgtype sets the "msgtype" field.
  22845. func (m *MsgMutation) SetMsgtype(i int32) {
  22846. m.msgtype = &i
  22847. m.addmsgtype = nil
  22848. }
  22849. // Msgtype returns the value of the "msgtype" field in the mutation.
  22850. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  22851. v := m.msgtype
  22852. if v == nil {
  22853. return
  22854. }
  22855. return *v, true
  22856. }
  22857. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  22858. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22860. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  22861. if !m.op.Is(OpUpdateOne) {
  22862. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  22863. }
  22864. if m.id == nil || m.oldValue == nil {
  22865. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  22866. }
  22867. oldValue, err := m.oldValue(ctx)
  22868. if err != nil {
  22869. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  22870. }
  22871. return oldValue.Msgtype, nil
  22872. }
  22873. // AddMsgtype adds i to the "msgtype" field.
  22874. func (m *MsgMutation) AddMsgtype(i int32) {
  22875. if m.addmsgtype != nil {
  22876. *m.addmsgtype += i
  22877. } else {
  22878. m.addmsgtype = &i
  22879. }
  22880. }
  22881. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  22882. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  22883. v := m.addmsgtype
  22884. if v == nil {
  22885. return
  22886. }
  22887. return *v, true
  22888. }
  22889. // ClearMsgtype clears the value of the "msgtype" field.
  22890. func (m *MsgMutation) ClearMsgtype() {
  22891. m.msgtype = nil
  22892. m.addmsgtype = nil
  22893. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  22894. }
  22895. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  22896. func (m *MsgMutation) MsgtypeCleared() bool {
  22897. _, ok := m.clearedFields[msg.FieldMsgtype]
  22898. return ok
  22899. }
  22900. // ResetMsgtype resets all changes to the "msgtype" field.
  22901. func (m *MsgMutation) ResetMsgtype() {
  22902. m.msgtype = nil
  22903. m.addmsgtype = nil
  22904. delete(m.clearedFields, msg.FieldMsgtype)
  22905. }
  22906. // SetMsg sets the "msg" field.
  22907. func (m *MsgMutation) SetMsg(s string) {
  22908. m.msg = &s
  22909. }
  22910. // Msg returns the value of the "msg" field in the mutation.
  22911. func (m *MsgMutation) Msg() (r string, exists bool) {
  22912. v := m.msg
  22913. if v == nil {
  22914. return
  22915. }
  22916. return *v, true
  22917. }
  22918. // OldMsg returns the old "msg" field's value of the Msg entity.
  22919. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22921. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  22922. if !m.op.Is(OpUpdateOne) {
  22923. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  22924. }
  22925. if m.id == nil || m.oldValue == nil {
  22926. return v, errors.New("OldMsg requires an ID field in the mutation")
  22927. }
  22928. oldValue, err := m.oldValue(ctx)
  22929. if err != nil {
  22930. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  22931. }
  22932. return oldValue.Msg, nil
  22933. }
  22934. // ClearMsg clears the value of the "msg" field.
  22935. func (m *MsgMutation) ClearMsg() {
  22936. m.msg = nil
  22937. m.clearedFields[msg.FieldMsg] = struct{}{}
  22938. }
  22939. // MsgCleared returns if the "msg" field was cleared in this mutation.
  22940. func (m *MsgMutation) MsgCleared() bool {
  22941. _, ok := m.clearedFields[msg.FieldMsg]
  22942. return ok
  22943. }
  22944. // ResetMsg resets all changes to the "msg" field.
  22945. func (m *MsgMutation) ResetMsg() {
  22946. m.msg = nil
  22947. delete(m.clearedFields, msg.FieldMsg)
  22948. }
  22949. // SetBatchNo sets the "batch_no" field.
  22950. func (m *MsgMutation) SetBatchNo(s string) {
  22951. m.batch_no = &s
  22952. }
  22953. // BatchNo returns the value of the "batch_no" field in the mutation.
  22954. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  22955. v := m.batch_no
  22956. if v == nil {
  22957. return
  22958. }
  22959. return *v, true
  22960. }
  22961. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  22962. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  22963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22964. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  22965. if !m.op.Is(OpUpdateOne) {
  22966. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  22967. }
  22968. if m.id == nil || m.oldValue == nil {
  22969. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  22970. }
  22971. oldValue, err := m.oldValue(ctx)
  22972. if err != nil {
  22973. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  22974. }
  22975. return oldValue.BatchNo, nil
  22976. }
  22977. // ClearBatchNo clears the value of the "batch_no" field.
  22978. func (m *MsgMutation) ClearBatchNo() {
  22979. m.batch_no = nil
  22980. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  22981. }
  22982. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  22983. func (m *MsgMutation) BatchNoCleared() bool {
  22984. _, ok := m.clearedFields[msg.FieldBatchNo]
  22985. return ok
  22986. }
  22987. // ResetBatchNo resets all changes to the "batch_no" field.
  22988. func (m *MsgMutation) ResetBatchNo() {
  22989. m.batch_no = nil
  22990. delete(m.clearedFields, msg.FieldBatchNo)
  22991. }
  22992. // SetCc sets the "cc" field.
  22993. func (m *MsgMutation) SetCc(s string) {
  22994. m.cc = &s
  22995. }
  22996. // Cc returns the value of the "cc" field in the mutation.
  22997. func (m *MsgMutation) Cc() (r string, exists bool) {
  22998. v := m.cc
  22999. if v == nil {
  23000. return
  23001. }
  23002. return *v, true
  23003. }
  23004. // OldCc returns the old "cc" field's value of the Msg entity.
  23005. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23007. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  23008. if !m.op.Is(OpUpdateOne) {
  23009. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  23010. }
  23011. if m.id == nil || m.oldValue == nil {
  23012. return v, errors.New("OldCc requires an ID field in the mutation")
  23013. }
  23014. oldValue, err := m.oldValue(ctx)
  23015. if err != nil {
  23016. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  23017. }
  23018. return oldValue.Cc, nil
  23019. }
  23020. // ResetCc resets all changes to the "cc" field.
  23021. func (m *MsgMutation) ResetCc() {
  23022. m.cc = nil
  23023. }
  23024. // SetPhone sets the "phone" field.
  23025. func (m *MsgMutation) SetPhone(s string) {
  23026. m.phone = &s
  23027. }
  23028. // Phone returns the value of the "phone" field in the mutation.
  23029. func (m *MsgMutation) Phone() (r string, exists bool) {
  23030. v := m.phone
  23031. if v == nil {
  23032. return
  23033. }
  23034. return *v, true
  23035. }
  23036. // OldPhone returns the old "phone" field's value of the Msg entity.
  23037. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23039. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  23040. if !m.op.Is(OpUpdateOne) {
  23041. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  23042. }
  23043. if m.id == nil || m.oldValue == nil {
  23044. return v, errors.New("OldPhone requires an ID field in the mutation")
  23045. }
  23046. oldValue, err := m.oldValue(ctx)
  23047. if err != nil {
  23048. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  23049. }
  23050. return oldValue.Phone, nil
  23051. }
  23052. // ResetPhone resets all changes to the "phone" field.
  23053. func (m *MsgMutation) ResetPhone() {
  23054. m.phone = nil
  23055. }
  23056. // Where appends a list predicates to the MsgMutation builder.
  23057. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  23058. m.predicates = append(m.predicates, ps...)
  23059. }
  23060. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  23061. // users can use type-assertion to append predicates that do not depend on any generated package.
  23062. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  23063. p := make([]predicate.Msg, len(ps))
  23064. for i := range ps {
  23065. p[i] = ps[i]
  23066. }
  23067. m.Where(p...)
  23068. }
  23069. // Op returns the operation name.
  23070. func (m *MsgMutation) Op() Op {
  23071. return m.op
  23072. }
  23073. // SetOp allows setting the mutation operation.
  23074. func (m *MsgMutation) SetOp(op Op) {
  23075. m.op = op
  23076. }
  23077. // Type returns the node type of this mutation (Msg).
  23078. func (m *MsgMutation) Type() string {
  23079. return m.typ
  23080. }
  23081. // Fields returns all fields that were changed during this mutation. Note that in
  23082. // order to get all numeric fields that were incremented/decremented, call
  23083. // AddedFields().
  23084. func (m *MsgMutation) Fields() []string {
  23085. fields := make([]string, 0, 11)
  23086. if m.created_at != nil {
  23087. fields = append(fields, msg.FieldCreatedAt)
  23088. }
  23089. if m.updated_at != nil {
  23090. fields = append(fields, msg.FieldUpdatedAt)
  23091. }
  23092. if m.deleted_at != nil {
  23093. fields = append(fields, msg.FieldDeletedAt)
  23094. }
  23095. if m.status != nil {
  23096. fields = append(fields, msg.FieldStatus)
  23097. }
  23098. if m.fromwxid != nil {
  23099. fields = append(fields, msg.FieldFromwxid)
  23100. }
  23101. if m.toid != nil {
  23102. fields = append(fields, msg.FieldToid)
  23103. }
  23104. if m.msgtype != nil {
  23105. fields = append(fields, msg.FieldMsgtype)
  23106. }
  23107. if m.msg != nil {
  23108. fields = append(fields, msg.FieldMsg)
  23109. }
  23110. if m.batch_no != nil {
  23111. fields = append(fields, msg.FieldBatchNo)
  23112. }
  23113. if m.cc != nil {
  23114. fields = append(fields, msg.FieldCc)
  23115. }
  23116. if m.phone != nil {
  23117. fields = append(fields, msg.FieldPhone)
  23118. }
  23119. return fields
  23120. }
  23121. // Field returns the value of a field with the given name. The second boolean
  23122. // return value indicates that this field was not set, or was not defined in the
  23123. // schema.
  23124. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  23125. switch name {
  23126. case msg.FieldCreatedAt:
  23127. return m.CreatedAt()
  23128. case msg.FieldUpdatedAt:
  23129. return m.UpdatedAt()
  23130. case msg.FieldDeletedAt:
  23131. return m.DeletedAt()
  23132. case msg.FieldStatus:
  23133. return m.Status()
  23134. case msg.FieldFromwxid:
  23135. return m.Fromwxid()
  23136. case msg.FieldToid:
  23137. return m.Toid()
  23138. case msg.FieldMsgtype:
  23139. return m.Msgtype()
  23140. case msg.FieldMsg:
  23141. return m.Msg()
  23142. case msg.FieldBatchNo:
  23143. return m.BatchNo()
  23144. case msg.FieldCc:
  23145. return m.Cc()
  23146. case msg.FieldPhone:
  23147. return m.Phone()
  23148. }
  23149. return nil, false
  23150. }
  23151. // OldField returns the old value of the field from the database. An error is
  23152. // returned if the mutation operation is not UpdateOne, or the query to the
  23153. // database failed.
  23154. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23155. switch name {
  23156. case msg.FieldCreatedAt:
  23157. return m.OldCreatedAt(ctx)
  23158. case msg.FieldUpdatedAt:
  23159. return m.OldUpdatedAt(ctx)
  23160. case msg.FieldDeletedAt:
  23161. return m.OldDeletedAt(ctx)
  23162. case msg.FieldStatus:
  23163. return m.OldStatus(ctx)
  23164. case msg.FieldFromwxid:
  23165. return m.OldFromwxid(ctx)
  23166. case msg.FieldToid:
  23167. return m.OldToid(ctx)
  23168. case msg.FieldMsgtype:
  23169. return m.OldMsgtype(ctx)
  23170. case msg.FieldMsg:
  23171. return m.OldMsg(ctx)
  23172. case msg.FieldBatchNo:
  23173. return m.OldBatchNo(ctx)
  23174. case msg.FieldCc:
  23175. return m.OldCc(ctx)
  23176. case msg.FieldPhone:
  23177. return m.OldPhone(ctx)
  23178. }
  23179. return nil, fmt.Errorf("unknown Msg field %s", name)
  23180. }
  23181. // SetField sets the value of a field with the given name. It returns an error if
  23182. // the field is not defined in the schema, or if the type mismatched the field
  23183. // type.
  23184. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  23185. switch name {
  23186. case msg.FieldCreatedAt:
  23187. v, ok := value.(time.Time)
  23188. if !ok {
  23189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23190. }
  23191. m.SetCreatedAt(v)
  23192. return nil
  23193. case msg.FieldUpdatedAt:
  23194. v, ok := value.(time.Time)
  23195. if !ok {
  23196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23197. }
  23198. m.SetUpdatedAt(v)
  23199. return nil
  23200. case msg.FieldDeletedAt:
  23201. v, ok := value.(time.Time)
  23202. if !ok {
  23203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23204. }
  23205. m.SetDeletedAt(v)
  23206. return nil
  23207. case msg.FieldStatus:
  23208. v, ok := value.(uint8)
  23209. if !ok {
  23210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23211. }
  23212. m.SetStatus(v)
  23213. return nil
  23214. case msg.FieldFromwxid:
  23215. v, ok := value.(string)
  23216. if !ok {
  23217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23218. }
  23219. m.SetFromwxid(v)
  23220. return nil
  23221. case msg.FieldToid:
  23222. v, ok := value.(string)
  23223. if !ok {
  23224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23225. }
  23226. m.SetToid(v)
  23227. return nil
  23228. case msg.FieldMsgtype:
  23229. v, ok := value.(int32)
  23230. if !ok {
  23231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23232. }
  23233. m.SetMsgtype(v)
  23234. return nil
  23235. case msg.FieldMsg:
  23236. v, ok := value.(string)
  23237. if !ok {
  23238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23239. }
  23240. m.SetMsg(v)
  23241. return nil
  23242. case msg.FieldBatchNo:
  23243. v, ok := value.(string)
  23244. if !ok {
  23245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23246. }
  23247. m.SetBatchNo(v)
  23248. return nil
  23249. case msg.FieldCc:
  23250. v, ok := value.(string)
  23251. if !ok {
  23252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23253. }
  23254. m.SetCc(v)
  23255. return nil
  23256. case msg.FieldPhone:
  23257. v, ok := value.(string)
  23258. if !ok {
  23259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23260. }
  23261. m.SetPhone(v)
  23262. return nil
  23263. }
  23264. return fmt.Errorf("unknown Msg field %s", name)
  23265. }
  23266. // AddedFields returns all numeric fields that were incremented/decremented during
  23267. // this mutation.
  23268. func (m *MsgMutation) AddedFields() []string {
  23269. var fields []string
  23270. if m.addstatus != nil {
  23271. fields = append(fields, msg.FieldStatus)
  23272. }
  23273. if m.addmsgtype != nil {
  23274. fields = append(fields, msg.FieldMsgtype)
  23275. }
  23276. return fields
  23277. }
  23278. // AddedField returns the numeric value that was incremented/decremented on a field
  23279. // with the given name. The second boolean return value indicates that this field
  23280. // was not set, or was not defined in the schema.
  23281. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  23282. switch name {
  23283. case msg.FieldStatus:
  23284. return m.AddedStatus()
  23285. case msg.FieldMsgtype:
  23286. return m.AddedMsgtype()
  23287. }
  23288. return nil, false
  23289. }
  23290. // AddField adds the value to the field with the given name. It returns an error if
  23291. // the field is not defined in the schema, or if the type mismatched the field
  23292. // type.
  23293. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  23294. switch name {
  23295. case msg.FieldStatus:
  23296. v, ok := value.(int8)
  23297. if !ok {
  23298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23299. }
  23300. m.AddStatus(v)
  23301. return nil
  23302. case msg.FieldMsgtype:
  23303. v, ok := value.(int32)
  23304. if !ok {
  23305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23306. }
  23307. m.AddMsgtype(v)
  23308. return nil
  23309. }
  23310. return fmt.Errorf("unknown Msg numeric field %s", name)
  23311. }
  23312. // ClearedFields returns all nullable fields that were cleared during this
  23313. // mutation.
  23314. func (m *MsgMutation) ClearedFields() []string {
  23315. var fields []string
  23316. if m.FieldCleared(msg.FieldDeletedAt) {
  23317. fields = append(fields, msg.FieldDeletedAt)
  23318. }
  23319. if m.FieldCleared(msg.FieldStatus) {
  23320. fields = append(fields, msg.FieldStatus)
  23321. }
  23322. if m.FieldCleared(msg.FieldFromwxid) {
  23323. fields = append(fields, msg.FieldFromwxid)
  23324. }
  23325. if m.FieldCleared(msg.FieldToid) {
  23326. fields = append(fields, msg.FieldToid)
  23327. }
  23328. if m.FieldCleared(msg.FieldMsgtype) {
  23329. fields = append(fields, msg.FieldMsgtype)
  23330. }
  23331. if m.FieldCleared(msg.FieldMsg) {
  23332. fields = append(fields, msg.FieldMsg)
  23333. }
  23334. if m.FieldCleared(msg.FieldBatchNo) {
  23335. fields = append(fields, msg.FieldBatchNo)
  23336. }
  23337. return fields
  23338. }
  23339. // FieldCleared returns a boolean indicating if a field with the given name was
  23340. // cleared in this mutation.
  23341. func (m *MsgMutation) FieldCleared(name string) bool {
  23342. _, ok := m.clearedFields[name]
  23343. return ok
  23344. }
  23345. // ClearField clears the value of the field with the given name. It returns an
  23346. // error if the field is not defined in the schema.
  23347. func (m *MsgMutation) ClearField(name string) error {
  23348. switch name {
  23349. case msg.FieldDeletedAt:
  23350. m.ClearDeletedAt()
  23351. return nil
  23352. case msg.FieldStatus:
  23353. m.ClearStatus()
  23354. return nil
  23355. case msg.FieldFromwxid:
  23356. m.ClearFromwxid()
  23357. return nil
  23358. case msg.FieldToid:
  23359. m.ClearToid()
  23360. return nil
  23361. case msg.FieldMsgtype:
  23362. m.ClearMsgtype()
  23363. return nil
  23364. case msg.FieldMsg:
  23365. m.ClearMsg()
  23366. return nil
  23367. case msg.FieldBatchNo:
  23368. m.ClearBatchNo()
  23369. return nil
  23370. }
  23371. return fmt.Errorf("unknown Msg nullable field %s", name)
  23372. }
  23373. // ResetField resets all changes in the mutation for the field with the given name.
  23374. // It returns an error if the field is not defined in the schema.
  23375. func (m *MsgMutation) ResetField(name string) error {
  23376. switch name {
  23377. case msg.FieldCreatedAt:
  23378. m.ResetCreatedAt()
  23379. return nil
  23380. case msg.FieldUpdatedAt:
  23381. m.ResetUpdatedAt()
  23382. return nil
  23383. case msg.FieldDeletedAt:
  23384. m.ResetDeletedAt()
  23385. return nil
  23386. case msg.FieldStatus:
  23387. m.ResetStatus()
  23388. return nil
  23389. case msg.FieldFromwxid:
  23390. m.ResetFromwxid()
  23391. return nil
  23392. case msg.FieldToid:
  23393. m.ResetToid()
  23394. return nil
  23395. case msg.FieldMsgtype:
  23396. m.ResetMsgtype()
  23397. return nil
  23398. case msg.FieldMsg:
  23399. m.ResetMsg()
  23400. return nil
  23401. case msg.FieldBatchNo:
  23402. m.ResetBatchNo()
  23403. return nil
  23404. case msg.FieldCc:
  23405. m.ResetCc()
  23406. return nil
  23407. case msg.FieldPhone:
  23408. m.ResetPhone()
  23409. return nil
  23410. }
  23411. return fmt.Errorf("unknown Msg field %s", name)
  23412. }
  23413. // AddedEdges returns all edge names that were set/added in this mutation.
  23414. func (m *MsgMutation) AddedEdges() []string {
  23415. edges := make([]string, 0, 0)
  23416. return edges
  23417. }
  23418. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23419. // name in this mutation.
  23420. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  23421. return nil
  23422. }
  23423. // RemovedEdges returns all edge names that were removed in this mutation.
  23424. func (m *MsgMutation) RemovedEdges() []string {
  23425. edges := make([]string, 0, 0)
  23426. return edges
  23427. }
  23428. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23429. // the given name in this mutation.
  23430. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  23431. return nil
  23432. }
  23433. // ClearedEdges returns all edge names that were cleared in this mutation.
  23434. func (m *MsgMutation) ClearedEdges() []string {
  23435. edges := make([]string, 0, 0)
  23436. return edges
  23437. }
  23438. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23439. // was cleared in this mutation.
  23440. func (m *MsgMutation) EdgeCleared(name string) bool {
  23441. return false
  23442. }
  23443. // ClearEdge clears the value of the edge with the given name. It returns an error
  23444. // if that edge is not defined in the schema.
  23445. func (m *MsgMutation) ClearEdge(name string) error {
  23446. return fmt.Errorf("unknown Msg unique edge %s", name)
  23447. }
  23448. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23449. // It returns an error if the edge is not defined in the schema.
  23450. func (m *MsgMutation) ResetEdge(name string) error {
  23451. return fmt.Errorf("unknown Msg edge %s", name)
  23452. }
  23453. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  23454. type PayRechargeMutation struct {
  23455. config
  23456. op Op
  23457. typ string
  23458. id *uint64
  23459. created_at *time.Time
  23460. updated_at *time.Time
  23461. deleted_at *time.Time
  23462. user_id *string
  23463. number *float32
  23464. addnumber *float32
  23465. status *int
  23466. addstatus *int
  23467. money *float32
  23468. addmoney *float32
  23469. out_trade_no *string
  23470. organization_id *uint64
  23471. addorganization_id *int64
  23472. clearedFields map[string]struct{}
  23473. done bool
  23474. oldValue func(context.Context) (*PayRecharge, error)
  23475. predicates []predicate.PayRecharge
  23476. }
  23477. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  23478. // payrechargeOption allows management of the mutation configuration using functional options.
  23479. type payrechargeOption func(*PayRechargeMutation)
  23480. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  23481. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  23482. m := &PayRechargeMutation{
  23483. config: c,
  23484. op: op,
  23485. typ: TypePayRecharge,
  23486. clearedFields: make(map[string]struct{}),
  23487. }
  23488. for _, opt := range opts {
  23489. opt(m)
  23490. }
  23491. return m
  23492. }
  23493. // withPayRechargeID sets the ID field of the mutation.
  23494. func withPayRechargeID(id uint64) payrechargeOption {
  23495. return func(m *PayRechargeMutation) {
  23496. var (
  23497. err error
  23498. once sync.Once
  23499. value *PayRecharge
  23500. )
  23501. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  23502. once.Do(func() {
  23503. if m.done {
  23504. err = errors.New("querying old values post mutation is not allowed")
  23505. } else {
  23506. value, err = m.Client().PayRecharge.Get(ctx, id)
  23507. }
  23508. })
  23509. return value, err
  23510. }
  23511. m.id = &id
  23512. }
  23513. }
  23514. // withPayRecharge sets the old PayRecharge of the mutation.
  23515. func withPayRecharge(node *PayRecharge) payrechargeOption {
  23516. return func(m *PayRechargeMutation) {
  23517. m.oldValue = func(context.Context) (*PayRecharge, error) {
  23518. return node, nil
  23519. }
  23520. m.id = &node.ID
  23521. }
  23522. }
  23523. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23524. // executed in a transaction (ent.Tx), a transactional client is returned.
  23525. func (m PayRechargeMutation) Client() *Client {
  23526. client := &Client{config: m.config}
  23527. client.init()
  23528. return client
  23529. }
  23530. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23531. // it returns an error otherwise.
  23532. func (m PayRechargeMutation) Tx() (*Tx, error) {
  23533. if _, ok := m.driver.(*txDriver); !ok {
  23534. return nil, errors.New("ent: mutation is not running in a transaction")
  23535. }
  23536. tx := &Tx{config: m.config}
  23537. tx.init()
  23538. return tx, nil
  23539. }
  23540. // SetID sets the value of the id field. Note that this
  23541. // operation is only accepted on creation of PayRecharge entities.
  23542. func (m *PayRechargeMutation) SetID(id uint64) {
  23543. m.id = &id
  23544. }
  23545. // ID returns the ID value in the mutation. Note that the ID is only available
  23546. // if it was provided to the builder or after it was returned from the database.
  23547. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  23548. if m.id == nil {
  23549. return
  23550. }
  23551. return *m.id, true
  23552. }
  23553. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23554. // That means, if the mutation is applied within a transaction with an isolation level such
  23555. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23556. // or updated by the mutation.
  23557. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23558. switch {
  23559. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23560. id, exists := m.ID()
  23561. if exists {
  23562. return []uint64{id}, nil
  23563. }
  23564. fallthrough
  23565. case m.op.Is(OpUpdate | OpDelete):
  23566. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  23567. default:
  23568. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23569. }
  23570. }
  23571. // SetCreatedAt sets the "created_at" field.
  23572. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  23573. m.created_at = &t
  23574. }
  23575. // CreatedAt returns the value of the "created_at" field in the mutation.
  23576. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  23577. v := m.created_at
  23578. if v == nil {
  23579. return
  23580. }
  23581. return *v, true
  23582. }
  23583. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  23584. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23586. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23587. if !m.op.Is(OpUpdateOne) {
  23588. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23589. }
  23590. if m.id == nil || m.oldValue == nil {
  23591. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23592. }
  23593. oldValue, err := m.oldValue(ctx)
  23594. if err != nil {
  23595. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23596. }
  23597. return oldValue.CreatedAt, nil
  23598. }
  23599. // ResetCreatedAt resets all changes to the "created_at" field.
  23600. func (m *PayRechargeMutation) ResetCreatedAt() {
  23601. m.created_at = nil
  23602. }
  23603. // SetUpdatedAt sets the "updated_at" field.
  23604. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  23605. m.updated_at = &t
  23606. }
  23607. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23608. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  23609. v := m.updated_at
  23610. if v == nil {
  23611. return
  23612. }
  23613. return *v, true
  23614. }
  23615. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  23616. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23618. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23619. if !m.op.Is(OpUpdateOne) {
  23620. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23621. }
  23622. if m.id == nil || m.oldValue == nil {
  23623. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23624. }
  23625. oldValue, err := m.oldValue(ctx)
  23626. if err != nil {
  23627. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23628. }
  23629. return oldValue.UpdatedAt, nil
  23630. }
  23631. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23632. func (m *PayRechargeMutation) ResetUpdatedAt() {
  23633. m.updated_at = nil
  23634. }
  23635. // SetDeletedAt sets the "deleted_at" field.
  23636. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  23637. m.deleted_at = &t
  23638. }
  23639. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23640. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  23641. v := m.deleted_at
  23642. if v == nil {
  23643. return
  23644. }
  23645. return *v, true
  23646. }
  23647. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  23648. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23650. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23651. if !m.op.Is(OpUpdateOne) {
  23652. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23653. }
  23654. if m.id == nil || m.oldValue == nil {
  23655. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23656. }
  23657. oldValue, err := m.oldValue(ctx)
  23658. if err != nil {
  23659. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23660. }
  23661. return oldValue.DeletedAt, nil
  23662. }
  23663. // ClearDeletedAt clears the value of the "deleted_at" field.
  23664. func (m *PayRechargeMutation) ClearDeletedAt() {
  23665. m.deleted_at = nil
  23666. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  23667. }
  23668. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23669. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  23670. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  23671. return ok
  23672. }
  23673. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23674. func (m *PayRechargeMutation) ResetDeletedAt() {
  23675. m.deleted_at = nil
  23676. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  23677. }
  23678. // SetUserID sets the "user_id" field.
  23679. func (m *PayRechargeMutation) SetUserID(s string) {
  23680. m.user_id = &s
  23681. }
  23682. // UserID returns the value of the "user_id" field in the mutation.
  23683. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  23684. v := m.user_id
  23685. if v == nil {
  23686. return
  23687. }
  23688. return *v, true
  23689. }
  23690. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  23691. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23693. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  23694. if !m.op.Is(OpUpdateOne) {
  23695. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  23696. }
  23697. if m.id == nil || m.oldValue == nil {
  23698. return v, errors.New("OldUserID requires an ID field in the mutation")
  23699. }
  23700. oldValue, err := m.oldValue(ctx)
  23701. if err != nil {
  23702. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  23703. }
  23704. return oldValue.UserID, nil
  23705. }
  23706. // ResetUserID resets all changes to the "user_id" field.
  23707. func (m *PayRechargeMutation) ResetUserID() {
  23708. m.user_id = nil
  23709. }
  23710. // SetNumber sets the "number" field.
  23711. func (m *PayRechargeMutation) SetNumber(f float32) {
  23712. m.number = &f
  23713. m.addnumber = nil
  23714. }
  23715. // Number returns the value of the "number" field in the mutation.
  23716. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  23717. v := m.number
  23718. if v == nil {
  23719. return
  23720. }
  23721. return *v, true
  23722. }
  23723. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  23724. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23726. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  23727. if !m.op.Is(OpUpdateOne) {
  23728. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  23729. }
  23730. if m.id == nil || m.oldValue == nil {
  23731. return v, errors.New("OldNumber requires an ID field in the mutation")
  23732. }
  23733. oldValue, err := m.oldValue(ctx)
  23734. if err != nil {
  23735. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  23736. }
  23737. return oldValue.Number, nil
  23738. }
  23739. // AddNumber adds f to the "number" field.
  23740. func (m *PayRechargeMutation) AddNumber(f float32) {
  23741. if m.addnumber != nil {
  23742. *m.addnumber += f
  23743. } else {
  23744. m.addnumber = &f
  23745. }
  23746. }
  23747. // AddedNumber returns the value that was added to the "number" field in this mutation.
  23748. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  23749. v := m.addnumber
  23750. if v == nil {
  23751. return
  23752. }
  23753. return *v, true
  23754. }
  23755. // ResetNumber resets all changes to the "number" field.
  23756. func (m *PayRechargeMutation) ResetNumber() {
  23757. m.number = nil
  23758. m.addnumber = nil
  23759. }
  23760. // SetStatus sets the "status" field.
  23761. func (m *PayRechargeMutation) SetStatus(i int) {
  23762. m.status = &i
  23763. m.addstatus = nil
  23764. }
  23765. // Status returns the value of the "status" field in the mutation.
  23766. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  23767. v := m.status
  23768. if v == nil {
  23769. return
  23770. }
  23771. return *v, true
  23772. }
  23773. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  23774. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23776. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  23777. if !m.op.Is(OpUpdateOne) {
  23778. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23779. }
  23780. if m.id == nil || m.oldValue == nil {
  23781. return v, errors.New("OldStatus requires an ID field in the mutation")
  23782. }
  23783. oldValue, err := m.oldValue(ctx)
  23784. if err != nil {
  23785. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23786. }
  23787. return oldValue.Status, nil
  23788. }
  23789. // AddStatus adds i to the "status" field.
  23790. func (m *PayRechargeMutation) AddStatus(i int) {
  23791. if m.addstatus != nil {
  23792. *m.addstatus += i
  23793. } else {
  23794. m.addstatus = &i
  23795. }
  23796. }
  23797. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23798. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  23799. v := m.addstatus
  23800. if v == nil {
  23801. return
  23802. }
  23803. return *v, true
  23804. }
  23805. // ClearStatus clears the value of the "status" field.
  23806. func (m *PayRechargeMutation) ClearStatus() {
  23807. m.status = nil
  23808. m.addstatus = nil
  23809. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  23810. }
  23811. // StatusCleared returns if the "status" field was cleared in this mutation.
  23812. func (m *PayRechargeMutation) StatusCleared() bool {
  23813. _, ok := m.clearedFields[payrecharge.FieldStatus]
  23814. return ok
  23815. }
  23816. // ResetStatus resets all changes to the "status" field.
  23817. func (m *PayRechargeMutation) ResetStatus() {
  23818. m.status = nil
  23819. m.addstatus = nil
  23820. delete(m.clearedFields, payrecharge.FieldStatus)
  23821. }
  23822. // SetMoney sets the "money" field.
  23823. func (m *PayRechargeMutation) SetMoney(f float32) {
  23824. m.money = &f
  23825. m.addmoney = nil
  23826. }
  23827. // Money returns the value of the "money" field in the mutation.
  23828. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  23829. v := m.money
  23830. if v == nil {
  23831. return
  23832. }
  23833. return *v, true
  23834. }
  23835. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  23836. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23838. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  23839. if !m.op.Is(OpUpdateOne) {
  23840. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  23841. }
  23842. if m.id == nil || m.oldValue == nil {
  23843. return v, errors.New("OldMoney requires an ID field in the mutation")
  23844. }
  23845. oldValue, err := m.oldValue(ctx)
  23846. if err != nil {
  23847. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  23848. }
  23849. return oldValue.Money, nil
  23850. }
  23851. // AddMoney adds f to the "money" field.
  23852. func (m *PayRechargeMutation) AddMoney(f float32) {
  23853. if m.addmoney != nil {
  23854. *m.addmoney += f
  23855. } else {
  23856. m.addmoney = &f
  23857. }
  23858. }
  23859. // AddedMoney returns the value that was added to the "money" field in this mutation.
  23860. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  23861. v := m.addmoney
  23862. if v == nil {
  23863. return
  23864. }
  23865. return *v, true
  23866. }
  23867. // ClearMoney clears the value of the "money" field.
  23868. func (m *PayRechargeMutation) ClearMoney() {
  23869. m.money = nil
  23870. m.addmoney = nil
  23871. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  23872. }
  23873. // MoneyCleared returns if the "money" field was cleared in this mutation.
  23874. func (m *PayRechargeMutation) MoneyCleared() bool {
  23875. _, ok := m.clearedFields[payrecharge.FieldMoney]
  23876. return ok
  23877. }
  23878. // ResetMoney resets all changes to the "money" field.
  23879. func (m *PayRechargeMutation) ResetMoney() {
  23880. m.money = nil
  23881. m.addmoney = nil
  23882. delete(m.clearedFields, payrecharge.FieldMoney)
  23883. }
  23884. // SetOutTradeNo sets the "out_trade_no" field.
  23885. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  23886. m.out_trade_no = &s
  23887. }
  23888. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  23889. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  23890. v := m.out_trade_no
  23891. if v == nil {
  23892. return
  23893. }
  23894. return *v, true
  23895. }
  23896. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  23897. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23899. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  23900. if !m.op.Is(OpUpdateOne) {
  23901. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  23902. }
  23903. if m.id == nil || m.oldValue == nil {
  23904. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  23905. }
  23906. oldValue, err := m.oldValue(ctx)
  23907. if err != nil {
  23908. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  23909. }
  23910. return oldValue.OutTradeNo, nil
  23911. }
  23912. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  23913. func (m *PayRechargeMutation) ClearOutTradeNo() {
  23914. m.out_trade_no = nil
  23915. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  23916. }
  23917. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  23918. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  23919. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  23920. return ok
  23921. }
  23922. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  23923. func (m *PayRechargeMutation) ResetOutTradeNo() {
  23924. m.out_trade_no = nil
  23925. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  23926. }
  23927. // SetOrganizationID sets the "organization_id" field.
  23928. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  23929. m.organization_id = &u
  23930. m.addorganization_id = nil
  23931. }
  23932. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23933. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  23934. v := m.organization_id
  23935. if v == nil {
  23936. return
  23937. }
  23938. return *v, true
  23939. }
  23940. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  23941. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  23942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23943. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23944. if !m.op.Is(OpUpdateOne) {
  23945. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23946. }
  23947. if m.id == nil || m.oldValue == nil {
  23948. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23949. }
  23950. oldValue, err := m.oldValue(ctx)
  23951. if err != nil {
  23952. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23953. }
  23954. return oldValue.OrganizationID, nil
  23955. }
  23956. // AddOrganizationID adds u to the "organization_id" field.
  23957. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  23958. if m.addorganization_id != nil {
  23959. *m.addorganization_id += u
  23960. } else {
  23961. m.addorganization_id = &u
  23962. }
  23963. }
  23964. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23965. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  23966. v := m.addorganization_id
  23967. if v == nil {
  23968. return
  23969. }
  23970. return *v, true
  23971. }
  23972. // ResetOrganizationID resets all changes to the "organization_id" field.
  23973. func (m *PayRechargeMutation) ResetOrganizationID() {
  23974. m.organization_id = nil
  23975. m.addorganization_id = nil
  23976. }
  23977. // Where appends a list predicates to the PayRechargeMutation builder.
  23978. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  23979. m.predicates = append(m.predicates, ps...)
  23980. }
  23981. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  23982. // users can use type-assertion to append predicates that do not depend on any generated package.
  23983. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  23984. p := make([]predicate.PayRecharge, len(ps))
  23985. for i := range ps {
  23986. p[i] = ps[i]
  23987. }
  23988. m.Where(p...)
  23989. }
  23990. // Op returns the operation name.
  23991. func (m *PayRechargeMutation) Op() Op {
  23992. return m.op
  23993. }
  23994. // SetOp allows setting the mutation operation.
  23995. func (m *PayRechargeMutation) SetOp(op Op) {
  23996. m.op = op
  23997. }
  23998. // Type returns the node type of this mutation (PayRecharge).
  23999. func (m *PayRechargeMutation) Type() string {
  24000. return m.typ
  24001. }
  24002. // Fields returns all fields that were changed during this mutation. Note that in
  24003. // order to get all numeric fields that were incremented/decremented, call
  24004. // AddedFields().
  24005. func (m *PayRechargeMutation) Fields() []string {
  24006. fields := make([]string, 0, 9)
  24007. if m.created_at != nil {
  24008. fields = append(fields, payrecharge.FieldCreatedAt)
  24009. }
  24010. if m.updated_at != nil {
  24011. fields = append(fields, payrecharge.FieldUpdatedAt)
  24012. }
  24013. if m.deleted_at != nil {
  24014. fields = append(fields, payrecharge.FieldDeletedAt)
  24015. }
  24016. if m.user_id != nil {
  24017. fields = append(fields, payrecharge.FieldUserID)
  24018. }
  24019. if m.number != nil {
  24020. fields = append(fields, payrecharge.FieldNumber)
  24021. }
  24022. if m.status != nil {
  24023. fields = append(fields, payrecharge.FieldStatus)
  24024. }
  24025. if m.money != nil {
  24026. fields = append(fields, payrecharge.FieldMoney)
  24027. }
  24028. if m.out_trade_no != nil {
  24029. fields = append(fields, payrecharge.FieldOutTradeNo)
  24030. }
  24031. if m.organization_id != nil {
  24032. fields = append(fields, payrecharge.FieldOrganizationID)
  24033. }
  24034. return fields
  24035. }
  24036. // Field returns the value of a field with the given name. The second boolean
  24037. // return value indicates that this field was not set, or was not defined in the
  24038. // schema.
  24039. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  24040. switch name {
  24041. case payrecharge.FieldCreatedAt:
  24042. return m.CreatedAt()
  24043. case payrecharge.FieldUpdatedAt:
  24044. return m.UpdatedAt()
  24045. case payrecharge.FieldDeletedAt:
  24046. return m.DeletedAt()
  24047. case payrecharge.FieldUserID:
  24048. return m.UserID()
  24049. case payrecharge.FieldNumber:
  24050. return m.Number()
  24051. case payrecharge.FieldStatus:
  24052. return m.Status()
  24053. case payrecharge.FieldMoney:
  24054. return m.Money()
  24055. case payrecharge.FieldOutTradeNo:
  24056. return m.OutTradeNo()
  24057. case payrecharge.FieldOrganizationID:
  24058. return m.OrganizationID()
  24059. }
  24060. return nil, false
  24061. }
  24062. // OldField returns the old value of the field from the database. An error is
  24063. // returned if the mutation operation is not UpdateOne, or the query to the
  24064. // database failed.
  24065. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24066. switch name {
  24067. case payrecharge.FieldCreatedAt:
  24068. return m.OldCreatedAt(ctx)
  24069. case payrecharge.FieldUpdatedAt:
  24070. return m.OldUpdatedAt(ctx)
  24071. case payrecharge.FieldDeletedAt:
  24072. return m.OldDeletedAt(ctx)
  24073. case payrecharge.FieldUserID:
  24074. return m.OldUserID(ctx)
  24075. case payrecharge.FieldNumber:
  24076. return m.OldNumber(ctx)
  24077. case payrecharge.FieldStatus:
  24078. return m.OldStatus(ctx)
  24079. case payrecharge.FieldMoney:
  24080. return m.OldMoney(ctx)
  24081. case payrecharge.FieldOutTradeNo:
  24082. return m.OldOutTradeNo(ctx)
  24083. case payrecharge.FieldOrganizationID:
  24084. return m.OldOrganizationID(ctx)
  24085. }
  24086. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  24087. }
  24088. // SetField sets the value of a field with the given name. It returns an error if
  24089. // the field is not defined in the schema, or if the type mismatched the field
  24090. // type.
  24091. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  24092. switch name {
  24093. case payrecharge.FieldCreatedAt:
  24094. v, ok := value.(time.Time)
  24095. if !ok {
  24096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24097. }
  24098. m.SetCreatedAt(v)
  24099. return nil
  24100. case payrecharge.FieldUpdatedAt:
  24101. v, ok := value.(time.Time)
  24102. if !ok {
  24103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24104. }
  24105. m.SetUpdatedAt(v)
  24106. return nil
  24107. case payrecharge.FieldDeletedAt:
  24108. v, ok := value.(time.Time)
  24109. if !ok {
  24110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24111. }
  24112. m.SetDeletedAt(v)
  24113. return nil
  24114. case payrecharge.FieldUserID:
  24115. v, ok := value.(string)
  24116. if !ok {
  24117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24118. }
  24119. m.SetUserID(v)
  24120. return nil
  24121. case payrecharge.FieldNumber:
  24122. v, ok := value.(float32)
  24123. if !ok {
  24124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24125. }
  24126. m.SetNumber(v)
  24127. return nil
  24128. case payrecharge.FieldStatus:
  24129. v, ok := value.(int)
  24130. if !ok {
  24131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24132. }
  24133. m.SetStatus(v)
  24134. return nil
  24135. case payrecharge.FieldMoney:
  24136. v, ok := value.(float32)
  24137. if !ok {
  24138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24139. }
  24140. m.SetMoney(v)
  24141. return nil
  24142. case payrecharge.FieldOutTradeNo:
  24143. v, ok := value.(string)
  24144. if !ok {
  24145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24146. }
  24147. m.SetOutTradeNo(v)
  24148. return nil
  24149. case payrecharge.FieldOrganizationID:
  24150. v, ok := value.(uint64)
  24151. if !ok {
  24152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24153. }
  24154. m.SetOrganizationID(v)
  24155. return nil
  24156. }
  24157. return fmt.Errorf("unknown PayRecharge field %s", name)
  24158. }
  24159. // AddedFields returns all numeric fields that were incremented/decremented during
  24160. // this mutation.
  24161. func (m *PayRechargeMutation) AddedFields() []string {
  24162. var fields []string
  24163. if m.addnumber != nil {
  24164. fields = append(fields, payrecharge.FieldNumber)
  24165. }
  24166. if m.addstatus != nil {
  24167. fields = append(fields, payrecharge.FieldStatus)
  24168. }
  24169. if m.addmoney != nil {
  24170. fields = append(fields, payrecharge.FieldMoney)
  24171. }
  24172. if m.addorganization_id != nil {
  24173. fields = append(fields, payrecharge.FieldOrganizationID)
  24174. }
  24175. return fields
  24176. }
  24177. // AddedField returns the numeric value that was incremented/decremented on a field
  24178. // with the given name. The second boolean return value indicates that this field
  24179. // was not set, or was not defined in the schema.
  24180. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  24181. switch name {
  24182. case payrecharge.FieldNumber:
  24183. return m.AddedNumber()
  24184. case payrecharge.FieldStatus:
  24185. return m.AddedStatus()
  24186. case payrecharge.FieldMoney:
  24187. return m.AddedMoney()
  24188. case payrecharge.FieldOrganizationID:
  24189. return m.AddedOrganizationID()
  24190. }
  24191. return nil, false
  24192. }
  24193. // AddField adds the value to the field with the given name. It returns an error if
  24194. // the field is not defined in the schema, or if the type mismatched the field
  24195. // type.
  24196. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  24197. switch name {
  24198. case payrecharge.FieldNumber:
  24199. v, ok := value.(float32)
  24200. if !ok {
  24201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24202. }
  24203. m.AddNumber(v)
  24204. return nil
  24205. case payrecharge.FieldStatus:
  24206. v, ok := value.(int)
  24207. if !ok {
  24208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24209. }
  24210. m.AddStatus(v)
  24211. return nil
  24212. case payrecharge.FieldMoney:
  24213. v, ok := value.(float32)
  24214. if !ok {
  24215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24216. }
  24217. m.AddMoney(v)
  24218. return nil
  24219. case payrecharge.FieldOrganizationID:
  24220. v, ok := value.(int64)
  24221. if !ok {
  24222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24223. }
  24224. m.AddOrganizationID(v)
  24225. return nil
  24226. }
  24227. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  24228. }
  24229. // ClearedFields returns all nullable fields that were cleared during this
  24230. // mutation.
  24231. func (m *PayRechargeMutation) ClearedFields() []string {
  24232. var fields []string
  24233. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  24234. fields = append(fields, payrecharge.FieldDeletedAt)
  24235. }
  24236. if m.FieldCleared(payrecharge.FieldStatus) {
  24237. fields = append(fields, payrecharge.FieldStatus)
  24238. }
  24239. if m.FieldCleared(payrecharge.FieldMoney) {
  24240. fields = append(fields, payrecharge.FieldMoney)
  24241. }
  24242. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  24243. fields = append(fields, payrecharge.FieldOutTradeNo)
  24244. }
  24245. return fields
  24246. }
  24247. // FieldCleared returns a boolean indicating if a field with the given name was
  24248. // cleared in this mutation.
  24249. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  24250. _, ok := m.clearedFields[name]
  24251. return ok
  24252. }
  24253. // ClearField clears the value of the field with the given name. It returns an
  24254. // error if the field is not defined in the schema.
  24255. func (m *PayRechargeMutation) ClearField(name string) error {
  24256. switch name {
  24257. case payrecharge.FieldDeletedAt:
  24258. m.ClearDeletedAt()
  24259. return nil
  24260. case payrecharge.FieldStatus:
  24261. m.ClearStatus()
  24262. return nil
  24263. case payrecharge.FieldMoney:
  24264. m.ClearMoney()
  24265. return nil
  24266. case payrecharge.FieldOutTradeNo:
  24267. m.ClearOutTradeNo()
  24268. return nil
  24269. }
  24270. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  24271. }
  24272. // ResetField resets all changes in the mutation for the field with the given name.
  24273. // It returns an error if the field is not defined in the schema.
  24274. func (m *PayRechargeMutation) ResetField(name string) error {
  24275. switch name {
  24276. case payrecharge.FieldCreatedAt:
  24277. m.ResetCreatedAt()
  24278. return nil
  24279. case payrecharge.FieldUpdatedAt:
  24280. m.ResetUpdatedAt()
  24281. return nil
  24282. case payrecharge.FieldDeletedAt:
  24283. m.ResetDeletedAt()
  24284. return nil
  24285. case payrecharge.FieldUserID:
  24286. m.ResetUserID()
  24287. return nil
  24288. case payrecharge.FieldNumber:
  24289. m.ResetNumber()
  24290. return nil
  24291. case payrecharge.FieldStatus:
  24292. m.ResetStatus()
  24293. return nil
  24294. case payrecharge.FieldMoney:
  24295. m.ResetMoney()
  24296. return nil
  24297. case payrecharge.FieldOutTradeNo:
  24298. m.ResetOutTradeNo()
  24299. return nil
  24300. case payrecharge.FieldOrganizationID:
  24301. m.ResetOrganizationID()
  24302. return nil
  24303. }
  24304. return fmt.Errorf("unknown PayRecharge field %s", name)
  24305. }
  24306. // AddedEdges returns all edge names that were set/added in this mutation.
  24307. func (m *PayRechargeMutation) AddedEdges() []string {
  24308. edges := make([]string, 0, 0)
  24309. return edges
  24310. }
  24311. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24312. // name in this mutation.
  24313. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  24314. return nil
  24315. }
  24316. // RemovedEdges returns all edge names that were removed in this mutation.
  24317. func (m *PayRechargeMutation) RemovedEdges() []string {
  24318. edges := make([]string, 0, 0)
  24319. return edges
  24320. }
  24321. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24322. // the given name in this mutation.
  24323. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  24324. return nil
  24325. }
  24326. // ClearedEdges returns all edge names that were cleared in this mutation.
  24327. func (m *PayRechargeMutation) ClearedEdges() []string {
  24328. edges := make([]string, 0, 0)
  24329. return edges
  24330. }
  24331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24332. // was cleared in this mutation.
  24333. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  24334. return false
  24335. }
  24336. // ClearEdge clears the value of the edge with the given name. It returns an error
  24337. // if that edge is not defined in the schema.
  24338. func (m *PayRechargeMutation) ClearEdge(name string) error {
  24339. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  24340. }
  24341. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24342. // It returns an error if the edge is not defined in the schema.
  24343. func (m *PayRechargeMutation) ResetEdge(name string) error {
  24344. return fmt.Errorf("unknown PayRecharge edge %s", name)
  24345. }
  24346. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  24347. type ServerMutation struct {
  24348. config
  24349. op Op
  24350. typ string
  24351. id *uint64
  24352. created_at *time.Time
  24353. updated_at *time.Time
  24354. status *uint8
  24355. addstatus *int8
  24356. deleted_at *time.Time
  24357. name *string
  24358. public_ip *string
  24359. private_ip *string
  24360. admin_port *string
  24361. clearedFields map[string]struct{}
  24362. wxs map[uint64]struct{}
  24363. removedwxs map[uint64]struct{}
  24364. clearedwxs bool
  24365. done bool
  24366. oldValue func(context.Context) (*Server, error)
  24367. predicates []predicate.Server
  24368. }
  24369. var _ ent.Mutation = (*ServerMutation)(nil)
  24370. // serverOption allows management of the mutation configuration using functional options.
  24371. type serverOption func(*ServerMutation)
  24372. // newServerMutation creates new mutation for the Server entity.
  24373. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  24374. m := &ServerMutation{
  24375. config: c,
  24376. op: op,
  24377. typ: TypeServer,
  24378. clearedFields: make(map[string]struct{}),
  24379. }
  24380. for _, opt := range opts {
  24381. opt(m)
  24382. }
  24383. return m
  24384. }
  24385. // withServerID sets the ID field of the mutation.
  24386. func withServerID(id uint64) serverOption {
  24387. return func(m *ServerMutation) {
  24388. var (
  24389. err error
  24390. once sync.Once
  24391. value *Server
  24392. )
  24393. m.oldValue = func(ctx context.Context) (*Server, error) {
  24394. once.Do(func() {
  24395. if m.done {
  24396. err = errors.New("querying old values post mutation is not allowed")
  24397. } else {
  24398. value, err = m.Client().Server.Get(ctx, id)
  24399. }
  24400. })
  24401. return value, err
  24402. }
  24403. m.id = &id
  24404. }
  24405. }
  24406. // withServer sets the old Server of the mutation.
  24407. func withServer(node *Server) serverOption {
  24408. return func(m *ServerMutation) {
  24409. m.oldValue = func(context.Context) (*Server, error) {
  24410. return node, nil
  24411. }
  24412. m.id = &node.ID
  24413. }
  24414. }
  24415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24416. // executed in a transaction (ent.Tx), a transactional client is returned.
  24417. func (m ServerMutation) Client() *Client {
  24418. client := &Client{config: m.config}
  24419. client.init()
  24420. return client
  24421. }
  24422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24423. // it returns an error otherwise.
  24424. func (m ServerMutation) Tx() (*Tx, error) {
  24425. if _, ok := m.driver.(*txDriver); !ok {
  24426. return nil, errors.New("ent: mutation is not running in a transaction")
  24427. }
  24428. tx := &Tx{config: m.config}
  24429. tx.init()
  24430. return tx, nil
  24431. }
  24432. // SetID sets the value of the id field. Note that this
  24433. // operation is only accepted on creation of Server entities.
  24434. func (m *ServerMutation) SetID(id uint64) {
  24435. m.id = &id
  24436. }
  24437. // ID returns the ID value in the mutation. Note that the ID is only available
  24438. // if it was provided to the builder or after it was returned from the database.
  24439. func (m *ServerMutation) ID() (id uint64, exists bool) {
  24440. if m.id == nil {
  24441. return
  24442. }
  24443. return *m.id, true
  24444. }
  24445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24446. // That means, if the mutation is applied within a transaction with an isolation level such
  24447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24448. // or updated by the mutation.
  24449. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  24450. switch {
  24451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24452. id, exists := m.ID()
  24453. if exists {
  24454. return []uint64{id}, nil
  24455. }
  24456. fallthrough
  24457. case m.op.Is(OpUpdate | OpDelete):
  24458. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  24459. default:
  24460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24461. }
  24462. }
  24463. // SetCreatedAt sets the "created_at" field.
  24464. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  24465. m.created_at = &t
  24466. }
  24467. // CreatedAt returns the value of the "created_at" field in the mutation.
  24468. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  24469. v := m.created_at
  24470. if v == nil {
  24471. return
  24472. }
  24473. return *v, true
  24474. }
  24475. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  24476. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24478. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24479. if !m.op.Is(OpUpdateOne) {
  24480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24481. }
  24482. if m.id == nil || m.oldValue == nil {
  24483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24484. }
  24485. oldValue, err := m.oldValue(ctx)
  24486. if err != nil {
  24487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24488. }
  24489. return oldValue.CreatedAt, nil
  24490. }
  24491. // ResetCreatedAt resets all changes to the "created_at" field.
  24492. func (m *ServerMutation) ResetCreatedAt() {
  24493. m.created_at = nil
  24494. }
  24495. // SetUpdatedAt sets the "updated_at" field.
  24496. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  24497. m.updated_at = &t
  24498. }
  24499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24500. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  24501. v := m.updated_at
  24502. if v == nil {
  24503. return
  24504. }
  24505. return *v, true
  24506. }
  24507. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  24508. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24510. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24511. if !m.op.Is(OpUpdateOne) {
  24512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24513. }
  24514. if m.id == nil || m.oldValue == nil {
  24515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24516. }
  24517. oldValue, err := m.oldValue(ctx)
  24518. if err != nil {
  24519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24520. }
  24521. return oldValue.UpdatedAt, nil
  24522. }
  24523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24524. func (m *ServerMutation) ResetUpdatedAt() {
  24525. m.updated_at = nil
  24526. }
  24527. // SetStatus sets the "status" field.
  24528. func (m *ServerMutation) SetStatus(u uint8) {
  24529. m.status = &u
  24530. m.addstatus = nil
  24531. }
  24532. // Status returns the value of the "status" field in the mutation.
  24533. func (m *ServerMutation) Status() (r uint8, exists bool) {
  24534. v := m.status
  24535. if v == nil {
  24536. return
  24537. }
  24538. return *v, true
  24539. }
  24540. // OldStatus returns the old "status" field's value of the Server entity.
  24541. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24543. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24544. if !m.op.Is(OpUpdateOne) {
  24545. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24546. }
  24547. if m.id == nil || m.oldValue == nil {
  24548. return v, errors.New("OldStatus requires an ID field in the mutation")
  24549. }
  24550. oldValue, err := m.oldValue(ctx)
  24551. if err != nil {
  24552. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24553. }
  24554. return oldValue.Status, nil
  24555. }
  24556. // AddStatus adds u to the "status" field.
  24557. func (m *ServerMutation) AddStatus(u int8) {
  24558. if m.addstatus != nil {
  24559. *m.addstatus += u
  24560. } else {
  24561. m.addstatus = &u
  24562. }
  24563. }
  24564. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24565. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  24566. v := m.addstatus
  24567. if v == nil {
  24568. return
  24569. }
  24570. return *v, true
  24571. }
  24572. // ClearStatus clears the value of the "status" field.
  24573. func (m *ServerMutation) ClearStatus() {
  24574. m.status = nil
  24575. m.addstatus = nil
  24576. m.clearedFields[server.FieldStatus] = struct{}{}
  24577. }
  24578. // StatusCleared returns if the "status" field was cleared in this mutation.
  24579. func (m *ServerMutation) StatusCleared() bool {
  24580. _, ok := m.clearedFields[server.FieldStatus]
  24581. return ok
  24582. }
  24583. // ResetStatus resets all changes to the "status" field.
  24584. func (m *ServerMutation) ResetStatus() {
  24585. m.status = nil
  24586. m.addstatus = nil
  24587. delete(m.clearedFields, server.FieldStatus)
  24588. }
  24589. // SetDeletedAt sets the "deleted_at" field.
  24590. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  24591. m.deleted_at = &t
  24592. }
  24593. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24594. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  24595. v := m.deleted_at
  24596. if v == nil {
  24597. return
  24598. }
  24599. return *v, true
  24600. }
  24601. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  24602. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24604. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24605. if !m.op.Is(OpUpdateOne) {
  24606. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24607. }
  24608. if m.id == nil || m.oldValue == nil {
  24609. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24610. }
  24611. oldValue, err := m.oldValue(ctx)
  24612. if err != nil {
  24613. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24614. }
  24615. return oldValue.DeletedAt, nil
  24616. }
  24617. // ClearDeletedAt clears the value of the "deleted_at" field.
  24618. func (m *ServerMutation) ClearDeletedAt() {
  24619. m.deleted_at = nil
  24620. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  24621. }
  24622. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24623. func (m *ServerMutation) DeletedAtCleared() bool {
  24624. _, ok := m.clearedFields[server.FieldDeletedAt]
  24625. return ok
  24626. }
  24627. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24628. func (m *ServerMutation) ResetDeletedAt() {
  24629. m.deleted_at = nil
  24630. delete(m.clearedFields, server.FieldDeletedAt)
  24631. }
  24632. // SetName sets the "name" field.
  24633. func (m *ServerMutation) SetName(s string) {
  24634. m.name = &s
  24635. }
  24636. // Name returns the value of the "name" field in the mutation.
  24637. func (m *ServerMutation) Name() (r string, exists bool) {
  24638. v := m.name
  24639. if v == nil {
  24640. return
  24641. }
  24642. return *v, true
  24643. }
  24644. // OldName returns the old "name" field's value of the Server entity.
  24645. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24647. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  24648. if !m.op.Is(OpUpdateOne) {
  24649. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24650. }
  24651. if m.id == nil || m.oldValue == nil {
  24652. return v, errors.New("OldName requires an ID field in the mutation")
  24653. }
  24654. oldValue, err := m.oldValue(ctx)
  24655. if err != nil {
  24656. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24657. }
  24658. return oldValue.Name, nil
  24659. }
  24660. // ResetName resets all changes to the "name" field.
  24661. func (m *ServerMutation) ResetName() {
  24662. m.name = nil
  24663. }
  24664. // SetPublicIP sets the "public_ip" field.
  24665. func (m *ServerMutation) SetPublicIP(s string) {
  24666. m.public_ip = &s
  24667. }
  24668. // PublicIP returns the value of the "public_ip" field in the mutation.
  24669. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  24670. v := m.public_ip
  24671. if v == nil {
  24672. return
  24673. }
  24674. return *v, true
  24675. }
  24676. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  24677. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24679. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  24680. if !m.op.Is(OpUpdateOne) {
  24681. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  24682. }
  24683. if m.id == nil || m.oldValue == nil {
  24684. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  24685. }
  24686. oldValue, err := m.oldValue(ctx)
  24687. if err != nil {
  24688. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  24689. }
  24690. return oldValue.PublicIP, nil
  24691. }
  24692. // ResetPublicIP resets all changes to the "public_ip" field.
  24693. func (m *ServerMutation) ResetPublicIP() {
  24694. m.public_ip = nil
  24695. }
  24696. // SetPrivateIP sets the "private_ip" field.
  24697. func (m *ServerMutation) SetPrivateIP(s string) {
  24698. m.private_ip = &s
  24699. }
  24700. // PrivateIP returns the value of the "private_ip" field in the mutation.
  24701. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  24702. v := m.private_ip
  24703. if v == nil {
  24704. return
  24705. }
  24706. return *v, true
  24707. }
  24708. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  24709. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24711. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  24712. if !m.op.Is(OpUpdateOne) {
  24713. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  24714. }
  24715. if m.id == nil || m.oldValue == nil {
  24716. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  24717. }
  24718. oldValue, err := m.oldValue(ctx)
  24719. if err != nil {
  24720. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  24721. }
  24722. return oldValue.PrivateIP, nil
  24723. }
  24724. // ResetPrivateIP resets all changes to the "private_ip" field.
  24725. func (m *ServerMutation) ResetPrivateIP() {
  24726. m.private_ip = nil
  24727. }
  24728. // SetAdminPort sets the "admin_port" field.
  24729. func (m *ServerMutation) SetAdminPort(s string) {
  24730. m.admin_port = &s
  24731. }
  24732. // AdminPort returns the value of the "admin_port" field in the mutation.
  24733. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  24734. v := m.admin_port
  24735. if v == nil {
  24736. return
  24737. }
  24738. return *v, true
  24739. }
  24740. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  24741. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  24742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24743. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  24744. if !m.op.Is(OpUpdateOne) {
  24745. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  24746. }
  24747. if m.id == nil || m.oldValue == nil {
  24748. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  24749. }
  24750. oldValue, err := m.oldValue(ctx)
  24751. if err != nil {
  24752. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  24753. }
  24754. return oldValue.AdminPort, nil
  24755. }
  24756. // ResetAdminPort resets all changes to the "admin_port" field.
  24757. func (m *ServerMutation) ResetAdminPort() {
  24758. m.admin_port = nil
  24759. }
  24760. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  24761. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  24762. if m.wxs == nil {
  24763. m.wxs = make(map[uint64]struct{})
  24764. }
  24765. for i := range ids {
  24766. m.wxs[ids[i]] = struct{}{}
  24767. }
  24768. }
  24769. // ClearWxs clears the "wxs" edge to the Wx entity.
  24770. func (m *ServerMutation) ClearWxs() {
  24771. m.clearedwxs = true
  24772. }
  24773. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  24774. func (m *ServerMutation) WxsCleared() bool {
  24775. return m.clearedwxs
  24776. }
  24777. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  24778. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  24779. if m.removedwxs == nil {
  24780. m.removedwxs = make(map[uint64]struct{})
  24781. }
  24782. for i := range ids {
  24783. delete(m.wxs, ids[i])
  24784. m.removedwxs[ids[i]] = struct{}{}
  24785. }
  24786. }
  24787. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  24788. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  24789. for id := range m.removedwxs {
  24790. ids = append(ids, id)
  24791. }
  24792. return
  24793. }
  24794. // WxsIDs returns the "wxs" edge IDs in the mutation.
  24795. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  24796. for id := range m.wxs {
  24797. ids = append(ids, id)
  24798. }
  24799. return
  24800. }
  24801. // ResetWxs resets all changes to the "wxs" edge.
  24802. func (m *ServerMutation) ResetWxs() {
  24803. m.wxs = nil
  24804. m.clearedwxs = false
  24805. m.removedwxs = nil
  24806. }
  24807. // Where appends a list predicates to the ServerMutation builder.
  24808. func (m *ServerMutation) Where(ps ...predicate.Server) {
  24809. m.predicates = append(m.predicates, ps...)
  24810. }
  24811. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  24812. // users can use type-assertion to append predicates that do not depend on any generated package.
  24813. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  24814. p := make([]predicate.Server, len(ps))
  24815. for i := range ps {
  24816. p[i] = ps[i]
  24817. }
  24818. m.Where(p...)
  24819. }
  24820. // Op returns the operation name.
  24821. func (m *ServerMutation) Op() Op {
  24822. return m.op
  24823. }
  24824. // SetOp allows setting the mutation operation.
  24825. func (m *ServerMutation) SetOp(op Op) {
  24826. m.op = op
  24827. }
  24828. // Type returns the node type of this mutation (Server).
  24829. func (m *ServerMutation) Type() string {
  24830. return m.typ
  24831. }
  24832. // Fields returns all fields that were changed during this mutation. Note that in
  24833. // order to get all numeric fields that were incremented/decremented, call
  24834. // AddedFields().
  24835. func (m *ServerMutation) Fields() []string {
  24836. fields := make([]string, 0, 8)
  24837. if m.created_at != nil {
  24838. fields = append(fields, server.FieldCreatedAt)
  24839. }
  24840. if m.updated_at != nil {
  24841. fields = append(fields, server.FieldUpdatedAt)
  24842. }
  24843. if m.status != nil {
  24844. fields = append(fields, server.FieldStatus)
  24845. }
  24846. if m.deleted_at != nil {
  24847. fields = append(fields, server.FieldDeletedAt)
  24848. }
  24849. if m.name != nil {
  24850. fields = append(fields, server.FieldName)
  24851. }
  24852. if m.public_ip != nil {
  24853. fields = append(fields, server.FieldPublicIP)
  24854. }
  24855. if m.private_ip != nil {
  24856. fields = append(fields, server.FieldPrivateIP)
  24857. }
  24858. if m.admin_port != nil {
  24859. fields = append(fields, server.FieldAdminPort)
  24860. }
  24861. return fields
  24862. }
  24863. // Field returns the value of a field with the given name. The second boolean
  24864. // return value indicates that this field was not set, or was not defined in the
  24865. // schema.
  24866. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  24867. switch name {
  24868. case server.FieldCreatedAt:
  24869. return m.CreatedAt()
  24870. case server.FieldUpdatedAt:
  24871. return m.UpdatedAt()
  24872. case server.FieldStatus:
  24873. return m.Status()
  24874. case server.FieldDeletedAt:
  24875. return m.DeletedAt()
  24876. case server.FieldName:
  24877. return m.Name()
  24878. case server.FieldPublicIP:
  24879. return m.PublicIP()
  24880. case server.FieldPrivateIP:
  24881. return m.PrivateIP()
  24882. case server.FieldAdminPort:
  24883. return m.AdminPort()
  24884. }
  24885. return nil, false
  24886. }
  24887. // OldField returns the old value of the field from the database. An error is
  24888. // returned if the mutation operation is not UpdateOne, or the query to the
  24889. // database failed.
  24890. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24891. switch name {
  24892. case server.FieldCreatedAt:
  24893. return m.OldCreatedAt(ctx)
  24894. case server.FieldUpdatedAt:
  24895. return m.OldUpdatedAt(ctx)
  24896. case server.FieldStatus:
  24897. return m.OldStatus(ctx)
  24898. case server.FieldDeletedAt:
  24899. return m.OldDeletedAt(ctx)
  24900. case server.FieldName:
  24901. return m.OldName(ctx)
  24902. case server.FieldPublicIP:
  24903. return m.OldPublicIP(ctx)
  24904. case server.FieldPrivateIP:
  24905. return m.OldPrivateIP(ctx)
  24906. case server.FieldAdminPort:
  24907. return m.OldAdminPort(ctx)
  24908. }
  24909. return nil, fmt.Errorf("unknown Server field %s", name)
  24910. }
  24911. // SetField sets the value of a field with the given name. It returns an error if
  24912. // the field is not defined in the schema, or if the type mismatched the field
  24913. // type.
  24914. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  24915. switch name {
  24916. case server.FieldCreatedAt:
  24917. v, ok := value.(time.Time)
  24918. if !ok {
  24919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24920. }
  24921. m.SetCreatedAt(v)
  24922. return nil
  24923. case server.FieldUpdatedAt:
  24924. v, ok := value.(time.Time)
  24925. if !ok {
  24926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24927. }
  24928. m.SetUpdatedAt(v)
  24929. return nil
  24930. case server.FieldStatus:
  24931. v, ok := value.(uint8)
  24932. if !ok {
  24933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24934. }
  24935. m.SetStatus(v)
  24936. return nil
  24937. case server.FieldDeletedAt:
  24938. v, ok := value.(time.Time)
  24939. if !ok {
  24940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24941. }
  24942. m.SetDeletedAt(v)
  24943. return nil
  24944. case server.FieldName:
  24945. v, ok := value.(string)
  24946. if !ok {
  24947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24948. }
  24949. m.SetName(v)
  24950. return nil
  24951. case server.FieldPublicIP:
  24952. v, ok := value.(string)
  24953. if !ok {
  24954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24955. }
  24956. m.SetPublicIP(v)
  24957. return nil
  24958. case server.FieldPrivateIP:
  24959. v, ok := value.(string)
  24960. if !ok {
  24961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24962. }
  24963. m.SetPrivateIP(v)
  24964. return nil
  24965. case server.FieldAdminPort:
  24966. v, ok := value.(string)
  24967. if !ok {
  24968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24969. }
  24970. m.SetAdminPort(v)
  24971. return nil
  24972. }
  24973. return fmt.Errorf("unknown Server field %s", name)
  24974. }
  24975. // AddedFields returns all numeric fields that were incremented/decremented during
  24976. // this mutation.
  24977. func (m *ServerMutation) AddedFields() []string {
  24978. var fields []string
  24979. if m.addstatus != nil {
  24980. fields = append(fields, server.FieldStatus)
  24981. }
  24982. return fields
  24983. }
  24984. // AddedField returns the numeric value that was incremented/decremented on a field
  24985. // with the given name. The second boolean return value indicates that this field
  24986. // was not set, or was not defined in the schema.
  24987. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  24988. switch name {
  24989. case server.FieldStatus:
  24990. return m.AddedStatus()
  24991. }
  24992. return nil, false
  24993. }
  24994. // AddField adds the value to the field with the given name. It returns an error if
  24995. // the field is not defined in the schema, or if the type mismatched the field
  24996. // type.
  24997. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  24998. switch name {
  24999. case server.FieldStatus:
  25000. v, ok := value.(int8)
  25001. if !ok {
  25002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25003. }
  25004. m.AddStatus(v)
  25005. return nil
  25006. }
  25007. return fmt.Errorf("unknown Server numeric field %s", name)
  25008. }
  25009. // ClearedFields returns all nullable fields that were cleared during this
  25010. // mutation.
  25011. func (m *ServerMutation) ClearedFields() []string {
  25012. var fields []string
  25013. if m.FieldCleared(server.FieldStatus) {
  25014. fields = append(fields, server.FieldStatus)
  25015. }
  25016. if m.FieldCleared(server.FieldDeletedAt) {
  25017. fields = append(fields, server.FieldDeletedAt)
  25018. }
  25019. return fields
  25020. }
  25021. // FieldCleared returns a boolean indicating if a field with the given name was
  25022. // cleared in this mutation.
  25023. func (m *ServerMutation) FieldCleared(name string) bool {
  25024. _, ok := m.clearedFields[name]
  25025. return ok
  25026. }
  25027. // ClearField clears the value of the field with the given name. It returns an
  25028. // error if the field is not defined in the schema.
  25029. func (m *ServerMutation) ClearField(name string) error {
  25030. switch name {
  25031. case server.FieldStatus:
  25032. m.ClearStatus()
  25033. return nil
  25034. case server.FieldDeletedAt:
  25035. m.ClearDeletedAt()
  25036. return nil
  25037. }
  25038. return fmt.Errorf("unknown Server nullable field %s", name)
  25039. }
  25040. // ResetField resets all changes in the mutation for the field with the given name.
  25041. // It returns an error if the field is not defined in the schema.
  25042. func (m *ServerMutation) ResetField(name string) error {
  25043. switch name {
  25044. case server.FieldCreatedAt:
  25045. m.ResetCreatedAt()
  25046. return nil
  25047. case server.FieldUpdatedAt:
  25048. m.ResetUpdatedAt()
  25049. return nil
  25050. case server.FieldStatus:
  25051. m.ResetStatus()
  25052. return nil
  25053. case server.FieldDeletedAt:
  25054. m.ResetDeletedAt()
  25055. return nil
  25056. case server.FieldName:
  25057. m.ResetName()
  25058. return nil
  25059. case server.FieldPublicIP:
  25060. m.ResetPublicIP()
  25061. return nil
  25062. case server.FieldPrivateIP:
  25063. m.ResetPrivateIP()
  25064. return nil
  25065. case server.FieldAdminPort:
  25066. m.ResetAdminPort()
  25067. return nil
  25068. }
  25069. return fmt.Errorf("unknown Server field %s", name)
  25070. }
  25071. // AddedEdges returns all edge names that were set/added in this mutation.
  25072. func (m *ServerMutation) AddedEdges() []string {
  25073. edges := make([]string, 0, 1)
  25074. if m.wxs != nil {
  25075. edges = append(edges, server.EdgeWxs)
  25076. }
  25077. return edges
  25078. }
  25079. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25080. // name in this mutation.
  25081. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  25082. switch name {
  25083. case server.EdgeWxs:
  25084. ids := make([]ent.Value, 0, len(m.wxs))
  25085. for id := range m.wxs {
  25086. ids = append(ids, id)
  25087. }
  25088. return ids
  25089. }
  25090. return nil
  25091. }
  25092. // RemovedEdges returns all edge names that were removed in this mutation.
  25093. func (m *ServerMutation) RemovedEdges() []string {
  25094. edges := make([]string, 0, 1)
  25095. if m.removedwxs != nil {
  25096. edges = append(edges, server.EdgeWxs)
  25097. }
  25098. return edges
  25099. }
  25100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25101. // the given name in this mutation.
  25102. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  25103. switch name {
  25104. case server.EdgeWxs:
  25105. ids := make([]ent.Value, 0, len(m.removedwxs))
  25106. for id := range m.removedwxs {
  25107. ids = append(ids, id)
  25108. }
  25109. return ids
  25110. }
  25111. return nil
  25112. }
  25113. // ClearedEdges returns all edge names that were cleared in this mutation.
  25114. func (m *ServerMutation) ClearedEdges() []string {
  25115. edges := make([]string, 0, 1)
  25116. if m.clearedwxs {
  25117. edges = append(edges, server.EdgeWxs)
  25118. }
  25119. return edges
  25120. }
  25121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25122. // was cleared in this mutation.
  25123. func (m *ServerMutation) EdgeCleared(name string) bool {
  25124. switch name {
  25125. case server.EdgeWxs:
  25126. return m.clearedwxs
  25127. }
  25128. return false
  25129. }
  25130. // ClearEdge clears the value of the edge with the given name. It returns an error
  25131. // if that edge is not defined in the schema.
  25132. func (m *ServerMutation) ClearEdge(name string) error {
  25133. switch name {
  25134. }
  25135. return fmt.Errorf("unknown Server unique edge %s", name)
  25136. }
  25137. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25138. // It returns an error if the edge is not defined in the schema.
  25139. func (m *ServerMutation) ResetEdge(name string) error {
  25140. switch name {
  25141. case server.EdgeWxs:
  25142. m.ResetWxs()
  25143. return nil
  25144. }
  25145. return fmt.Errorf("unknown Server edge %s", name)
  25146. }
  25147. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  25148. type SopNodeMutation struct {
  25149. config
  25150. op Op
  25151. typ string
  25152. id *uint64
  25153. created_at *time.Time
  25154. updated_at *time.Time
  25155. status *uint8
  25156. addstatus *int8
  25157. deleted_at *time.Time
  25158. parent_id *uint64
  25159. addparent_id *int64
  25160. name *string
  25161. condition_type *int
  25162. addcondition_type *int
  25163. condition_list *[]string
  25164. appendcondition_list []string
  25165. no_reply_condition *uint64
  25166. addno_reply_condition *int64
  25167. no_reply_unit *string
  25168. action_message *[]custom_types.Action
  25169. appendaction_message []custom_types.Action
  25170. action_label_add *[]uint64
  25171. appendaction_label_add []uint64
  25172. action_label_del *[]uint64
  25173. appendaction_label_del []uint64
  25174. action_forward **custom_types.ActionForward
  25175. clearedFields map[string]struct{}
  25176. sop_stage *uint64
  25177. clearedsop_stage bool
  25178. node_messages map[uint64]struct{}
  25179. removednode_messages map[uint64]struct{}
  25180. clearednode_messages bool
  25181. done bool
  25182. oldValue func(context.Context) (*SopNode, error)
  25183. predicates []predicate.SopNode
  25184. }
  25185. var _ ent.Mutation = (*SopNodeMutation)(nil)
  25186. // sopnodeOption allows management of the mutation configuration using functional options.
  25187. type sopnodeOption func(*SopNodeMutation)
  25188. // newSopNodeMutation creates new mutation for the SopNode entity.
  25189. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  25190. m := &SopNodeMutation{
  25191. config: c,
  25192. op: op,
  25193. typ: TypeSopNode,
  25194. clearedFields: make(map[string]struct{}),
  25195. }
  25196. for _, opt := range opts {
  25197. opt(m)
  25198. }
  25199. return m
  25200. }
  25201. // withSopNodeID sets the ID field of the mutation.
  25202. func withSopNodeID(id uint64) sopnodeOption {
  25203. return func(m *SopNodeMutation) {
  25204. var (
  25205. err error
  25206. once sync.Once
  25207. value *SopNode
  25208. )
  25209. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  25210. once.Do(func() {
  25211. if m.done {
  25212. err = errors.New("querying old values post mutation is not allowed")
  25213. } else {
  25214. value, err = m.Client().SopNode.Get(ctx, id)
  25215. }
  25216. })
  25217. return value, err
  25218. }
  25219. m.id = &id
  25220. }
  25221. }
  25222. // withSopNode sets the old SopNode of the mutation.
  25223. func withSopNode(node *SopNode) sopnodeOption {
  25224. return func(m *SopNodeMutation) {
  25225. m.oldValue = func(context.Context) (*SopNode, error) {
  25226. return node, nil
  25227. }
  25228. m.id = &node.ID
  25229. }
  25230. }
  25231. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25232. // executed in a transaction (ent.Tx), a transactional client is returned.
  25233. func (m SopNodeMutation) Client() *Client {
  25234. client := &Client{config: m.config}
  25235. client.init()
  25236. return client
  25237. }
  25238. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25239. // it returns an error otherwise.
  25240. func (m SopNodeMutation) Tx() (*Tx, error) {
  25241. if _, ok := m.driver.(*txDriver); !ok {
  25242. return nil, errors.New("ent: mutation is not running in a transaction")
  25243. }
  25244. tx := &Tx{config: m.config}
  25245. tx.init()
  25246. return tx, nil
  25247. }
  25248. // SetID sets the value of the id field. Note that this
  25249. // operation is only accepted on creation of SopNode entities.
  25250. func (m *SopNodeMutation) SetID(id uint64) {
  25251. m.id = &id
  25252. }
  25253. // ID returns the ID value in the mutation. Note that the ID is only available
  25254. // if it was provided to the builder or after it was returned from the database.
  25255. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  25256. if m.id == nil {
  25257. return
  25258. }
  25259. return *m.id, true
  25260. }
  25261. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25262. // That means, if the mutation is applied within a transaction with an isolation level such
  25263. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25264. // or updated by the mutation.
  25265. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  25266. switch {
  25267. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25268. id, exists := m.ID()
  25269. if exists {
  25270. return []uint64{id}, nil
  25271. }
  25272. fallthrough
  25273. case m.op.Is(OpUpdate | OpDelete):
  25274. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  25275. default:
  25276. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25277. }
  25278. }
  25279. // SetCreatedAt sets the "created_at" field.
  25280. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  25281. m.created_at = &t
  25282. }
  25283. // CreatedAt returns the value of the "created_at" field in the mutation.
  25284. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  25285. v := m.created_at
  25286. if v == nil {
  25287. return
  25288. }
  25289. return *v, true
  25290. }
  25291. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  25292. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25294. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25295. if !m.op.Is(OpUpdateOne) {
  25296. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25297. }
  25298. if m.id == nil || m.oldValue == nil {
  25299. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25300. }
  25301. oldValue, err := m.oldValue(ctx)
  25302. if err != nil {
  25303. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25304. }
  25305. return oldValue.CreatedAt, nil
  25306. }
  25307. // ResetCreatedAt resets all changes to the "created_at" field.
  25308. func (m *SopNodeMutation) ResetCreatedAt() {
  25309. m.created_at = nil
  25310. }
  25311. // SetUpdatedAt sets the "updated_at" field.
  25312. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  25313. m.updated_at = &t
  25314. }
  25315. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25316. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  25317. v := m.updated_at
  25318. if v == nil {
  25319. return
  25320. }
  25321. return *v, true
  25322. }
  25323. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  25324. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25326. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25327. if !m.op.Is(OpUpdateOne) {
  25328. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25329. }
  25330. if m.id == nil || m.oldValue == nil {
  25331. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25332. }
  25333. oldValue, err := m.oldValue(ctx)
  25334. if err != nil {
  25335. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25336. }
  25337. return oldValue.UpdatedAt, nil
  25338. }
  25339. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25340. func (m *SopNodeMutation) ResetUpdatedAt() {
  25341. m.updated_at = nil
  25342. }
  25343. // SetStatus sets the "status" field.
  25344. func (m *SopNodeMutation) SetStatus(u uint8) {
  25345. m.status = &u
  25346. m.addstatus = nil
  25347. }
  25348. // Status returns the value of the "status" field in the mutation.
  25349. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  25350. v := m.status
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldStatus returns the old "status" field's value of the SopNode entity.
  25357. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldStatus requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25369. }
  25370. return oldValue.Status, nil
  25371. }
  25372. // AddStatus adds u to the "status" field.
  25373. func (m *SopNodeMutation) AddStatus(u int8) {
  25374. if m.addstatus != nil {
  25375. *m.addstatus += u
  25376. } else {
  25377. m.addstatus = &u
  25378. }
  25379. }
  25380. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25381. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  25382. v := m.addstatus
  25383. if v == nil {
  25384. return
  25385. }
  25386. return *v, true
  25387. }
  25388. // ClearStatus clears the value of the "status" field.
  25389. func (m *SopNodeMutation) ClearStatus() {
  25390. m.status = nil
  25391. m.addstatus = nil
  25392. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  25393. }
  25394. // StatusCleared returns if the "status" field was cleared in this mutation.
  25395. func (m *SopNodeMutation) StatusCleared() bool {
  25396. _, ok := m.clearedFields[sopnode.FieldStatus]
  25397. return ok
  25398. }
  25399. // ResetStatus resets all changes to the "status" field.
  25400. func (m *SopNodeMutation) ResetStatus() {
  25401. m.status = nil
  25402. m.addstatus = nil
  25403. delete(m.clearedFields, sopnode.FieldStatus)
  25404. }
  25405. // SetDeletedAt sets the "deleted_at" field.
  25406. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  25407. m.deleted_at = &t
  25408. }
  25409. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25410. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  25411. v := m.deleted_at
  25412. if v == nil {
  25413. return
  25414. }
  25415. return *v, true
  25416. }
  25417. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  25418. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25420. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25421. if !m.op.Is(OpUpdateOne) {
  25422. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25423. }
  25424. if m.id == nil || m.oldValue == nil {
  25425. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25426. }
  25427. oldValue, err := m.oldValue(ctx)
  25428. if err != nil {
  25429. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25430. }
  25431. return oldValue.DeletedAt, nil
  25432. }
  25433. // ClearDeletedAt clears the value of the "deleted_at" field.
  25434. func (m *SopNodeMutation) ClearDeletedAt() {
  25435. m.deleted_at = nil
  25436. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  25437. }
  25438. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25439. func (m *SopNodeMutation) DeletedAtCleared() bool {
  25440. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  25441. return ok
  25442. }
  25443. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25444. func (m *SopNodeMutation) ResetDeletedAt() {
  25445. m.deleted_at = nil
  25446. delete(m.clearedFields, sopnode.FieldDeletedAt)
  25447. }
  25448. // SetStageID sets the "stage_id" field.
  25449. func (m *SopNodeMutation) SetStageID(u uint64) {
  25450. m.sop_stage = &u
  25451. }
  25452. // StageID returns the value of the "stage_id" field in the mutation.
  25453. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  25454. v := m.sop_stage
  25455. if v == nil {
  25456. return
  25457. }
  25458. return *v, true
  25459. }
  25460. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  25461. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25463. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  25464. if !m.op.Is(OpUpdateOne) {
  25465. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  25466. }
  25467. if m.id == nil || m.oldValue == nil {
  25468. return v, errors.New("OldStageID requires an ID field in the mutation")
  25469. }
  25470. oldValue, err := m.oldValue(ctx)
  25471. if err != nil {
  25472. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  25473. }
  25474. return oldValue.StageID, nil
  25475. }
  25476. // ResetStageID resets all changes to the "stage_id" field.
  25477. func (m *SopNodeMutation) ResetStageID() {
  25478. m.sop_stage = nil
  25479. }
  25480. // SetParentID sets the "parent_id" field.
  25481. func (m *SopNodeMutation) SetParentID(u uint64) {
  25482. m.parent_id = &u
  25483. m.addparent_id = nil
  25484. }
  25485. // ParentID returns the value of the "parent_id" field in the mutation.
  25486. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  25487. v := m.parent_id
  25488. if v == nil {
  25489. return
  25490. }
  25491. return *v, true
  25492. }
  25493. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  25494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25496. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  25497. if !m.op.Is(OpUpdateOne) {
  25498. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  25499. }
  25500. if m.id == nil || m.oldValue == nil {
  25501. return v, errors.New("OldParentID requires an ID field in the mutation")
  25502. }
  25503. oldValue, err := m.oldValue(ctx)
  25504. if err != nil {
  25505. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  25506. }
  25507. return oldValue.ParentID, nil
  25508. }
  25509. // AddParentID adds u to the "parent_id" field.
  25510. func (m *SopNodeMutation) AddParentID(u int64) {
  25511. if m.addparent_id != nil {
  25512. *m.addparent_id += u
  25513. } else {
  25514. m.addparent_id = &u
  25515. }
  25516. }
  25517. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  25518. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  25519. v := m.addparent_id
  25520. if v == nil {
  25521. return
  25522. }
  25523. return *v, true
  25524. }
  25525. // ResetParentID resets all changes to the "parent_id" field.
  25526. func (m *SopNodeMutation) ResetParentID() {
  25527. m.parent_id = nil
  25528. m.addparent_id = nil
  25529. }
  25530. // SetName sets the "name" field.
  25531. func (m *SopNodeMutation) SetName(s string) {
  25532. m.name = &s
  25533. }
  25534. // Name returns the value of the "name" field in the mutation.
  25535. func (m *SopNodeMutation) Name() (r string, exists bool) {
  25536. v := m.name
  25537. if v == nil {
  25538. return
  25539. }
  25540. return *v, true
  25541. }
  25542. // OldName returns the old "name" field's value of the SopNode entity.
  25543. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25545. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  25546. if !m.op.Is(OpUpdateOne) {
  25547. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25548. }
  25549. if m.id == nil || m.oldValue == nil {
  25550. return v, errors.New("OldName requires an ID field in the mutation")
  25551. }
  25552. oldValue, err := m.oldValue(ctx)
  25553. if err != nil {
  25554. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25555. }
  25556. return oldValue.Name, nil
  25557. }
  25558. // ResetName resets all changes to the "name" field.
  25559. func (m *SopNodeMutation) ResetName() {
  25560. m.name = nil
  25561. }
  25562. // SetConditionType sets the "condition_type" field.
  25563. func (m *SopNodeMutation) SetConditionType(i int) {
  25564. m.condition_type = &i
  25565. m.addcondition_type = nil
  25566. }
  25567. // ConditionType returns the value of the "condition_type" field in the mutation.
  25568. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  25569. v := m.condition_type
  25570. if v == nil {
  25571. return
  25572. }
  25573. return *v, true
  25574. }
  25575. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  25576. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25578. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25579. if !m.op.Is(OpUpdateOne) {
  25580. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25581. }
  25582. if m.id == nil || m.oldValue == nil {
  25583. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25584. }
  25585. oldValue, err := m.oldValue(ctx)
  25586. if err != nil {
  25587. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25588. }
  25589. return oldValue.ConditionType, nil
  25590. }
  25591. // AddConditionType adds i to the "condition_type" field.
  25592. func (m *SopNodeMutation) AddConditionType(i int) {
  25593. if m.addcondition_type != nil {
  25594. *m.addcondition_type += i
  25595. } else {
  25596. m.addcondition_type = &i
  25597. }
  25598. }
  25599. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25600. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  25601. v := m.addcondition_type
  25602. if v == nil {
  25603. return
  25604. }
  25605. return *v, true
  25606. }
  25607. // ResetConditionType resets all changes to the "condition_type" field.
  25608. func (m *SopNodeMutation) ResetConditionType() {
  25609. m.condition_type = nil
  25610. m.addcondition_type = nil
  25611. }
  25612. // SetConditionList sets the "condition_list" field.
  25613. func (m *SopNodeMutation) SetConditionList(s []string) {
  25614. m.condition_list = &s
  25615. m.appendcondition_list = nil
  25616. }
  25617. // ConditionList returns the value of the "condition_list" field in the mutation.
  25618. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  25619. v := m.condition_list
  25620. if v == nil {
  25621. return
  25622. }
  25623. return *v, true
  25624. }
  25625. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  25626. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25628. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  25629. if !m.op.Is(OpUpdateOne) {
  25630. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25631. }
  25632. if m.id == nil || m.oldValue == nil {
  25633. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25634. }
  25635. oldValue, err := m.oldValue(ctx)
  25636. if err != nil {
  25637. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25638. }
  25639. return oldValue.ConditionList, nil
  25640. }
  25641. // AppendConditionList adds s to the "condition_list" field.
  25642. func (m *SopNodeMutation) AppendConditionList(s []string) {
  25643. m.appendcondition_list = append(m.appendcondition_list, s...)
  25644. }
  25645. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25646. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  25647. if len(m.appendcondition_list) == 0 {
  25648. return nil, false
  25649. }
  25650. return m.appendcondition_list, true
  25651. }
  25652. // ClearConditionList clears the value of the "condition_list" field.
  25653. func (m *SopNodeMutation) ClearConditionList() {
  25654. m.condition_list = nil
  25655. m.appendcondition_list = nil
  25656. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  25657. }
  25658. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  25659. func (m *SopNodeMutation) ConditionListCleared() bool {
  25660. _, ok := m.clearedFields[sopnode.FieldConditionList]
  25661. return ok
  25662. }
  25663. // ResetConditionList resets all changes to the "condition_list" field.
  25664. func (m *SopNodeMutation) ResetConditionList() {
  25665. m.condition_list = nil
  25666. m.appendcondition_list = nil
  25667. delete(m.clearedFields, sopnode.FieldConditionList)
  25668. }
  25669. // SetNoReplyCondition sets the "no_reply_condition" field.
  25670. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  25671. m.no_reply_condition = &u
  25672. m.addno_reply_condition = nil
  25673. }
  25674. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  25675. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  25676. v := m.no_reply_condition
  25677. if v == nil {
  25678. return
  25679. }
  25680. return *v, true
  25681. }
  25682. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  25683. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25685. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  25686. if !m.op.Is(OpUpdateOne) {
  25687. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  25688. }
  25689. if m.id == nil || m.oldValue == nil {
  25690. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  25691. }
  25692. oldValue, err := m.oldValue(ctx)
  25693. if err != nil {
  25694. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  25695. }
  25696. return oldValue.NoReplyCondition, nil
  25697. }
  25698. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  25699. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  25700. if m.addno_reply_condition != nil {
  25701. *m.addno_reply_condition += u
  25702. } else {
  25703. m.addno_reply_condition = &u
  25704. }
  25705. }
  25706. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  25707. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  25708. v := m.addno_reply_condition
  25709. if v == nil {
  25710. return
  25711. }
  25712. return *v, true
  25713. }
  25714. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  25715. func (m *SopNodeMutation) ResetNoReplyCondition() {
  25716. m.no_reply_condition = nil
  25717. m.addno_reply_condition = nil
  25718. }
  25719. // SetNoReplyUnit sets the "no_reply_unit" field.
  25720. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  25721. m.no_reply_unit = &s
  25722. }
  25723. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  25724. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  25725. v := m.no_reply_unit
  25726. if v == nil {
  25727. return
  25728. }
  25729. return *v, true
  25730. }
  25731. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  25732. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25734. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  25735. if !m.op.Is(OpUpdateOne) {
  25736. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  25737. }
  25738. if m.id == nil || m.oldValue == nil {
  25739. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  25740. }
  25741. oldValue, err := m.oldValue(ctx)
  25742. if err != nil {
  25743. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  25744. }
  25745. return oldValue.NoReplyUnit, nil
  25746. }
  25747. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  25748. func (m *SopNodeMutation) ResetNoReplyUnit() {
  25749. m.no_reply_unit = nil
  25750. }
  25751. // SetActionMessage sets the "action_message" field.
  25752. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  25753. m.action_message = &ct
  25754. m.appendaction_message = nil
  25755. }
  25756. // ActionMessage returns the value of the "action_message" field in the mutation.
  25757. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25758. v := m.action_message
  25759. if v == nil {
  25760. return
  25761. }
  25762. return *v, true
  25763. }
  25764. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  25765. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25767. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25768. if !m.op.Is(OpUpdateOne) {
  25769. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25770. }
  25771. if m.id == nil || m.oldValue == nil {
  25772. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25773. }
  25774. oldValue, err := m.oldValue(ctx)
  25775. if err != nil {
  25776. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25777. }
  25778. return oldValue.ActionMessage, nil
  25779. }
  25780. // AppendActionMessage adds ct to the "action_message" field.
  25781. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  25782. m.appendaction_message = append(m.appendaction_message, ct...)
  25783. }
  25784. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25785. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25786. if len(m.appendaction_message) == 0 {
  25787. return nil, false
  25788. }
  25789. return m.appendaction_message, true
  25790. }
  25791. // ClearActionMessage clears the value of the "action_message" field.
  25792. func (m *SopNodeMutation) ClearActionMessage() {
  25793. m.action_message = nil
  25794. m.appendaction_message = nil
  25795. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  25796. }
  25797. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25798. func (m *SopNodeMutation) ActionMessageCleared() bool {
  25799. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  25800. return ok
  25801. }
  25802. // ResetActionMessage resets all changes to the "action_message" field.
  25803. func (m *SopNodeMutation) ResetActionMessage() {
  25804. m.action_message = nil
  25805. m.appendaction_message = nil
  25806. delete(m.clearedFields, sopnode.FieldActionMessage)
  25807. }
  25808. // SetActionLabelAdd sets the "action_label_add" field.
  25809. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  25810. m.action_label_add = &u
  25811. m.appendaction_label_add = nil
  25812. }
  25813. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25814. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25815. v := m.action_label_add
  25816. if v == nil {
  25817. return
  25818. }
  25819. return *v, true
  25820. }
  25821. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  25822. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25824. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25825. if !m.op.Is(OpUpdateOne) {
  25826. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25827. }
  25828. if m.id == nil || m.oldValue == nil {
  25829. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25830. }
  25831. oldValue, err := m.oldValue(ctx)
  25832. if err != nil {
  25833. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25834. }
  25835. return oldValue.ActionLabelAdd, nil
  25836. }
  25837. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25838. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  25839. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25840. }
  25841. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25842. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25843. if len(m.appendaction_label_add) == 0 {
  25844. return nil, false
  25845. }
  25846. return m.appendaction_label_add, true
  25847. }
  25848. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25849. func (m *SopNodeMutation) ClearActionLabelAdd() {
  25850. m.action_label_add = nil
  25851. m.appendaction_label_add = nil
  25852. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  25853. }
  25854. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25855. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  25856. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  25857. return ok
  25858. }
  25859. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25860. func (m *SopNodeMutation) ResetActionLabelAdd() {
  25861. m.action_label_add = nil
  25862. m.appendaction_label_add = nil
  25863. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  25864. }
  25865. // SetActionLabelDel sets the "action_label_del" field.
  25866. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  25867. m.action_label_del = &u
  25868. m.appendaction_label_del = nil
  25869. }
  25870. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25871. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  25872. v := m.action_label_del
  25873. if v == nil {
  25874. return
  25875. }
  25876. return *v, true
  25877. }
  25878. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  25879. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25881. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25882. if !m.op.Is(OpUpdateOne) {
  25883. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25884. }
  25885. if m.id == nil || m.oldValue == nil {
  25886. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  25887. }
  25888. oldValue, err := m.oldValue(ctx)
  25889. if err != nil {
  25890. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  25891. }
  25892. return oldValue.ActionLabelDel, nil
  25893. }
  25894. // AppendActionLabelDel adds u to the "action_label_del" field.
  25895. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  25896. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25897. }
  25898. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25899. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25900. if len(m.appendaction_label_del) == 0 {
  25901. return nil, false
  25902. }
  25903. return m.appendaction_label_del, true
  25904. }
  25905. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25906. func (m *SopNodeMutation) ClearActionLabelDel() {
  25907. m.action_label_del = nil
  25908. m.appendaction_label_del = nil
  25909. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  25910. }
  25911. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25912. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  25913. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  25914. return ok
  25915. }
  25916. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25917. func (m *SopNodeMutation) ResetActionLabelDel() {
  25918. m.action_label_del = nil
  25919. m.appendaction_label_del = nil
  25920. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  25921. }
  25922. // SetActionForward sets the "action_forward" field.
  25923. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25924. m.action_forward = &ctf
  25925. }
  25926. // ActionForward returns the value of the "action_forward" field in the mutation.
  25927. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25928. v := m.action_forward
  25929. if v == nil {
  25930. return
  25931. }
  25932. return *v, true
  25933. }
  25934. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  25935. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  25936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25937. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25938. if !m.op.Is(OpUpdateOne) {
  25939. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25940. }
  25941. if m.id == nil || m.oldValue == nil {
  25942. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25943. }
  25944. oldValue, err := m.oldValue(ctx)
  25945. if err != nil {
  25946. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25947. }
  25948. return oldValue.ActionForward, nil
  25949. }
  25950. // ClearActionForward clears the value of the "action_forward" field.
  25951. func (m *SopNodeMutation) ClearActionForward() {
  25952. m.action_forward = nil
  25953. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  25954. }
  25955. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25956. func (m *SopNodeMutation) ActionForwardCleared() bool {
  25957. _, ok := m.clearedFields[sopnode.FieldActionForward]
  25958. return ok
  25959. }
  25960. // ResetActionForward resets all changes to the "action_forward" field.
  25961. func (m *SopNodeMutation) ResetActionForward() {
  25962. m.action_forward = nil
  25963. delete(m.clearedFields, sopnode.FieldActionForward)
  25964. }
  25965. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25966. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  25967. m.sop_stage = &id
  25968. }
  25969. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25970. func (m *SopNodeMutation) ClearSopStage() {
  25971. m.clearedsop_stage = true
  25972. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  25973. }
  25974. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25975. func (m *SopNodeMutation) SopStageCleared() bool {
  25976. return m.clearedsop_stage
  25977. }
  25978. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25979. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  25980. if m.sop_stage != nil {
  25981. return *m.sop_stage, true
  25982. }
  25983. return
  25984. }
  25985. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25986. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25987. // SopStageID instead. It exists only for internal usage by the builders.
  25988. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  25989. if id := m.sop_stage; id != nil {
  25990. ids = append(ids, *id)
  25991. }
  25992. return
  25993. }
  25994. // ResetSopStage resets all changes to the "sop_stage" edge.
  25995. func (m *SopNodeMutation) ResetSopStage() {
  25996. m.sop_stage = nil
  25997. m.clearedsop_stage = false
  25998. }
  25999. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  26000. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  26001. if m.node_messages == nil {
  26002. m.node_messages = make(map[uint64]struct{})
  26003. }
  26004. for i := range ids {
  26005. m.node_messages[ids[i]] = struct{}{}
  26006. }
  26007. }
  26008. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  26009. func (m *SopNodeMutation) ClearNodeMessages() {
  26010. m.clearednode_messages = true
  26011. }
  26012. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  26013. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  26014. return m.clearednode_messages
  26015. }
  26016. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  26017. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  26018. if m.removednode_messages == nil {
  26019. m.removednode_messages = make(map[uint64]struct{})
  26020. }
  26021. for i := range ids {
  26022. delete(m.node_messages, ids[i])
  26023. m.removednode_messages[ids[i]] = struct{}{}
  26024. }
  26025. }
  26026. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  26027. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  26028. for id := range m.removednode_messages {
  26029. ids = append(ids, id)
  26030. }
  26031. return
  26032. }
  26033. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  26034. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  26035. for id := range m.node_messages {
  26036. ids = append(ids, id)
  26037. }
  26038. return
  26039. }
  26040. // ResetNodeMessages resets all changes to the "node_messages" edge.
  26041. func (m *SopNodeMutation) ResetNodeMessages() {
  26042. m.node_messages = nil
  26043. m.clearednode_messages = false
  26044. m.removednode_messages = nil
  26045. }
  26046. // Where appends a list predicates to the SopNodeMutation builder.
  26047. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  26048. m.predicates = append(m.predicates, ps...)
  26049. }
  26050. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  26051. // users can use type-assertion to append predicates that do not depend on any generated package.
  26052. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  26053. p := make([]predicate.SopNode, len(ps))
  26054. for i := range ps {
  26055. p[i] = ps[i]
  26056. }
  26057. m.Where(p...)
  26058. }
  26059. // Op returns the operation name.
  26060. func (m *SopNodeMutation) Op() Op {
  26061. return m.op
  26062. }
  26063. // SetOp allows setting the mutation operation.
  26064. func (m *SopNodeMutation) SetOp(op Op) {
  26065. m.op = op
  26066. }
  26067. // Type returns the node type of this mutation (SopNode).
  26068. func (m *SopNodeMutation) Type() string {
  26069. return m.typ
  26070. }
  26071. // Fields returns all fields that were changed during this mutation. Note that in
  26072. // order to get all numeric fields that were incremented/decremented, call
  26073. // AddedFields().
  26074. func (m *SopNodeMutation) Fields() []string {
  26075. fields := make([]string, 0, 15)
  26076. if m.created_at != nil {
  26077. fields = append(fields, sopnode.FieldCreatedAt)
  26078. }
  26079. if m.updated_at != nil {
  26080. fields = append(fields, sopnode.FieldUpdatedAt)
  26081. }
  26082. if m.status != nil {
  26083. fields = append(fields, sopnode.FieldStatus)
  26084. }
  26085. if m.deleted_at != nil {
  26086. fields = append(fields, sopnode.FieldDeletedAt)
  26087. }
  26088. if m.sop_stage != nil {
  26089. fields = append(fields, sopnode.FieldStageID)
  26090. }
  26091. if m.parent_id != nil {
  26092. fields = append(fields, sopnode.FieldParentID)
  26093. }
  26094. if m.name != nil {
  26095. fields = append(fields, sopnode.FieldName)
  26096. }
  26097. if m.condition_type != nil {
  26098. fields = append(fields, sopnode.FieldConditionType)
  26099. }
  26100. if m.condition_list != nil {
  26101. fields = append(fields, sopnode.FieldConditionList)
  26102. }
  26103. if m.no_reply_condition != nil {
  26104. fields = append(fields, sopnode.FieldNoReplyCondition)
  26105. }
  26106. if m.no_reply_unit != nil {
  26107. fields = append(fields, sopnode.FieldNoReplyUnit)
  26108. }
  26109. if m.action_message != nil {
  26110. fields = append(fields, sopnode.FieldActionMessage)
  26111. }
  26112. if m.action_label_add != nil {
  26113. fields = append(fields, sopnode.FieldActionLabelAdd)
  26114. }
  26115. if m.action_label_del != nil {
  26116. fields = append(fields, sopnode.FieldActionLabelDel)
  26117. }
  26118. if m.action_forward != nil {
  26119. fields = append(fields, sopnode.FieldActionForward)
  26120. }
  26121. return fields
  26122. }
  26123. // Field returns the value of a field with the given name. The second boolean
  26124. // return value indicates that this field was not set, or was not defined in the
  26125. // schema.
  26126. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  26127. switch name {
  26128. case sopnode.FieldCreatedAt:
  26129. return m.CreatedAt()
  26130. case sopnode.FieldUpdatedAt:
  26131. return m.UpdatedAt()
  26132. case sopnode.FieldStatus:
  26133. return m.Status()
  26134. case sopnode.FieldDeletedAt:
  26135. return m.DeletedAt()
  26136. case sopnode.FieldStageID:
  26137. return m.StageID()
  26138. case sopnode.FieldParentID:
  26139. return m.ParentID()
  26140. case sopnode.FieldName:
  26141. return m.Name()
  26142. case sopnode.FieldConditionType:
  26143. return m.ConditionType()
  26144. case sopnode.FieldConditionList:
  26145. return m.ConditionList()
  26146. case sopnode.FieldNoReplyCondition:
  26147. return m.NoReplyCondition()
  26148. case sopnode.FieldNoReplyUnit:
  26149. return m.NoReplyUnit()
  26150. case sopnode.FieldActionMessage:
  26151. return m.ActionMessage()
  26152. case sopnode.FieldActionLabelAdd:
  26153. return m.ActionLabelAdd()
  26154. case sopnode.FieldActionLabelDel:
  26155. return m.ActionLabelDel()
  26156. case sopnode.FieldActionForward:
  26157. return m.ActionForward()
  26158. }
  26159. return nil, false
  26160. }
  26161. // OldField returns the old value of the field from the database. An error is
  26162. // returned if the mutation operation is not UpdateOne, or the query to the
  26163. // database failed.
  26164. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26165. switch name {
  26166. case sopnode.FieldCreatedAt:
  26167. return m.OldCreatedAt(ctx)
  26168. case sopnode.FieldUpdatedAt:
  26169. return m.OldUpdatedAt(ctx)
  26170. case sopnode.FieldStatus:
  26171. return m.OldStatus(ctx)
  26172. case sopnode.FieldDeletedAt:
  26173. return m.OldDeletedAt(ctx)
  26174. case sopnode.FieldStageID:
  26175. return m.OldStageID(ctx)
  26176. case sopnode.FieldParentID:
  26177. return m.OldParentID(ctx)
  26178. case sopnode.FieldName:
  26179. return m.OldName(ctx)
  26180. case sopnode.FieldConditionType:
  26181. return m.OldConditionType(ctx)
  26182. case sopnode.FieldConditionList:
  26183. return m.OldConditionList(ctx)
  26184. case sopnode.FieldNoReplyCondition:
  26185. return m.OldNoReplyCondition(ctx)
  26186. case sopnode.FieldNoReplyUnit:
  26187. return m.OldNoReplyUnit(ctx)
  26188. case sopnode.FieldActionMessage:
  26189. return m.OldActionMessage(ctx)
  26190. case sopnode.FieldActionLabelAdd:
  26191. return m.OldActionLabelAdd(ctx)
  26192. case sopnode.FieldActionLabelDel:
  26193. return m.OldActionLabelDel(ctx)
  26194. case sopnode.FieldActionForward:
  26195. return m.OldActionForward(ctx)
  26196. }
  26197. return nil, fmt.Errorf("unknown SopNode field %s", name)
  26198. }
  26199. // SetField sets the value of a field with the given name. It returns an error if
  26200. // the field is not defined in the schema, or if the type mismatched the field
  26201. // type.
  26202. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  26203. switch name {
  26204. case sopnode.FieldCreatedAt:
  26205. v, ok := value.(time.Time)
  26206. if !ok {
  26207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26208. }
  26209. m.SetCreatedAt(v)
  26210. return nil
  26211. case sopnode.FieldUpdatedAt:
  26212. v, ok := value.(time.Time)
  26213. if !ok {
  26214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26215. }
  26216. m.SetUpdatedAt(v)
  26217. return nil
  26218. case sopnode.FieldStatus:
  26219. v, ok := value.(uint8)
  26220. if !ok {
  26221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26222. }
  26223. m.SetStatus(v)
  26224. return nil
  26225. case sopnode.FieldDeletedAt:
  26226. v, ok := value.(time.Time)
  26227. if !ok {
  26228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26229. }
  26230. m.SetDeletedAt(v)
  26231. return nil
  26232. case sopnode.FieldStageID:
  26233. v, ok := value.(uint64)
  26234. if !ok {
  26235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26236. }
  26237. m.SetStageID(v)
  26238. return nil
  26239. case sopnode.FieldParentID:
  26240. v, ok := value.(uint64)
  26241. if !ok {
  26242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26243. }
  26244. m.SetParentID(v)
  26245. return nil
  26246. case sopnode.FieldName:
  26247. v, ok := value.(string)
  26248. if !ok {
  26249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26250. }
  26251. m.SetName(v)
  26252. return nil
  26253. case sopnode.FieldConditionType:
  26254. v, ok := value.(int)
  26255. if !ok {
  26256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26257. }
  26258. m.SetConditionType(v)
  26259. return nil
  26260. case sopnode.FieldConditionList:
  26261. v, ok := value.([]string)
  26262. if !ok {
  26263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26264. }
  26265. m.SetConditionList(v)
  26266. return nil
  26267. case sopnode.FieldNoReplyCondition:
  26268. v, ok := value.(uint64)
  26269. if !ok {
  26270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26271. }
  26272. m.SetNoReplyCondition(v)
  26273. return nil
  26274. case sopnode.FieldNoReplyUnit:
  26275. v, ok := value.(string)
  26276. if !ok {
  26277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26278. }
  26279. m.SetNoReplyUnit(v)
  26280. return nil
  26281. case sopnode.FieldActionMessage:
  26282. v, ok := value.([]custom_types.Action)
  26283. if !ok {
  26284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26285. }
  26286. m.SetActionMessage(v)
  26287. return nil
  26288. case sopnode.FieldActionLabelAdd:
  26289. v, ok := value.([]uint64)
  26290. if !ok {
  26291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26292. }
  26293. m.SetActionLabelAdd(v)
  26294. return nil
  26295. case sopnode.FieldActionLabelDel:
  26296. v, ok := value.([]uint64)
  26297. if !ok {
  26298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26299. }
  26300. m.SetActionLabelDel(v)
  26301. return nil
  26302. case sopnode.FieldActionForward:
  26303. v, ok := value.(*custom_types.ActionForward)
  26304. if !ok {
  26305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26306. }
  26307. m.SetActionForward(v)
  26308. return nil
  26309. }
  26310. return fmt.Errorf("unknown SopNode field %s", name)
  26311. }
  26312. // AddedFields returns all numeric fields that were incremented/decremented during
  26313. // this mutation.
  26314. func (m *SopNodeMutation) AddedFields() []string {
  26315. var fields []string
  26316. if m.addstatus != nil {
  26317. fields = append(fields, sopnode.FieldStatus)
  26318. }
  26319. if m.addparent_id != nil {
  26320. fields = append(fields, sopnode.FieldParentID)
  26321. }
  26322. if m.addcondition_type != nil {
  26323. fields = append(fields, sopnode.FieldConditionType)
  26324. }
  26325. if m.addno_reply_condition != nil {
  26326. fields = append(fields, sopnode.FieldNoReplyCondition)
  26327. }
  26328. return fields
  26329. }
  26330. // AddedField returns the numeric value that was incremented/decremented on a field
  26331. // with the given name. The second boolean return value indicates that this field
  26332. // was not set, or was not defined in the schema.
  26333. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  26334. switch name {
  26335. case sopnode.FieldStatus:
  26336. return m.AddedStatus()
  26337. case sopnode.FieldParentID:
  26338. return m.AddedParentID()
  26339. case sopnode.FieldConditionType:
  26340. return m.AddedConditionType()
  26341. case sopnode.FieldNoReplyCondition:
  26342. return m.AddedNoReplyCondition()
  26343. }
  26344. return nil, false
  26345. }
  26346. // AddField adds the value to the field with the given name. It returns an error if
  26347. // the field is not defined in the schema, or if the type mismatched the field
  26348. // type.
  26349. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  26350. switch name {
  26351. case sopnode.FieldStatus:
  26352. v, ok := value.(int8)
  26353. if !ok {
  26354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26355. }
  26356. m.AddStatus(v)
  26357. return nil
  26358. case sopnode.FieldParentID:
  26359. v, ok := value.(int64)
  26360. if !ok {
  26361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26362. }
  26363. m.AddParentID(v)
  26364. return nil
  26365. case sopnode.FieldConditionType:
  26366. v, ok := value.(int)
  26367. if !ok {
  26368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26369. }
  26370. m.AddConditionType(v)
  26371. return nil
  26372. case sopnode.FieldNoReplyCondition:
  26373. v, ok := value.(int64)
  26374. if !ok {
  26375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26376. }
  26377. m.AddNoReplyCondition(v)
  26378. return nil
  26379. }
  26380. return fmt.Errorf("unknown SopNode numeric field %s", name)
  26381. }
  26382. // ClearedFields returns all nullable fields that were cleared during this
  26383. // mutation.
  26384. func (m *SopNodeMutation) ClearedFields() []string {
  26385. var fields []string
  26386. if m.FieldCleared(sopnode.FieldStatus) {
  26387. fields = append(fields, sopnode.FieldStatus)
  26388. }
  26389. if m.FieldCleared(sopnode.FieldDeletedAt) {
  26390. fields = append(fields, sopnode.FieldDeletedAt)
  26391. }
  26392. if m.FieldCleared(sopnode.FieldConditionList) {
  26393. fields = append(fields, sopnode.FieldConditionList)
  26394. }
  26395. if m.FieldCleared(sopnode.FieldActionMessage) {
  26396. fields = append(fields, sopnode.FieldActionMessage)
  26397. }
  26398. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  26399. fields = append(fields, sopnode.FieldActionLabelAdd)
  26400. }
  26401. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  26402. fields = append(fields, sopnode.FieldActionLabelDel)
  26403. }
  26404. if m.FieldCleared(sopnode.FieldActionForward) {
  26405. fields = append(fields, sopnode.FieldActionForward)
  26406. }
  26407. return fields
  26408. }
  26409. // FieldCleared returns a boolean indicating if a field with the given name was
  26410. // cleared in this mutation.
  26411. func (m *SopNodeMutation) FieldCleared(name string) bool {
  26412. _, ok := m.clearedFields[name]
  26413. return ok
  26414. }
  26415. // ClearField clears the value of the field with the given name. It returns an
  26416. // error if the field is not defined in the schema.
  26417. func (m *SopNodeMutation) ClearField(name string) error {
  26418. switch name {
  26419. case sopnode.FieldStatus:
  26420. m.ClearStatus()
  26421. return nil
  26422. case sopnode.FieldDeletedAt:
  26423. m.ClearDeletedAt()
  26424. return nil
  26425. case sopnode.FieldConditionList:
  26426. m.ClearConditionList()
  26427. return nil
  26428. case sopnode.FieldActionMessage:
  26429. m.ClearActionMessage()
  26430. return nil
  26431. case sopnode.FieldActionLabelAdd:
  26432. m.ClearActionLabelAdd()
  26433. return nil
  26434. case sopnode.FieldActionLabelDel:
  26435. m.ClearActionLabelDel()
  26436. return nil
  26437. case sopnode.FieldActionForward:
  26438. m.ClearActionForward()
  26439. return nil
  26440. }
  26441. return fmt.Errorf("unknown SopNode nullable field %s", name)
  26442. }
  26443. // ResetField resets all changes in the mutation for the field with the given name.
  26444. // It returns an error if the field is not defined in the schema.
  26445. func (m *SopNodeMutation) ResetField(name string) error {
  26446. switch name {
  26447. case sopnode.FieldCreatedAt:
  26448. m.ResetCreatedAt()
  26449. return nil
  26450. case sopnode.FieldUpdatedAt:
  26451. m.ResetUpdatedAt()
  26452. return nil
  26453. case sopnode.FieldStatus:
  26454. m.ResetStatus()
  26455. return nil
  26456. case sopnode.FieldDeletedAt:
  26457. m.ResetDeletedAt()
  26458. return nil
  26459. case sopnode.FieldStageID:
  26460. m.ResetStageID()
  26461. return nil
  26462. case sopnode.FieldParentID:
  26463. m.ResetParentID()
  26464. return nil
  26465. case sopnode.FieldName:
  26466. m.ResetName()
  26467. return nil
  26468. case sopnode.FieldConditionType:
  26469. m.ResetConditionType()
  26470. return nil
  26471. case sopnode.FieldConditionList:
  26472. m.ResetConditionList()
  26473. return nil
  26474. case sopnode.FieldNoReplyCondition:
  26475. m.ResetNoReplyCondition()
  26476. return nil
  26477. case sopnode.FieldNoReplyUnit:
  26478. m.ResetNoReplyUnit()
  26479. return nil
  26480. case sopnode.FieldActionMessage:
  26481. m.ResetActionMessage()
  26482. return nil
  26483. case sopnode.FieldActionLabelAdd:
  26484. m.ResetActionLabelAdd()
  26485. return nil
  26486. case sopnode.FieldActionLabelDel:
  26487. m.ResetActionLabelDel()
  26488. return nil
  26489. case sopnode.FieldActionForward:
  26490. m.ResetActionForward()
  26491. return nil
  26492. }
  26493. return fmt.Errorf("unknown SopNode field %s", name)
  26494. }
  26495. // AddedEdges returns all edge names that were set/added in this mutation.
  26496. func (m *SopNodeMutation) AddedEdges() []string {
  26497. edges := make([]string, 0, 2)
  26498. if m.sop_stage != nil {
  26499. edges = append(edges, sopnode.EdgeSopStage)
  26500. }
  26501. if m.node_messages != nil {
  26502. edges = append(edges, sopnode.EdgeNodeMessages)
  26503. }
  26504. return edges
  26505. }
  26506. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26507. // name in this mutation.
  26508. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  26509. switch name {
  26510. case sopnode.EdgeSopStage:
  26511. if id := m.sop_stage; id != nil {
  26512. return []ent.Value{*id}
  26513. }
  26514. case sopnode.EdgeNodeMessages:
  26515. ids := make([]ent.Value, 0, len(m.node_messages))
  26516. for id := range m.node_messages {
  26517. ids = append(ids, id)
  26518. }
  26519. return ids
  26520. }
  26521. return nil
  26522. }
  26523. // RemovedEdges returns all edge names that were removed in this mutation.
  26524. func (m *SopNodeMutation) RemovedEdges() []string {
  26525. edges := make([]string, 0, 2)
  26526. if m.removednode_messages != nil {
  26527. edges = append(edges, sopnode.EdgeNodeMessages)
  26528. }
  26529. return edges
  26530. }
  26531. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26532. // the given name in this mutation.
  26533. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  26534. switch name {
  26535. case sopnode.EdgeNodeMessages:
  26536. ids := make([]ent.Value, 0, len(m.removednode_messages))
  26537. for id := range m.removednode_messages {
  26538. ids = append(ids, id)
  26539. }
  26540. return ids
  26541. }
  26542. return nil
  26543. }
  26544. // ClearedEdges returns all edge names that were cleared in this mutation.
  26545. func (m *SopNodeMutation) ClearedEdges() []string {
  26546. edges := make([]string, 0, 2)
  26547. if m.clearedsop_stage {
  26548. edges = append(edges, sopnode.EdgeSopStage)
  26549. }
  26550. if m.clearednode_messages {
  26551. edges = append(edges, sopnode.EdgeNodeMessages)
  26552. }
  26553. return edges
  26554. }
  26555. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26556. // was cleared in this mutation.
  26557. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  26558. switch name {
  26559. case sopnode.EdgeSopStage:
  26560. return m.clearedsop_stage
  26561. case sopnode.EdgeNodeMessages:
  26562. return m.clearednode_messages
  26563. }
  26564. return false
  26565. }
  26566. // ClearEdge clears the value of the edge with the given name. It returns an error
  26567. // if that edge is not defined in the schema.
  26568. func (m *SopNodeMutation) ClearEdge(name string) error {
  26569. switch name {
  26570. case sopnode.EdgeSopStage:
  26571. m.ClearSopStage()
  26572. return nil
  26573. }
  26574. return fmt.Errorf("unknown SopNode unique edge %s", name)
  26575. }
  26576. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26577. // It returns an error if the edge is not defined in the schema.
  26578. func (m *SopNodeMutation) ResetEdge(name string) error {
  26579. switch name {
  26580. case sopnode.EdgeSopStage:
  26581. m.ResetSopStage()
  26582. return nil
  26583. case sopnode.EdgeNodeMessages:
  26584. m.ResetNodeMessages()
  26585. return nil
  26586. }
  26587. return fmt.Errorf("unknown SopNode edge %s", name)
  26588. }
  26589. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  26590. type SopStageMutation struct {
  26591. config
  26592. op Op
  26593. typ string
  26594. id *uint64
  26595. created_at *time.Time
  26596. updated_at *time.Time
  26597. status *uint8
  26598. addstatus *int8
  26599. deleted_at *time.Time
  26600. name *string
  26601. condition_type *int
  26602. addcondition_type *int
  26603. condition_operator *int
  26604. addcondition_operator *int
  26605. condition_list *[]custom_types.Condition
  26606. appendcondition_list []custom_types.Condition
  26607. action_message *[]custom_types.Action
  26608. appendaction_message []custom_types.Action
  26609. action_label_add *[]uint64
  26610. appendaction_label_add []uint64
  26611. action_label_del *[]uint64
  26612. appendaction_label_del []uint64
  26613. action_forward **custom_types.ActionForward
  26614. index_sort *int
  26615. addindex_sort *int
  26616. clearedFields map[string]struct{}
  26617. sop_task *uint64
  26618. clearedsop_task bool
  26619. stage_nodes map[uint64]struct{}
  26620. removedstage_nodes map[uint64]struct{}
  26621. clearedstage_nodes bool
  26622. stage_messages map[uint64]struct{}
  26623. removedstage_messages map[uint64]struct{}
  26624. clearedstage_messages bool
  26625. done bool
  26626. oldValue func(context.Context) (*SopStage, error)
  26627. predicates []predicate.SopStage
  26628. }
  26629. var _ ent.Mutation = (*SopStageMutation)(nil)
  26630. // sopstageOption allows management of the mutation configuration using functional options.
  26631. type sopstageOption func(*SopStageMutation)
  26632. // newSopStageMutation creates new mutation for the SopStage entity.
  26633. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  26634. m := &SopStageMutation{
  26635. config: c,
  26636. op: op,
  26637. typ: TypeSopStage,
  26638. clearedFields: make(map[string]struct{}),
  26639. }
  26640. for _, opt := range opts {
  26641. opt(m)
  26642. }
  26643. return m
  26644. }
  26645. // withSopStageID sets the ID field of the mutation.
  26646. func withSopStageID(id uint64) sopstageOption {
  26647. return func(m *SopStageMutation) {
  26648. var (
  26649. err error
  26650. once sync.Once
  26651. value *SopStage
  26652. )
  26653. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  26654. once.Do(func() {
  26655. if m.done {
  26656. err = errors.New("querying old values post mutation is not allowed")
  26657. } else {
  26658. value, err = m.Client().SopStage.Get(ctx, id)
  26659. }
  26660. })
  26661. return value, err
  26662. }
  26663. m.id = &id
  26664. }
  26665. }
  26666. // withSopStage sets the old SopStage of the mutation.
  26667. func withSopStage(node *SopStage) sopstageOption {
  26668. return func(m *SopStageMutation) {
  26669. m.oldValue = func(context.Context) (*SopStage, error) {
  26670. return node, nil
  26671. }
  26672. m.id = &node.ID
  26673. }
  26674. }
  26675. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26676. // executed in a transaction (ent.Tx), a transactional client is returned.
  26677. func (m SopStageMutation) Client() *Client {
  26678. client := &Client{config: m.config}
  26679. client.init()
  26680. return client
  26681. }
  26682. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26683. // it returns an error otherwise.
  26684. func (m SopStageMutation) Tx() (*Tx, error) {
  26685. if _, ok := m.driver.(*txDriver); !ok {
  26686. return nil, errors.New("ent: mutation is not running in a transaction")
  26687. }
  26688. tx := &Tx{config: m.config}
  26689. tx.init()
  26690. return tx, nil
  26691. }
  26692. // SetID sets the value of the id field. Note that this
  26693. // operation is only accepted on creation of SopStage entities.
  26694. func (m *SopStageMutation) SetID(id uint64) {
  26695. m.id = &id
  26696. }
  26697. // ID returns the ID value in the mutation. Note that the ID is only available
  26698. // if it was provided to the builder or after it was returned from the database.
  26699. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  26700. if m.id == nil {
  26701. return
  26702. }
  26703. return *m.id, true
  26704. }
  26705. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26706. // That means, if the mutation is applied within a transaction with an isolation level such
  26707. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26708. // or updated by the mutation.
  26709. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  26710. switch {
  26711. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26712. id, exists := m.ID()
  26713. if exists {
  26714. return []uint64{id}, nil
  26715. }
  26716. fallthrough
  26717. case m.op.Is(OpUpdate | OpDelete):
  26718. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  26719. default:
  26720. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26721. }
  26722. }
  26723. // SetCreatedAt sets the "created_at" field.
  26724. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  26725. m.created_at = &t
  26726. }
  26727. // CreatedAt returns the value of the "created_at" field in the mutation.
  26728. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  26729. v := m.created_at
  26730. if v == nil {
  26731. return
  26732. }
  26733. return *v, true
  26734. }
  26735. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  26736. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26738. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26739. if !m.op.Is(OpUpdateOne) {
  26740. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26741. }
  26742. if m.id == nil || m.oldValue == nil {
  26743. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26744. }
  26745. oldValue, err := m.oldValue(ctx)
  26746. if err != nil {
  26747. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26748. }
  26749. return oldValue.CreatedAt, nil
  26750. }
  26751. // ResetCreatedAt resets all changes to the "created_at" field.
  26752. func (m *SopStageMutation) ResetCreatedAt() {
  26753. m.created_at = nil
  26754. }
  26755. // SetUpdatedAt sets the "updated_at" field.
  26756. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  26757. m.updated_at = &t
  26758. }
  26759. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26760. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  26761. v := m.updated_at
  26762. if v == nil {
  26763. return
  26764. }
  26765. return *v, true
  26766. }
  26767. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  26768. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26770. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26771. if !m.op.Is(OpUpdateOne) {
  26772. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26773. }
  26774. if m.id == nil || m.oldValue == nil {
  26775. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26776. }
  26777. oldValue, err := m.oldValue(ctx)
  26778. if err != nil {
  26779. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26780. }
  26781. return oldValue.UpdatedAt, nil
  26782. }
  26783. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26784. func (m *SopStageMutation) ResetUpdatedAt() {
  26785. m.updated_at = nil
  26786. }
  26787. // SetStatus sets the "status" field.
  26788. func (m *SopStageMutation) SetStatus(u uint8) {
  26789. m.status = &u
  26790. m.addstatus = nil
  26791. }
  26792. // Status returns the value of the "status" field in the mutation.
  26793. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  26794. v := m.status
  26795. if v == nil {
  26796. return
  26797. }
  26798. return *v, true
  26799. }
  26800. // OldStatus returns the old "status" field's value of the SopStage entity.
  26801. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26803. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26804. if !m.op.Is(OpUpdateOne) {
  26805. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26806. }
  26807. if m.id == nil || m.oldValue == nil {
  26808. return v, errors.New("OldStatus requires an ID field in the mutation")
  26809. }
  26810. oldValue, err := m.oldValue(ctx)
  26811. if err != nil {
  26812. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26813. }
  26814. return oldValue.Status, nil
  26815. }
  26816. // AddStatus adds u to the "status" field.
  26817. func (m *SopStageMutation) AddStatus(u int8) {
  26818. if m.addstatus != nil {
  26819. *m.addstatus += u
  26820. } else {
  26821. m.addstatus = &u
  26822. }
  26823. }
  26824. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26825. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  26826. v := m.addstatus
  26827. if v == nil {
  26828. return
  26829. }
  26830. return *v, true
  26831. }
  26832. // ClearStatus clears the value of the "status" field.
  26833. func (m *SopStageMutation) ClearStatus() {
  26834. m.status = nil
  26835. m.addstatus = nil
  26836. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  26837. }
  26838. // StatusCleared returns if the "status" field was cleared in this mutation.
  26839. func (m *SopStageMutation) StatusCleared() bool {
  26840. _, ok := m.clearedFields[sopstage.FieldStatus]
  26841. return ok
  26842. }
  26843. // ResetStatus resets all changes to the "status" field.
  26844. func (m *SopStageMutation) ResetStatus() {
  26845. m.status = nil
  26846. m.addstatus = nil
  26847. delete(m.clearedFields, sopstage.FieldStatus)
  26848. }
  26849. // SetDeletedAt sets the "deleted_at" field.
  26850. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  26851. m.deleted_at = &t
  26852. }
  26853. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26854. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  26855. v := m.deleted_at
  26856. if v == nil {
  26857. return
  26858. }
  26859. return *v, true
  26860. }
  26861. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  26862. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26864. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26865. if !m.op.Is(OpUpdateOne) {
  26866. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26867. }
  26868. if m.id == nil || m.oldValue == nil {
  26869. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26870. }
  26871. oldValue, err := m.oldValue(ctx)
  26872. if err != nil {
  26873. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26874. }
  26875. return oldValue.DeletedAt, nil
  26876. }
  26877. // ClearDeletedAt clears the value of the "deleted_at" field.
  26878. func (m *SopStageMutation) ClearDeletedAt() {
  26879. m.deleted_at = nil
  26880. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  26881. }
  26882. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26883. func (m *SopStageMutation) DeletedAtCleared() bool {
  26884. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  26885. return ok
  26886. }
  26887. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26888. func (m *SopStageMutation) ResetDeletedAt() {
  26889. m.deleted_at = nil
  26890. delete(m.clearedFields, sopstage.FieldDeletedAt)
  26891. }
  26892. // SetTaskID sets the "task_id" field.
  26893. func (m *SopStageMutation) SetTaskID(u uint64) {
  26894. m.sop_task = &u
  26895. }
  26896. // TaskID returns the value of the "task_id" field in the mutation.
  26897. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  26898. v := m.sop_task
  26899. if v == nil {
  26900. return
  26901. }
  26902. return *v, true
  26903. }
  26904. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  26905. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26907. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  26908. if !m.op.Is(OpUpdateOne) {
  26909. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  26910. }
  26911. if m.id == nil || m.oldValue == nil {
  26912. return v, errors.New("OldTaskID requires an ID field in the mutation")
  26913. }
  26914. oldValue, err := m.oldValue(ctx)
  26915. if err != nil {
  26916. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  26917. }
  26918. return oldValue.TaskID, nil
  26919. }
  26920. // ResetTaskID resets all changes to the "task_id" field.
  26921. func (m *SopStageMutation) ResetTaskID() {
  26922. m.sop_task = nil
  26923. }
  26924. // SetName sets the "name" field.
  26925. func (m *SopStageMutation) SetName(s string) {
  26926. m.name = &s
  26927. }
  26928. // Name returns the value of the "name" field in the mutation.
  26929. func (m *SopStageMutation) Name() (r string, exists bool) {
  26930. v := m.name
  26931. if v == nil {
  26932. return
  26933. }
  26934. return *v, true
  26935. }
  26936. // OldName returns the old "name" field's value of the SopStage entity.
  26937. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26939. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  26940. if !m.op.Is(OpUpdateOne) {
  26941. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26942. }
  26943. if m.id == nil || m.oldValue == nil {
  26944. return v, errors.New("OldName requires an ID field in the mutation")
  26945. }
  26946. oldValue, err := m.oldValue(ctx)
  26947. if err != nil {
  26948. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26949. }
  26950. return oldValue.Name, nil
  26951. }
  26952. // ResetName resets all changes to the "name" field.
  26953. func (m *SopStageMutation) ResetName() {
  26954. m.name = nil
  26955. }
  26956. // SetConditionType sets the "condition_type" field.
  26957. func (m *SopStageMutation) SetConditionType(i int) {
  26958. m.condition_type = &i
  26959. m.addcondition_type = nil
  26960. }
  26961. // ConditionType returns the value of the "condition_type" field in the mutation.
  26962. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  26963. v := m.condition_type
  26964. if v == nil {
  26965. return
  26966. }
  26967. return *v, true
  26968. }
  26969. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  26970. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26972. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26973. if !m.op.Is(OpUpdateOne) {
  26974. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26975. }
  26976. if m.id == nil || m.oldValue == nil {
  26977. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26978. }
  26979. oldValue, err := m.oldValue(ctx)
  26980. if err != nil {
  26981. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26982. }
  26983. return oldValue.ConditionType, nil
  26984. }
  26985. // AddConditionType adds i to the "condition_type" field.
  26986. func (m *SopStageMutation) AddConditionType(i int) {
  26987. if m.addcondition_type != nil {
  26988. *m.addcondition_type += i
  26989. } else {
  26990. m.addcondition_type = &i
  26991. }
  26992. }
  26993. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26994. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  26995. v := m.addcondition_type
  26996. if v == nil {
  26997. return
  26998. }
  26999. return *v, true
  27000. }
  27001. // ResetConditionType resets all changes to the "condition_type" field.
  27002. func (m *SopStageMutation) ResetConditionType() {
  27003. m.condition_type = nil
  27004. m.addcondition_type = nil
  27005. }
  27006. // SetConditionOperator sets the "condition_operator" field.
  27007. func (m *SopStageMutation) SetConditionOperator(i int) {
  27008. m.condition_operator = &i
  27009. m.addcondition_operator = nil
  27010. }
  27011. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  27012. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  27013. v := m.condition_operator
  27014. if v == nil {
  27015. return
  27016. }
  27017. return *v, true
  27018. }
  27019. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  27020. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27022. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  27023. if !m.op.Is(OpUpdateOne) {
  27024. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  27025. }
  27026. if m.id == nil || m.oldValue == nil {
  27027. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  27028. }
  27029. oldValue, err := m.oldValue(ctx)
  27030. if err != nil {
  27031. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  27032. }
  27033. return oldValue.ConditionOperator, nil
  27034. }
  27035. // AddConditionOperator adds i to the "condition_operator" field.
  27036. func (m *SopStageMutation) AddConditionOperator(i int) {
  27037. if m.addcondition_operator != nil {
  27038. *m.addcondition_operator += i
  27039. } else {
  27040. m.addcondition_operator = &i
  27041. }
  27042. }
  27043. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  27044. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  27045. v := m.addcondition_operator
  27046. if v == nil {
  27047. return
  27048. }
  27049. return *v, true
  27050. }
  27051. // ResetConditionOperator resets all changes to the "condition_operator" field.
  27052. func (m *SopStageMutation) ResetConditionOperator() {
  27053. m.condition_operator = nil
  27054. m.addcondition_operator = nil
  27055. }
  27056. // SetConditionList sets the "condition_list" field.
  27057. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  27058. m.condition_list = &ct
  27059. m.appendcondition_list = nil
  27060. }
  27061. // ConditionList returns the value of the "condition_list" field in the mutation.
  27062. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  27063. v := m.condition_list
  27064. if v == nil {
  27065. return
  27066. }
  27067. return *v, true
  27068. }
  27069. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  27070. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27072. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  27073. if !m.op.Is(OpUpdateOne) {
  27074. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27075. }
  27076. if m.id == nil || m.oldValue == nil {
  27077. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27078. }
  27079. oldValue, err := m.oldValue(ctx)
  27080. if err != nil {
  27081. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27082. }
  27083. return oldValue.ConditionList, nil
  27084. }
  27085. // AppendConditionList adds ct to the "condition_list" field.
  27086. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  27087. m.appendcondition_list = append(m.appendcondition_list, ct...)
  27088. }
  27089. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27090. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  27091. if len(m.appendcondition_list) == 0 {
  27092. return nil, false
  27093. }
  27094. return m.appendcondition_list, true
  27095. }
  27096. // ResetConditionList resets all changes to the "condition_list" field.
  27097. func (m *SopStageMutation) ResetConditionList() {
  27098. m.condition_list = nil
  27099. m.appendcondition_list = nil
  27100. }
  27101. // SetActionMessage sets the "action_message" field.
  27102. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  27103. m.action_message = &ct
  27104. m.appendaction_message = nil
  27105. }
  27106. // ActionMessage returns the value of the "action_message" field in the mutation.
  27107. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27108. v := m.action_message
  27109. if v == nil {
  27110. return
  27111. }
  27112. return *v, true
  27113. }
  27114. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  27115. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27117. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27118. if !m.op.Is(OpUpdateOne) {
  27119. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27120. }
  27121. if m.id == nil || m.oldValue == nil {
  27122. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27123. }
  27124. oldValue, err := m.oldValue(ctx)
  27125. if err != nil {
  27126. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27127. }
  27128. return oldValue.ActionMessage, nil
  27129. }
  27130. // AppendActionMessage adds ct to the "action_message" field.
  27131. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  27132. m.appendaction_message = append(m.appendaction_message, ct...)
  27133. }
  27134. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27135. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27136. if len(m.appendaction_message) == 0 {
  27137. return nil, false
  27138. }
  27139. return m.appendaction_message, true
  27140. }
  27141. // ClearActionMessage clears the value of the "action_message" field.
  27142. func (m *SopStageMutation) ClearActionMessage() {
  27143. m.action_message = nil
  27144. m.appendaction_message = nil
  27145. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  27146. }
  27147. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27148. func (m *SopStageMutation) ActionMessageCleared() bool {
  27149. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  27150. return ok
  27151. }
  27152. // ResetActionMessage resets all changes to the "action_message" field.
  27153. func (m *SopStageMutation) ResetActionMessage() {
  27154. m.action_message = nil
  27155. m.appendaction_message = nil
  27156. delete(m.clearedFields, sopstage.FieldActionMessage)
  27157. }
  27158. // SetActionLabelAdd sets the "action_label_add" field.
  27159. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  27160. m.action_label_add = &u
  27161. m.appendaction_label_add = nil
  27162. }
  27163. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27164. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27165. v := m.action_label_add
  27166. if v == nil {
  27167. return
  27168. }
  27169. return *v, true
  27170. }
  27171. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  27172. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27174. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27175. if !m.op.Is(OpUpdateOne) {
  27176. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27177. }
  27178. if m.id == nil || m.oldValue == nil {
  27179. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27180. }
  27181. oldValue, err := m.oldValue(ctx)
  27182. if err != nil {
  27183. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27184. }
  27185. return oldValue.ActionLabelAdd, nil
  27186. }
  27187. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27188. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  27189. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27190. }
  27191. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27192. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27193. if len(m.appendaction_label_add) == 0 {
  27194. return nil, false
  27195. }
  27196. return m.appendaction_label_add, true
  27197. }
  27198. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27199. func (m *SopStageMutation) ClearActionLabelAdd() {
  27200. m.action_label_add = nil
  27201. m.appendaction_label_add = nil
  27202. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  27203. }
  27204. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27205. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  27206. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  27207. return ok
  27208. }
  27209. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27210. func (m *SopStageMutation) ResetActionLabelAdd() {
  27211. m.action_label_add = nil
  27212. m.appendaction_label_add = nil
  27213. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  27214. }
  27215. // SetActionLabelDel sets the "action_label_del" field.
  27216. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  27217. m.action_label_del = &u
  27218. m.appendaction_label_del = nil
  27219. }
  27220. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27221. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  27222. v := m.action_label_del
  27223. if v == nil {
  27224. return
  27225. }
  27226. return *v, true
  27227. }
  27228. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  27229. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27231. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27232. if !m.op.Is(OpUpdateOne) {
  27233. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27234. }
  27235. if m.id == nil || m.oldValue == nil {
  27236. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27237. }
  27238. oldValue, err := m.oldValue(ctx)
  27239. if err != nil {
  27240. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27241. }
  27242. return oldValue.ActionLabelDel, nil
  27243. }
  27244. // AppendActionLabelDel adds u to the "action_label_del" field.
  27245. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  27246. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27247. }
  27248. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27249. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27250. if len(m.appendaction_label_del) == 0 {
  27251. return nil, false
  27252. }
  27253. return m.appendaction_label_del, true
  27254. }
  27255. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27256. func (m *SopStageMutation) ClearActionLabelDel() {
  27257. m.action_label_del = nil
  27258. m.appendaction_label_del = nil
  27259. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  27260. }
  27261. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27262. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  27263. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  27264. return ok
  27265. }
  27266. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27267. func (m *SopStageMutation) ResetActionLabelDel() {
  27268. m.action_label_del = nil
  27269. m.appendaction_label_del = nil
  27270. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  27271. }
  27272. // SetActionForward sets the "action_forward" field.
  27273. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27274. m.action_forward = &ctf
  27275. }
  27276. // ActionForward returns the value of the "action_forward" field in the mutation.
  27277. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27278. v := m.action_forward
  27279. if v == nil {
  27280. return
  27281. }
  27282. return *v, true
  27283. }
  27284. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  27285. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27287. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27288. if !m.op.Is(OpUpdateOne) {
  27289. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27290. }
  27291. if m.id == nil || m.oldValue == nil {
  27292. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27293. }
  27294. oldValue, err := m.oldValue(ctx)
  27295. if err != nil {
  27296. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27297. }
  27298. return oldValue.ActionForward, nil
  27299. }
  27300. // ClearActionForward clears the value of the "action_forward" field.
  27301. func (m *SopStageMutation) ClearActionForward() {
  27302. m.action_forward = nil
  27303. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  27304. }
  27305. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27306. func (m *SopStageMutation) ActionForwardCleared() bool {
  27307. _, ok := m.clearedFields[sopstage.FieldActionForward]
  27308. return ok
  27309. }
  27310. // ResetActionForward resets all changes to the "action_forward" field.
  27311. func (m *SopStageMutation) ResetActionForward() {
  27312. m.action_forward = nil
  27313. delete(m.clearedFields, sopstage.FieldActionForward)
  27314. }
  27315. // SetIndexSort sets the "index_sort" field.
  27316. func (m *SopStageMutation) SetIndexSort(i int) {
  27317. m.index_sort = &i
  27318. m.addindex_sort = nil
  27319. }
  27320. // IndexSort returns the value of the "index_sort" field in the mutation.
  27321. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  27322. v := m.index_sort
  27323. if v == nil {
  27324. return
  27325. }
  27326. return *v, true
  27327. }
  27328. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  27329. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  27330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27331. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  27332. if !m.op.Is(OpUpdateOne) {
  27333. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  27334. }
  27335. if m.id == nil || m.oldValue == nil {
  27336. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  27337. }
  27338. oldValue, err := m.oldValue(ctx)
  27339. if err != nil {
  27340. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  27341. }
  27342. return oldValue.IndexSort, nil
  27343. }
  27344. // AddIndexSort adds i to the "index_sort" field.
  27345. func (m *SopStageMutation) AddIndexSort(i int) {
  27346. if m.addindex_sort != nil {
  27347. *m.addindex_sort += i
  27348. } else {
  27349. m.addindex_sort = &i
  27350. }
  27351. }
  27352. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  27353. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  27354. v := m.addindex_sort
  27355. if v == nil {
  27356. return
  27357. }
  27358. return *v, true
  27359. }
  27360. // ClearIndexSort clears the value of the "index_sort" field.
  27361. func (m *SopStageMutation) ClearIndexSort() {
  27362. m.index_sort = nil
  27363. m.addindex_sort = nil
  27364. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  27365. }
  27366. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  27367. func (m *SopStageMutation) IndexSortCleared() bool {
  27368. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  27369. return ok
  27370. }
  27371. // ResetIndexSort resets all changes to the "index_sort" field.
  27372. func (m *SopStageMutation) ResetIndexSort() {
  27373. m.index_sort = nil
  27374. m.addindex_sort = nil
  27375. delete(m.clearedFields, sopstage.FieldIndexSort)
  27376. }
  27377. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  27378. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  27379. m.sop_task = &id
  27380. }
  27381. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  27382. func (m *SopStageMutation) ClearSopTask() {
  27383. m.clearedsop_task = true
  27384. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  27385. }
  27386. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  27387. func (m *SopStageMutation) SopTaskCleared() bool {
  27388. return m.clearedsop_task
  27389. }
  27390. // SopTaskID returns the "sop_task" edge ID in the mutation.
  27391. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  27392. if m.sop_task != nil {
  27393. return *m.sop_task, true
  27394. }
  27395. return
  27396. }
  27397. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  27398. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27399. // SopTaskID instead. It exists only for internal usage by the builders.
  27400. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  27401. if id := m.sop_task; id != nil {
  27402. ids = append(ids, *id)
  27403. }
  27404. return
  27405. }
  27406. // ResetSopTask resets all changes to the "sop_task" edge.
  27407. func (m *SopStageMutation) ResetSopTask() {
  27408. m.sop_task = nil
  27409. m.clearedsop_task = false
  27410. }
  27411. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  27412. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  27413. if m.stage_nodes == nil {
  27414. m.stage_nodes = make(map[uint64]struct{})
  27415. }
  27416. for i := range ids {
  27417. m.stage_nodes[ids[i]] = struct{}{}
  27418. }
  27419. }
  27420. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  27421. func (m *SopStageMutation) ClearStageNodes() {
  27422. m.clearedstage_nodes = true
  27423. }
  27424. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  27425. func (m *SopStageMutation) StageNodesCleared() bool {
  27426. return m.clearedstage_nodes
  27427. }
  27428. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  27429. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  27430. if m.removedstage_nodes == nil {
  27431. m.removedstage_nodes = make(map[uint64]struct{})
  27432. }
  27433. for i := range ids {
  27434. delete(m.stage_nodes, ids[i])
  27435. m.removedstage_nodes[ids[i]] = struct{}{}
  27436. }
  27437. }
  27438. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  27439. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  27440. for id := range m.removedstage_nodes {
  27441. ids = append(ids, id)
  27442. }
  27443. return
  27444. }
  27445. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  27446. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  27447. for id := range m.stage_nodes {
  27448. ids = append(ids, id)
  27449. }
  27450. return
  27451. }
  27452. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  27453. func (m *SopStageMutation) ResetStageNodes() {
  27454. m.stage_nodes = nil
  27455. m.clearedstage_nodes = false
  27456. m.removedstage_nodes = nil
  27457. }
  27458. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  27459. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  27460. if m.stage_messages == nil {
  27461. m.stage_messages = make(map[uint64]struct{})
  27462. }
  27463. for i := range ids {
  27464. m.stage_messages[ids[i]] = struct{}{}
  27465. }
  27466. }
  27467. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  27468. func (m *SopStageMutation) ClearStageMessages() {
  27469. m.clearedstage_messages = true
  27470. }
  27471. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  27472. func (m *SopStageMutation) StageMessagesCleared() bool {
  27473. return m.clearedstage_messages
  27474. }
  27475. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  27476. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  27477. if m.removedstage_messages == nil {
  27478. m.removedstage_messages = make(map[uint64]struct{})
  27479. }
  27480. for i := range ids {
  27481. delete(m.stage_messages, ids[i])
  27482. m.removedstage_messages[ids[i]] = struct{}{}
  27483. }
  27484. }
  27485. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  27486. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  27487. for id := range m.removedstage_messages {
  27488. ids = append(ids, id)
  27489. }
  27490. return
  27491. }
  27492. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  27493. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  27494. for id := range m.stage_messages {
  27495. ids = append(ids, id)
  27496. }
  27497. return
  27498. }
  27499. // ResetStageMessages resets all changes to the "stage_messages" edge.
  27500. func (m *SopStageMutation) ResetStageMessages() {
  27501. m.stage_messages = nil
  27502. m.clearedstage_messages = false
  27503. m.removedstage_messages = nil
  27504. }
  27505. // Where appends a list predicates to the SopStageMutation builder.
  27506. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  27507. m.predicates = append(m.predicates, ps...)
  27508. }
  27509. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  27510. // users can use type-assertion to append predicates that do not depend on any generated package.
  27511. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  27512. p := make([]predicate.SopStage, len(ps))
  27513. for i := range ps {
  27514. p[i] = ps[i]
  27515. }
  27516. m.Where(p...)
  27517. }
  27518. // Op returns the operation name.
  27519. func (m *SopStageMutation) Op() Op {
  27520. return m.op
  27521. }
  27522. // SetOp allows setting the mutation operation.
  27523. func (m *SopStageMutation) SetOp(op Op) {
  27524. m.op = op
  27525. }
  27526. // Type returns the node type of this mutation (SopStage).
  27527. func (m *SopStageMutation) Type() string {
  27528. return m.typ
  27529. }
  27530. // Fields returns all fields that were changed during this mutation. Note that in
  27531. // order to get all numeric fields that were incremented/decremented, call
  27532. // AddedFields().
  27533. func (m *SopStageMutation) Fields() []string {
  27534. fields := make([]string, 0, 14)
  27535. if m.created_at != nil {
  27536. fields = append(fields, sopstage.FieldCreatedAt)
  27537. }
  27538. if m.updated_at != nil {
  27539. fields = append(fields, sopstage.FieldUpdatedAt)
  27540. }
  27541. if m.status != nil {
  27542. fields = append(fields, sopstage.FieldStatus)
  27543. }
  27544. if m.deleted_at != nil {
  27545. fields = append(fields, sopstage.FieldDeletedAt)
  27546. }
  27547. if m.sop_task != nil {
  27548. fields = append(fields, sopstage.FieldTaskID)
  27549. }
  27550. if m.name != nil {
  27551. fields = append(fields, sopstage.FieldName)
  27552. }
  27553. if m.condition_type != nil {
  27554. fields = append(fields, sopstage.FieldConditionType)
  27555. }
  27556. if m.condition_operator != nil {
  27557. fields = append(fields, sopstage.FieldConditionOperator)
  27558. }
  27559. if m.condition_list != nil {
  27560. fields = append(fields, sopstage.FieldConditionList)
  27561. }
  27562. if m.action_message != nil {
  27563. fields = append(fields, sopstage.FieldActionMessage)
  27564. }
  27565. if m.action_label_add != nil {
  27566. fields = append(fields, sopstage.FieldActionLabelAdd)
  27567. }
  27568. if m.action_label_del != nil {
  27569. fields = append(fields, sopstage.FieldActionLabelDel)
  27570. }
  27571. if m.action_forward != nil {
  27572. fields = append(fields, sopstage.FieldActionForward)
  27573. }
  27574. if m.index_sort != nil {
  27575. fields = append(fields, sopstage.FieldIndexSort)
  27576. }
  27577. return fields
  27578. }
  27579. // Field returns the value of a field with the given name. The second boolean
  27580. // return value indicates that this field was not set, or was not defined in the
  27581. // schema.
  27582. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  27583. switch name {
  27584. case sopstage.FieldCreatedAt:
  27585. return m.CreatedAt()
  27586. case sopstage.FieldUpdatedAt:
  27587. return m.UpdatedAt()
  27588. case sopstage.FieldStatus:
  27589. return m.Status()
  27590. case sopstage.FieldDeletedAt:
  27591. return m.DeletedAt()
  27592. case sopstage.FieldTaskID:
  27593. return m.TaskID()
  27594. case sopstage.FieldName:
  27595. return m.Name()
  27596. case sopstage.FieldConditionType:
  27597. return m.ConditionType()
  27598. case sopstage.FieldConditionOperator:
  27599. return m.ConditionOperator()
  27600. case sopstage.FieldConditionList:
  27601. return m.ConditionList()
  27602. case sopstage.FieldActionMessage:
  27603. return m.ActionMessage()
  27604. case sopstage.FieldActionLabelAdd:
  27605. return m.ActionLabelAdd()
  27606. case sopstage.FieldActionLabelDel:
  27607. return m.ActionLabelDel()
  27608. case sopstage.FieldActionForward:
  27609. return m.ActionForward()
  27610. case sopstage.FieldIndexSort:
  27611. return m.IndexSort()
  27612. }
  27613. return nil, false
  27614. }
  27615. // OldField returns the old value of the field from the database. An error is
  27616. // returned if the mutation operation is not UpdateOne, or the query to the
  27617. // database failed.
  27618. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27619. switch name {
  27620. case sopstage.FieldCreatedAt:
  27621. return m.OldCreatedAt(ctx)
  27622. case sopstage.FieldUpdatedAt:
  27623. return m.OldUpdatedAt(ctx)
  27624. case sopstage.FieldStatus:
  27625. return m.OldStatus(ctx)
  27626. case sopstage.FieldDeletedAt:
  27627. return m.OldDeletedAt(ctx)
  27628. case sopstage.FieldTaskID:
  27629. return m.OldTaskID(ctx)
  27630. case sopstage.FieldName:
  27631. return m.OldName(ctx)
  27632. case sopstage.FieldConditionType:
  27633. return m.OldConditionType(ctx)
  27634. case sopstage.FieldConditionOperator:
  27635. return m.OldConditionOperator(ctx)
  27636. case sopstage.FieldConditionList:
  27637. return m.OldConditionList(ctx)
  27638. case sopstage.FieldActionMessage:
  27639. return m.OldActionMessage(ctx)
  27640. case sopstage.FieldActionLabelAdd:
  27641. return m.OldActionLabelAdd(ctx)
  27642. case sopstage.FieldActionLabelDel:
  27643. return m.OldActionLabelDel(ctx)
  27644. case sopstage.FieldActionForward:
  27645. return m.OldActionForward(ctx)
  27646. case sopstage.FieldIndexSort:
  27647. return m.OldIndexSort(ctx)
  27648. }
  27649. return nil, fmt.Errorf("unknown SopStage field %s", name)
  27650. }
  27651. // SetField sets the value of a field with the given name. It returns an error if
  27652. // the field is not defined in the schema, or if the type mismatched the field
  27653. // type.
  27654. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  27655. switch name {
  27656. case sopstage.FieldCreatedAt:
  27657. v, ok := value.(time.Time)
  27658. if !ok {
  27659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27660. }
  27661. m.SetCreatedAt(v)
  27662. return nil
  27663. case sopstage.FieldUpdatedAt:
  27664. v, ok := value.(time.Time)
  27665. if !ok {
  27666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27667. }
  27668. m.SetUpdatedAt(v)
  27669. return nil
  27670. case sopstage.FieldStatus:
  27671. v, ok := value.(uint8)
  27672. if !ok {
  27673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27674. }
  27675. m.SetStatus(v)
  27676. return nil
  27677. case sopstage.FieldDeletedAt:
  27678. v, ok := value.(time.Time)
  27679. if !ok {
  27680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27681. }
  27682. m.SetDeletedAt(v)
  27683. return nil
  27684. case sopstage.FieldTaskID:
  27685. v, ok := value.(uint64)
  27686. if !ok {
  27687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27688. }
  27689. m.SetTaskID(v)
  27690. return nil
  27691. case sopstage.FieldName:
  27692. v, ok := value.(string)
  27693. if !ok {
  27694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27695. }
  27696. m.SetName(v)
  27697. return nil
  27698. case sopstage.FieldConditionType:
  27699. v, ok := value.(int)
  27700. if !ok {
  27701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27702. }
  27703. m.SetConditionType(v)
  27704. return nil
  27705. case sopstage.FieldConditionOperator:
  27706. v, ok := value.(int)
  27707. if !ok {
  27708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27709. }
  27710. m.SetConditionOperator(v)
  27711. return nil
  27712. case sopstage.FieldConditionList:
  27713. v, ok := value.([]custom_types.Condition)
  27714. if !ok {
  27715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27716. }
  27717. m.SetConditionList(v)
  27718. return nil
  27719. case sopstage.FieldActionMessage:
  27720. v, ok := value.([]custom_types.Action)
  27721. if !ok {
  27722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27723. }
  27724. m.SetActionMessage(v)
  27725. return nil
  27726. case sopstage.FieldActionLabelAdd:
  27727. v, ok := value.([]uint64)
  27728. if !ok {
  27729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27730. }
  27731. m.SetActionLabelAdd(v)
  27732. return nil
  27733. case sopstage.FieldActionLabelDel:
  27734. v, ok := value.([]uint64)
  27735. if !ok {
  27736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27737. }
  27738. m.SetActionLabelDel(v)
  27739. return nil
  27740. case sopstage.FieldActionForward:
  27741. v, ok := value.(*custom_types.ActionForward)
  27742. if !ok {
  27743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27744. }
  27745. m.SetActionForward(v)
  27746. return nil
  27747. case sopstage.FieldIndexSort:
  27748. v, ok := value.(int)
  27749. if !ok {
  27750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27751. }
  27752. m.SetIndexSort(v)
  27753. return nil
  27754. }
  27755. return fmt.Errorf("unknown SopStage field %s", name)
  27756. }
  27757. // AddedFields returns all numeric fields that were incremented/decremented during
  27758. // this mutation.
  27759. func (m *SopStageMutation) AddedFields() []string {
  27760. var fields []string
  27761. if m.addstatus != nil {
  27762. fields = append(fields, sopstage.FieldStatus)
  27763. }
  27764. if m.addcondition_type != nil {
  27765. fields = append(fields, sopstage.FieldConditionType)
  27766. }
  27767. if m.addcondition_operator != nil {
  27768. fields = append(fields, sopstage.FieldConditionOperator)
  27769. }
  27770. if m.addindex_sort != nil {
  27771. fields = append(fields, sopstage.FieldIndexSort)
  27772. }
  27773. return fields
  27774. }
  27775. // AddedField returns the numeric value that was incremented/decremented on a field
  27776. // with the given name. The second boolean return value indicates that this field
  27777. // was not set, or was not defined in the schema.
  27778. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  27779. switch name {
  27780. case sopstage.FieldStatus:
  27781. return m.AddedStatus()
  27782. case sopstage.FieldConditionType:
  27783. return m.AddedConditionType()
  27784. case sopstage.FieldConditionOperator:
  27785. return m.AddedConditionOperator()
  27786. case sopstage.FieldIndexSort:
  27787. return m.AddedIndexSort()
  27788. }
  27789. return nil, false
  27790. }
  27791. // AddField adds the value to the field with the given name. It returns an error if
  27792. // the field is not defined in the schema, or if the type mismatched the field
  27793. // type.
  27794. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  27795. switch name {
  27796. case sopstage.FieldStatus:
  27797. v, ok := value.(int8)
  27798. if !ok {
  27799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27800. }
  27801. m.AddStatus(v)
  27802. return nil
  27803. case sopstage.FieldConditionType:
  27804. v, ok := value.(int)
  27805. if !ok {
  27806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27807. }
  27808. m.AddConditionType(v)
  27809. return nil
  27810. case sopstage.FieldConditionOperator:
  27811. v, ok := value.(int)
  27812. if !ok {
  27813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27814. }
  27815. m.AddConditionOperator(v)
  27816. return nil
  27817. case sopstage.FieldIndexSort:
  27818. v, ok := value.(int)
  27819. if !ok {
  27820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27821. }
  27822. m.AddIndexSort(v)
  27823. return nil
  27824. }
  27825. return fmt.Errorf("unknown SopStage numeric field %s", name)
  27826. }
  27827. // ClearedFields returns all nullable fields that were cleared during this
  27828. // mutation.
  27829. func (m *SopStageMutation) ClearedFields() []string {
  27830. var fields []string
  27831. if m.FieldCleared(sopstage.FieldStatus) {
  27832. fields = append(fields, sopstage.FieldStatus)
  27833. }
  27834. if m.FieldCleared(sopstage.FieldDeletedAt) {
  27835. fields = append(fields, sopstage.FieldDeletedAt)
  27836. }
  27837. if m.FieldCleared(sopstage.FieldActionMessage) {
  27838. fields = append(fields, sopstage.FieldActionMessage)
  27839. }
  27840. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  27841. fields = append(fields, sopstage.FieldActionLabelAdd)
  27842. }
  27843. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  27844. fields = append(fields, sopstage.FieldActionLabelDel)
  27845. }
  27846. if m.FieldCleared(sopstage.FieldActionForward) {
  27847. fields = append(fields, sopstage.FieldActionForward)
  27848. }
  27849. if m.FieldCleared(sopstage.FieldIndexSort) {
  27850. fields = append(fields, sopstage.FieldIndexSort)
  27851. }
  27852. return fields
  27853. }
  27854. // FieldCleared returns a boolean indicating if a field with the given name was
  27855. // cleared in this mutation.
  27856. func (m *SopStageMutation) FieldCleared(name string) bool {
  27857. _, ok := m.clearedFields[name]
  27858. return ok
  27859. }
  27860. // ClearField clears the value of the field with the given name. It returns an
  27861. // error if the field is not defined in the schema.
  27862. func (m *SopStageMutation) ClearField(name string) error {
  27863. switch name {
  27864. case sopstage.FieldStatus:
  27865. m.ClearStatus()
  27866. return nil
  27867. case sopstage.FieldDeletedAt:
  27868. m.ClearDeletedAt()
  27869. return nil
  27870. case sopstage.FieldActionMessage:
  27871. m.ClearActionMessage()
  27872. return nil
  27873. case sopstage.FieldActionLabelAdd:
  27874. m.ClearActionLabelAdd()
  27875. return nil
  27876. case sopstage.FieldActionLabelDel:
  27877. m.ClearActionLabelDel()
  27878. return nil
  27879. case sopstage.FieldActionForward:
  27880. m.ClearActionForward()
  27881. return nil
  27882. case sopstage.FieldIndexSort:
  27883. m.ClearIndexSort()
  27884. return nil
  27885. }
  27886. return fmt.Errorf("unknown SopStage nullable field %s", name)
  27887. }
  27888. // ResetField resets all changes in the mutation for the field with the given name.
  27889. // It returns an error if the field is not defined in the schema.
  27890. func (m *SopStageMutation) ResetField(name string) error {
  27891. switch name {
  27892. case sopstage.FieldCreatedAt:
  27893. m.ResetCreatedAt()
  27894. return nil
  27895. case sopstage.FieldUpdatedAt:
  27896. m.ResetUpdatedAt()
  27897. return nil
  27898. case sopstage.FieldStatus:
  27899. m.ResetStatus()
  27900. return nil
  27901. case sopstage.FieldDeletedAt:
  27902. m.ResetDeletedAt()
  27903. return nil
  27904. case sopstage.FieldTaskID:
  27905. m.ResetTaskID()
  27906. return nil
  27907. case sopstage.FieldName:
  27908. m.ResetName()
  27909. return nil
  27910. case sopstage.FieldConditionType:
  27911. m.ResetConditionType()
  27912. return nil
  27913. case sopstage.FieldConditionOperator:
  27914. m.ResetConditionOperator()
  27915. return nil
  27916. case sopstage.FieldConditionList:
  27917. m.ResetConditionList()
  27918. return nil
  27919. case sopstage.FieldActionMessage:
  27920. m.ResetActionMessage()
  27921. return nil
  27922. case sopstage.FieldActionLabelAdd:
  27923. m.ResetActionLabelAdd()
  27924. return nil
  27925. case sopstage.FieldActionLabelDel:
  27926. m.ResetActionLabelDel()
  27927. return nil
  27928. case sopstage.FieldActionForward:
  27929. m.ResetActionForward()
  27930. return nil
  27931. case sopstage.FieldIndexSort:
  27932. m.ResetIndexSort()
  27933. return nil
  27934. }
  27935. return fmt.Errorf("unknown SopStage field %s", name)
  27936. }
  27937. // AddedEdges returns all edge names that were set/added in this mutation.
  27938. func (m *SopStageMutation) AddedEdges() []string {
  27939. edges := make([]string, 0, 3)
  27940. if m.sop_task != nil {
  27941. edges = append(edges, sopstage.EdgeSopTask)
  27942. }
  27943. if m.stage_nodes != nil {
  27944. edges = append(edges, sopstage.EdgeStageNodes)
  27945. }
  27946. if m.stage_messages != nil {
  27947. edges = append(edges, sopstage.EdgeStageMessages)
  27948. }
  27949. return edges
  27950. }
  27951. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27952. // name in this mutation.
  27953. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  27954. switch name {
  27955. case sopstage.EdgeSopTask:
  27956. if id := m.sop_task; id != nil {
  27957. return []ent.Value{*id}
  27958. }
  27959. case sopstage.EdgeStageNodes:
  27960. ids := make([]ent.Value, 0, len(m.stage_nodes))
  27961. for id := range m.stage_nodes {
  27962. ids = append(ids, id)
  27963. }
  27964. return ids
  27965. case sopstage.EdgeStageMessages:
  27966. ids := make([]ent.Value, 0, len(m.stage_messages))
  27967. for id := range m.stage_messages {
  27968. ids = append(ids, id)
  27969. }
  27970. return ids
  27971. }
  27972. return nil
  27973. }
  27974. // RemovedEdges returns all edge names that were removed in this mutation.
  27975. func (m *SopStageMutation) RemovedEdges() []string {
  27976. edges := make([]string, 0, 3)
  27977. if m.removedstage_nodes != nil {
  27978. edges = append(edges, sopstage.EdgeStageNodes)
  27979. }
  27980. if m.removedstage_messages != nil {
  27981. edges = append(edges, sopstage.EdgeStageMessages)
  27982. }
  27983. return edges
  27984. }
  27985. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27986. // the given name in this mutation.
  27987. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  27988. switch name {
  27989. case sopstage.EdgeStageNodes:
  27990. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  27991. for id := range m.removedstage_nodes {
  27992. ids = append(ids, id)
  27993. }
  27994. return ids
  27995. case sopstage.EdgeStageMessages:
  27996. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  27997. for id := range m.removedstage_messages {
  27998. ids = append(ids, id)
  27999. }
  28000. return ids
  28001. }
  28002. return nil
  28003. }
  28004. // ClearedEdges returns all edge names that were cleared in this mutation.
  28005. func (m *SopStageMutation) ClearedEdges() []string {
  28006. edges := make([]string, 0, 3)
  28007. if m.clearedsop_task {
  28008. edges = append(edges, sopstage.EdgeSopTask)
  28009. }
  28010. if m.clearedstage_nodes {
  28011. edges = append(edges, sopstage.EdgeStageNodes)
  28012. }
  28013. if m.clearedstage_messages {
  28014. edges = append(edges, sopstage.EdgeStageMessages)
  28015. }
  28016. return edges
  28017. }
  28018. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28019. // was cleared in this mutation.
  28020. func (m *SopStageMutation) EdgeCleared(name string) bool {
  28021. switch name {
  28022. case sopstage.EdgeSopTask:
  28023. return m.clearedsop_task
  28024. case sopstage.EdgeStageNodes:
  28025. return m.clearedstage_nodes
  28026. case sopstage.EdgeStageMessages:
  28027. return m.clearedstage_messages
  28028. }
  28029. return false
  28030. }
  28031. // ClearEdge clears the value of the edge with the given name. It returns an error
  28032. // if that edge is not defined in the schema.
  28033. func (m *SopStageMutation) ClearEdge(name string) error {
  28034. switch name {
  28035. case sopstage.EdgeSopTask:
  28036. m.ClearSopTask()
  28037. return nil
  28038. }
  28039. return fmt.Errorf("unknown SopStage unique edge %s", name)
  28040. }
  28041. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28042. // It returns an error if the edge is not defined in the schema.
  28043. func (m *SopStageMutation) ResetEdge(name string) error {
  28044. switch name {
  28045. case sopstage.EdgeSopTask:
  28046. m.ResetSopTask()
  28047. return nil
  28048. case sopstage.EdgeStageNodes:
  28049. m.ResetStageNodes()
  28050. return nil
  28051. case sopstage.EdgeStageMessages:
  28052. m.ResetStageMessages()
  28053. return nil
  28054. }
  28055. return fmt.Errorf("unknown SopStage edge %s", name)
  28056. }
  28057. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  28058. type SopTaskMutation struct {
  28059. config
  28060. op Op
  28061. typ string
  28062. id *uint64
  28063. created_at *time.Time
  28064. updated_at *time.Time
  28065. status *uint8
  28066. addstatus *int8
  28067. deleted_at *time.Time
  28068. name *string
  28069. bot_wxid_list *[]string
  28070. appendbot_wxid_list []string
  28071. _type *int
  28072. add_type *int
  28073. plan_start_time *time.Time
  28074. plan_end_time *time.Time
  28075. creator_id *string
  28076. organization_id *uint64
  28077. addorganization_id *int64
  28078. token *[]string
  28079. appendtoken []string
  28080. clearedFields map[string]struct{}
  28081. task_stages map[uint64]struct{}
  28082. removedtask_stages map[uint64]struct{}
  28083. clearedtask_stages bool
  28084. done bool
  28085. oldValue func(context.Context) (*SopTask, error)
  28086. predicates []predicate.SopTask
  28087. }
  28088. var _ ent.Mutation = (*SopTaskMutation)(nil)
  28089. // soptaskOption allows management of the mutation configuration using functional options.
  28090. type soptaskOption func(*SopTaskMutation)
  28091. // newSopTaskMutation creates new mutation for the SopTask entity.
  28092. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  28093. m := &SopTaskMutation{
  28094. config: c,
  28095. op: op,
  28096. typ: TypeSopTask,
  28097. clearedFields: make(map[string]struct{}),
  28098. }
  28099. for _, opt := range opts {
  28100. opt(m)
  28101. }
  28102. return m
  28103. }
  28104. // withSopTaskID sets the ID field of the mutation.
  28105. func withSopTaskID(id uint64) soptaskOption {
  28106. return func(m *SopTaskMutation) {
  28107. var (
  28108. err error
  28109. once sync.Once
  28110. value *SopTask
  28111. )
  28112. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  28113. once.Do(func() {
  28114. if m.done {
  28115. err = errors.New("querying old values post mutation is not allowed")
  28116. } else {
  28117. value, err = m.Client().SopTask.Get(ctx, id)
  28118. }
  28119. })
  28120. return value, err
  28121. }
  28122. m.id = &id
  28123. }
  28124. }
  28125. // withSopTask sets the old SopTask of the mutation.
  28126. func withSopTask(node *SopTask) soptaskOption {
  28127. return func(m *SopTaskMutation) {
  28128. m.oldValue = func(context.Context) (*SopTask, error) {
  28129. return node, nil
  28130. }
  28131. m.id = &node.ID
  28132. }
  28133. }
  28134. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28135. // executed in a transaction (ent.Tx), a transactional client is returned.
  28136. func (m SopTaskMutation) Client() *Client {
  28137. client := &Client{config: m.config}
  28138. client.init()
  28139. return client
  28140. }
  28141. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28142. // it returns an error otherwise.
  28143. func (m SopTaskMutation) Tx() (*Tx, error) {
  28144. if _, ok := m.driver.(*txDriver); !ok {
  28145. return nil, errors.New("ent: mutation is not running in a transaction")
  28146. }
  28147. tx := &Tx{config: m.config}
  28148. tx.init()
  28149. return tx, nil
  28150. }
  28151. // SetID sets the value of the id field. Note that this
  28152. // operation is only accepted on creation of SopTask entities.
  28153. func (m *SopTaskMutation) SetID(id uint64) {
  28154. m.id = &id
  28155. }
  28156. // ID returns the ID value in the mutation. Note that the ID is only available
  28157. // if it was provided to the builder or after it was returned from the database.
  28158. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  28159. if m.id == nil {
  28160. return
  28161. }
  28162. return *m.id, true
  28163. }
  28164. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28165. // That means, if the mutation is applied within a transaction with an isolation level such
  28166. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28167. // or updated by the mutation.
  28168. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  28169. switch {
  28170. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28171. id, exists := m.ID()
  28172. if exists {
  28173. return []uint64{id}, nil
  28174. }
  28175. fallthrough
  28176. case m.op.Is(OpUpdate | OpDelete):
  28177. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  28178. default:
  28179. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28180. }
  28181. }
  28182. // SetCreatedAt sets the "created_at" field.
  28183. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  28184. m.created_at = &t
  28185. }
  28186. // CreatedAt returns the value of the "created_at" field in the mutation.
  28187. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  28188. v := m.created_at
  28189. if v == nil {
  28190. return
  28191. }
  28192. return *v, true
  28193. }
  28194. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  28195. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28197. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28198. if !m.op.Is(OpUpdateOne) {
  28199. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28200. }
  28201. if m.id == nil || m.oldValue == nil {
  28202. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28203. }
  28204. oldValue, err := m.oldValue(ctx)
  28205. if err != nil {
  28206. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28207. }
  28208. return oldValue.CreatedAt, nil
  28209. }
  28210. // ResetCreatedAt resets all changes to the "created_at" field.
  28211. func (m *SopTaskMutation) ResetCreatedAt() {
  28212. m.created_at = nil
  28213. }
  28214. // SetUpdatedAt sets the "updated_at" field.
  28215. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  28216. m.updated_at = &t
  28217. }
  28218. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28219. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  28220. v := m.updated_at
  28221. if v == nil {
  28222. return
  28223. }
  28224. return *v, true
  28225. }
  28226. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  28227. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28229. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28230. if !m.op.Is(OpUpdateOne) {
  28231. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28232. }
  28233. if m.id == nil || m.oldValue == nil {
  28234. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28235. }
  28236. oldValue, err := m.oldValue(ctx)
  28237. if err != nil {
  28238. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28239. }
  28240. return oldValue.UpdatedAt, nil
  28241. }
  28242. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28243. func (m *SopTaskMutation) ResetUpdatedAt() {
  28244. m.updated_at = nil
  28245. }
  28246. // SetStatus sets the "status" field.
  28247. func (m *SopTaskMutation) SetStatus(u uint8) {
  28248. m.status = &u
  28249. m.addstatus = nil
  28250. }
  28251. // Status returns the value of the "status" field in the mutation.
  28252. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  28253. v := m.status
  28254. if v == nil {
  28255. return
  28256. }
  28257. return *v, true
  28258. }
  28259. // OldStatus returns the old "status" field's value of the SopTask entity.
  28260. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28262. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28263. if !m.op.Is(OpUpdateOne) {
  28264. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28265. }
  28266. if m.id == nil || m.oldValue == nil {
  28267. return v, errors.New("OldStatus requires an ID field in the mutation")
  28268. }
  28269. oldValue, err := m.oldValue(ctx)
  28270. if err != nil {
  28271. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28272. }
  28273. return oldValue.Status, nil
  28274. }
  28275. // AddStatus adds u to the "status" field.
  28276. func (m *SopTaskMutation) AddStatus(u int8) {
  28277. if m.addstatus != nil {
  28278. *m.addstatus += u
  28279. } else {
  28280. m.addstatus = &u
  28281. }
  28282. }
  28283. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28284. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  28285. v := m.addstatus
  28286. if v == nil {
  28287. return
  28288. }
  28289. return *v, true
  28290. }
  28291. // ClearStatus clears the value of the "status" field.
  28292. func (m *SopTaskMutation) ClearStatus() {
  28293. m.status = nil
  28294. m.addstatus = nil
  28295. m.clearedFields[soptask.FieldStatus] = struct{}{}
  28296. }
  28297. // StatusCleared returns if the "status" field was cleared in this mutation.
  28298. func (m *SopTaskMutation) StatusCleared() bool {
  28299. _, ok := m.clearedFields[soptask.FieldStatus]
  28300. return ok
  28301. }
  28302. // ResetStatus resets all changes to the "status" field.
  28303. func (m *SopTaskMutation) ResetStatus() {
  28304. m.status = nil
  28305. m.addstatus = nil
  28306. delete(m.clearedFields, soptask.FieldStatus)
  28307. }
  28308. // SetDeletedAt sets the "deleted_at" field.
  28309. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  28310. m.deleted_at = &t
  28311. }
  28312. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28313. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  28314. v := m.deleted_at
  28315. if v == nil {
  28316. return
  28317. }
  28318. return *v, true
  28319. }
  28320. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  28321. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28323. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28324. if !m.op.Is(OpUpdateOne) {
  28325. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28326. }
  28327. if m.id == nil || m.oldValue == nil {
  28328. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28329. }
  28330. oldValue, err := m.oldValue(ctx)
  28331. if err != nil {
  28332. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28333. }
  28334. return oldValue.DeletedAt, nil
  28335. }
  28336. // ClearDeletedAt clears the value of the "deleted_at" field.
  28337. func (m *SopTaskMutation) ClearDeletedAt() {
  28338. m.deleted_at = nil
  28339. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  28340. }
  28341. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28342. func (m *SopTaskMutation) DeletedAtCleared() bool {
  28343. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  28344. return ok
  28345. }
  28346. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28347. func (m *SopTaskMutation) ResetDeletedAt() {
  28348. m.deleted_at = nil
  28349. delete(m.clearedFields, soptask.FieldDeletedAt)
  28350. }
  28351. // SetName sets the "name" field.
  28352. func (m *SopTaskMutation) SetName(s string) {
  28353. m.name = &s
  28354. }
  28355. // Name returns the value of the "name" field in the mutation.
  28356. func (m *SopTaskMutation) Name() (r string, exists bool) {
  28357. v := m.name
  28358. if v == nil {
  28359. return
  28360. }
  28361. return *v, true
  28362. }
  28363. // OldName returns the old "name" field's value of the SopTask entity.
  28364. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28366. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  28367. if !m.op.Is(OpUpdateOne) {
  28368. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28369. }
  28370. if m.id == nil || m.oldValue == nil {
  28371. return v, errors.New("OldName requires an ID field in the mutation")
  28372. }
  28373. oldValue, err := m.oldValue(ctx)
  28374. if err != nil {
  28375. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28376. }
  28377. return oldValue.Name, nil
  28378. }
  28379. // ResetName resets all changes to the "name" field.
  28380. func (m *SopTaskMutation) ResetName() {
  28381. m.name = nil
  28382. }
  28383. // SetBotWxidList sets the "bot_wxid_list" field.
  28384. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  28385. m.bot_wxid_list = &s
  28386. m.appendbot_wxid_list = nil
  28387. }
  28388. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  28389. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  28390. v := m.bot_wxid_list
  28391. if v == nil {
  28392. return
  28393. }
  28394. return *v, true
  28395. }
  28396. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  28397. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28399. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  28400. if !m.op.Is(OpUpdateOne) {
  28401. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  28402. }
  28403. if m.id == nil || m.oldValue == nil {
  28404. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  28405. }
  28406. oldValue, err := m.oldValue(ctx)
  28407. if err != nil {
  28408. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  28409. }
  28410. return oldValue.BotWxidList, nil
  28411. }
  28412. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  28413. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  28414. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  28415. }
  28416. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  28417. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  28418. if len(m.appendbot_wxid_list) == 0 {
  28419. return nil, false
  28420. }
  28421. return m.appendbot_wxid_list, true
  28422. }
  28423. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  28424. func (m *SopTaskMutation) ClearBotWxidList() {
  28425. m.bot_wxid_list = nil
  28426. m.appendbot_wxid_list = nil
  28427. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  28428. }
  28429. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  28430. func (m *SopTaskMutation) BotWxidListCleared() bool {
  28431. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  28432. return ok
  28433. }
  28434. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  28435. func (m *SopTaskMutation) ResetBotWxidList() {
  28436. m.bot_wxid_list = nil
  28437. m.appendbot_wxid_list = nil
  28438. delete(m.clearedFields, soptask.FieldBotWxidList)
  28439. }
  28440. // SetType sets the "type" field.
  28441. func (m *SopTaskMutation) SetType(i int) {
  28442. m._type = &i
  28443. m.add_type = nil
  28444. }
  28445. // GetType returns the value of the "type" field in the mutation.
  28446. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  28447. v := m._type
  28448. if v == nil {
  28449. return
  28450. }
  28451. return *v, true
  28452. }
  28453. // OldType returns the old "type" field's value of the SopTask entity.
  28454. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28456. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  28457. if !m.op.Is(OpUpdateOne) {
  28458. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28459. }
  28460. if m.id == nil || m.oldValue == nil {
  28461. return v, errors.New("OldType requires an ID field in the mutation")
  28462. }
  28463. oldValue, err := m.oldValue(ctx)
  28464. if err != nil {
  28465. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28466. }
  28467. return oldValue.Type, nil
  28468. }
  28469. // AddType adds i to the "type" field.
  28470. func (m *SopTaskMutation) AddType(i int) {
  28471. if m.add_type != nil {
  28472. *m.add_type += i
  28473. } else {
  28474. m.add_type = &i
  28475. }
  28476. }
  28477. // AddedType returns the value that was added to the "type" field in this mutation.
  28478. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  28479. v := m.add_type
  28480. if v == nil {
  28481. return
  28482. }
  28483. return *v, true
  28484. }
  28485. // ResetType resets all changes to the "type" field.
  28486. func (m *SopTaskMutation) ResetType() {
  28487. m._type = nil
  28488. m.add_type = nil
  28489. }
  28490. // SetPlanStartTime sets the "plan_start_time" field.
  28491. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  28492. m.plan_start_time = &t
  28493. }
  28494. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  28495. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  28496. v := m.plan_start_time
  28497. if v == nil {
  28498. return
  28499. }
  28500. return *v, true
  28501. }
  28502. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  28503. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28505. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  28506. if !m.op.Is(OpUpdateOne) {
  28507. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  28508. }
  28509. if m.id == nil || m.oldValue == nil {
  28510. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  28511. }
  28512. oldValue, err := m.oldValue(ctx)
  28513. if err != nil {
  28514. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  28515. }
  28516. return oldValue.PlanStartTime, nil
  28517. }
  28518. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  28519. func (m *SopTaskMutation) ClearPlanStartTime() {
  28520. m.plan_start_time = nil
  28521. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  28522. }
  28523. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  28524. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  28525. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  28526. return ok
  28527. }
  28528. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  28529. func (m *SopTaskMutation) ResetPlanStartTime() {
  28530. m.plan_start_time = nil
  28531. delete(m.clearedFields, soptask.FieldPlanStartTime)
  28532. }
  28533. // SetPlanEndTime sets the "plan_end_time" field.
  28534. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  28535. m.plan_end_time = &t
  28536. }
  28537. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  28538. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  28539. v := m.plan_end_time
  28540. if v == nil {
  28541. return
  28542. }
  28543. return *v, true
  28544. }
  28545. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  28546. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28548. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  28549. if !m.op.Is(OpUpdateOne) {
  28550. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  28551. }
  28552. if m.id == nil || m.oldValue == nil {
  28553. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  28554. }
  28555. oldValue, err := m.oldValue(ctx)
  28556. if err != nil {
  28557. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  28558. }
  28559. return oldValue.PlanEndTime, nil
  28560. }
  28561. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  28562. func (m *SopTaskMutation) ClearPlanEndTime() {
  28563. m.plan_end_time = nil
  28564. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  28565. }
  28566. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  28567. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  28568. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  28569. return ok
  28570. }
  28571. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  28572. func (m *SopTaskMutation) ResetPlanEndTime() {
  28573. m.plan_end_time = nil
  28574. delete(m.clearedFields, soptask.FieldPlanEndTime)
  28575. }
  28576. // SetCreatorID sets the "creator_id" field.
  28577. func (m *SopTaskMutation) SetCreatorID(s string) {
  28578. m.creator_id = &s
  28579. }
  28580. // CreatorID returns the value of the "creator_id" field in the mutation.
  28581. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  28582. v := m.creator_id
  28583. if v == nil {
  28584. return
  28585. }
  28586. return *v, true
  28587. }
  28588. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  28589. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28591. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  28592. if !m.op.Is(OpUpdateOne) {
  28593. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  28594. }
  28595. if m.id == nil || m.oldValue == nil {
  28596. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  28597. }
  28598. oldValue, err := m.oldValue(ctx)
  28599. if err != nil {
  28600. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  28601. }
  28602. return oldValue.CreatorID, nil
  28603. }
  28604. // ClearCreatorID clears the value of the "creator_id" field.
  28605. func (m *SopTaskMutation) ClearCreatorID() {
  28606. m.creator_id = nil
  28607. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  28608. }
  28609. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  28610. func (m *SopTaskMutation) CreatorIDCleared() bool {
  28611. _, ok := m.clearedFields[soptask.FieldCreatorID]
  28612. return ok
  28613. }
  28614. // ResetCreatorID resets all changes to the "creator_id" field.
  28615. func (m *SopTaskMutation) ResetCreatorID() {
  28616. m.creator_id = nil
  28617. delete(m.clearedFields, soptask.FieldCreatorID)
  28618. }
  28619. // SetOrganizationID sets the "organization_id" field.
  28620. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  28621. m.organization_id = &u
  28622. m.addorganization_id = nil
  28623. }
  28624. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28625. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  28626. v := m.organization_id
  28627. if v == nil {
  28628. return
  28629. }
  28630. return *v, true
  28631. }
  28632. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  28633. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28635. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28636. if !m.op.Is(OpUpdateOne) {
  28637. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28638. }
  28639. if m.id == nil || m.oldValue == nil {
  28640. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28641. }
  28642. oldValue, err := m.oldValue(ctx)
  28643. if err != nil {
  28644. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28645. }
  28646. return oldValue.OrganizationID, nil
  28647. }
  28648. // AddOrganizationID adds u to the "organization_id" field.
  28649. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  28650. if m.addorganization_id != nil {
  28651. *m.addorganization_id += u
  28652. } else {
  28653. m.addorganization_id = &u
  28654. }
  28655. }
  28656. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28657. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  28658. v := m.addorganization_id
  28659. if v == nil {
  28660. return
  28661. }
  28662. return *v, true
  28663. }
  28664. // ClearOrganizationID clears the value of the "organization_id" field.
  28665. func (m *SopTaskMutation) ClearOrganizationID() {
  28666. m.organization_id = nil
  28667. m.addorganization_id = nil
  28668. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  28669. }
  28670. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28671. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  28672. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  28673. return ok
  28674. }
  28675. // ResetOrganizationID resets all changes to the "organization_id" field.
  28676. func (m *SopTaskMutation) ResetOrganizationID() {
  28677. m.organization_id = nil
  28678. m.addorganization_id = nil
  28679. delete(m.clearedFields, soptask.FieldOrganizationID)
  28680. }
  28681. // SetToken sets the "token" field.
  28682. func (m *SopTaskMutation) SetToken(s []string) {
  28683. m.token = &s
  28684. m.appendtoken = nil
  28685. }
  28686. // Token returns the value of the "token" field in the mutation.
  28687. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  28688. v := m.token
  28689. if v == nil {
  28690. return
  28691. }
  28692. return *v, true
  28693. }
  28694. // OldToken returns the old "token" field's value of the SopTask entity.
  28695. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  28696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28697. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  28698. if !m.op.Is(OpUpdateOne) {
  28699. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28700. }
  28701. if m.id == nil || m.oldValue == nil {
  28702. return v, errors.New("OldToken requires an ID field in the mutation")
  28703. }
  28704. oldValue, err := m.oldValue(ctx)
  28705. if err != nil {
  28706. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28707. }
  28708. return oldValue.Token, nil
  28709. }
  28710. // AppendToken adds s to the "token" field.
  28711. func (m *SopTaskMutation) AppendToken(s []string) {
  28712. m.appendtoken = append(m.appendtoken, s...)
  28713. }
  28714. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  28715. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  28716. if len(m.appendtoken) == 0 {
  28717. return nil, false
  28718. }
  28719. return m.appendtoken, true
  28720. }
  28721. // ClearToken clears the value of the "token" field.
  28722. func (m *SopTaskMutation) ClearToken() {
  28723. m.token = nil
  28724. m.appendtoken = nil
  28725. m.clearedFields[soptask.FieldToken] = struct{}{}
  28726. }
  28727. // TokenCleared returns if the "token" field was cleared in this mutation.
  28728. func (m *SopTaskMutation) TokenCleared() bool {
  28729. _, ok := m.clearedFields[soptask.FieldToken]
  28730. return ok
  28731. }
  28732. // ResetToken resets all changes to the "token" field.
  28733. func (m *SopTaskMutation) ResetToken() {
  28734. m.token = nil
  28735. m.appendtoken = nil
  28736. delete(m.clearedFields, soptask.FieldToken)
  28737. }
  28738. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  28739. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  28740. if m.task_stages == nil {
  28741. m.task_stages = make(map[uint64]struct{})
  28742. }
  28743. for i := range ids {
  28744. m.task_stages[ids[i]] = struct{}{}
  28745. }
  28746. }
  28747. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  28748. func (m *SopTaskMutation) ClearTaskStages() {
  28749. m.clearedtask_stages = true
  28750. }
  28751. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  28752. func (m *SopTaskMutation) TaskStagesCleared() bool {
  28753. return m.clearedtask_stages
  28754. }
  28755. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  28756. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  28757. if m.removedtask_stages == nil {
  28758. m.removedtask_stages = make(map[uint64]struct{})
  28759. }
  28760. for i := range ids {
  28761. delete(m.task_stages, ids[i])
  28762. m.removedtask_stages[ids[i]] = struct{}{}
  28763. }
  28764. }
  28765. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  28766. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  28767. for id := range m.removedtask_stages {
  28768. ids = append(ids, id)
  28769. }
  28770. return
  28771. }
  28772. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  28773. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  28774. for id := range m.task_stages {
  28775. ids = append(ids, id)
  28776. }
  28777. return
  28778. }
  28779. // ResetTaskStages resets all changes to the "task_stages" edge.
  28780. func (m *SopTaskMutation) ResetTaskStages() {
  28781. m.task_stages = nil
  28782. m.clearedtask_stages = false
  28783. m.removedtask_stages = nil
  28784. }
  28785. // Where appends a list predicates to the SopTaskMutation builder.
  28786. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  28787. m.predicates = append(m.predicates, ps...)
  28788. }
  28789. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  28790. // users can use type-assertion to append predicates that do not depend on any generated package.
  28791. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  28792. p := make([]predicate.SopTask, len(ps))
  28793. for i := range ps {
  28794. p[i] = ps[i]
  28795. }
  28796. m.Where(p...)
  28797. }
  28798. // Op returns the operation name.
  28799. func (m *SopTaskMutation) Op() Op {
  28800. return m.op
  28801. }
  28802. // SetOp allows setting the mutation operation.
  28803. func (m *SopTaskMutation) SetOp(op Op) {
  28804. m.op = op
  28805. }
  28806. // Type returns the node type of this mutation (SopTask).
  28807. func (m *SopTaskMutation) Type() string {
  28808. return m.typ
  28809. }
  28810. // Fields returns all fields that were changed during this mutation. Note that in
  28811. // order to get all numeric fields that were incremented/decremented, call
  28812. // AddedFields().
  28813. func (m *SopTaskMutation) Fields() []string {
  28814. fields := make([]string, 0, 12)
  28815. if m.created_at != nil {
  28816. fields = append(fields, soptask.FieldCreatedAt)
  28817. }
  28818. if m.updated_at != nil {
  28819. fields = append(fields, soptask.FieldUpdatedAt)
  28820. }
  28821. if m.status != nil {
  28822. fields = append(fields, soptask.FieldStatus)
  28823. }
  28824. if m.deleted_at != nil {
  28825. fields = append(fields, soptask.FieldDeletedAt)
  28826. }
  28827. if m.name != nil {
  28828. fields = append(fields, soptask.FieldName)
  28829. }
  28830. if m.bot_wxid_list != nil {
  28831. fields = append(fields, soptask.FieldBotWxidList)
  28832. }
  28833. if m._type != nil {
  28834. fields = append(fields, soptask.FieldType)
  28835. }
  28836. if m.plan_start_time != nil {
  28837. fields = append(fields, soptask.FieldPlanStartTime)
  28838. }
  28839. if m.plan_end_time != nil {
  28840. fields = append(fields, soptask.FieldPlanEndTime)
  28841. }
  28842. if m.creator_id != nil {
  28843. fields = append(fields, soptask.FieldCreatorID)
  28844. }
  28845. if m.organization_id != nil {
  28846. fields = append(fields, soptask.FieldOrganizationID)
  28847. }
  28848. if m.token != nil {
  28849. fields = append(fields, soptask.FieldToken)
  28850. }
  28851. return fields
  28852. }
  28853. // Field returns the value of a field with the given name. The second boolean
  28854. // return value indicates that this field was not set, or was not defined in the
  28855. // schema.
  28856. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  28857. switch name {
  28858. case soptask.FieldCreatedAt:
  28859. return m.CreatedAt()
  28860. case soptask.FieldUpdatedAt:
  28861. return m.UpdatedAt()
  28862. case soptask.FieldStatus:
  28863. return m.Status()
  28864. case soptask.FieldDeletedAt:
  28865. return m.DeletedAt()
  28866. case soptask.FieldName:
  28867. return m.Name()
  28868. case soptask.FieldBotWxidList:
  28869. return m.BotWxidList()
  28870. case soptask.FieldType:
  28871. return m.GetType()
  28872. case soptask.FieldPlanStartTime:
  28873. return m.PlanStartTime()
  28874. case soptask.FieldPlanEndTime:
  28875. return m.PlanEndTime()
  28876. case soptask.FieldCreatorID:
  28877. return m.CreatorID()
  28878. case soptask.FieldOrganizationID:
  28879. return m.OrganizationID()
  28880. case soptask.FieldToken:
  28881. return m.Token()
  28882. }
  28883. return nil, false
  28884. }
  28885. // OldField returns the old value of the field from the database. An error is
  28886. // returned if the mutation operation is not UpdateOne, or the query to the
  28887. // database failed.
  28888. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28889. switch name {
  28890. case soptask.FieldCreatedAt:
  28891. return m.OldCreatedAt(ctx)
  28892. case soptask.FieldUpdatedAt:
  28893. return m.OldUpdatedAt(ctx)
  28894. case soptask.FieldStatus:
  28895. return m.OldStatus(ctx)
  28896. case soptask.FieldDeletedAt:
  28897. return m.OldDeletedAt(ctx)
  28898. case soptask.FieldName:
  28899. return m.OldName(ctx)
  28900. case soptask.FieldBotWxidList:
  28901. return m.OldBotWxidList(ctx)
  28902. case soptask.FieldType:
  28903. return m.OldType(ctx)
  28904. case soptask.FieldPlanStartTime:
  28905. return m.OldPlanStartTime(ctx)
  28906. case soptask.FieldPlanEndTime:
  28907. return m.OldPlanEndTime(ctx)
  28908. case soptask.FieldCreatorID:
  28909. return m.OldCreatorID(ctx)
  28910. case soptask.FieldOrganizationID:
  28911. return m.OldOrganizationID(ctx)
  28912. case soptask.FieldToken:
  28913. return m.OldToken(ctx)
  28914. }
  28915. return nil, fmt.Errorf("unknown SopTask field %s", name)
  28916. }
  28917. // SetField sets the value of a field with the given name. It returns an error if
  28918. // the field is not defined in the schema, or if the type mismatched the field
  28919. // type.
  28920. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  28921. switch name {
  28922. case soptask.FieldCreatedAt:
  28923. v, ok := value.(time.Time)
  28924. if !ok {
  28925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28926. }
  28927. m.SetCreatedAt(v)
  28928. return nil
  28929. case soptask.FieldUpdatedAt:
  28930. v, ok := value.(time.Time)
  28931. if !ok {
  28932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28933. }
  28934. m.SetUpdatedAt(v)
  28935. return nil
  28936. case soptask.FieldStatus:
  28937. v, ok := value.(uint8)
  28938. if !ok {
  28939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28940. }
  28941. m.SetStatus(v)
  28942. return nil
  28943. case soptask.FieldDeletedAt:
  28944. v, ok := value.(time.Time)
  28945. if !ok {
  28946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28947. }
  28948. m.SetDeletedAt(v)
  28949. return nil
  28950. case soptask.FieldName:
  28951. v, ok := value.(string)
  28952. if !ok {
  28953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28954. }
  28955. m.SetName(v)
  28956. return nil
  28957. case soptask.FieldBotWxidList:
  28958. v, ok := value.([]string)
  28959. if !ok {
  28960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28961. }
  28962. m.SetBotWxidList(v)
  28963. return nil
  28964. case soptask.FieldType:
  28965. v, ok := value.(int)
  28966. if !ok {
  28967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28968. }
  28969. m.SetType(v)
  28970. return nil
  28971. case soptask.FieldPlanStartTime:
  28972. v, ok := value.(time.Time)
  28973. if !ok {
  28974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28975. }
  28976. m.SetPlanStartTime(v)
  28977. return nil
  28978. case soptask.FieldPlanEndTime:
  28979. v, ok := value.(time.Time)
  28980. if !ok {
  28981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28982. }
  28983. m.SetPlanEndTime(v)
  28984. return nil
  28985. case soptask.FieldCreatorID:
  28986. v, ok := value.(string)
  28987. if !ok {
  28988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28989. }
  28990. m.SetCreatorID(v)
  28991. return nil
  28992. case soptask.FieldOrganizationID:
  28993. v, ok := value.(uint64)
  28994. if !ok {
  28995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28996. }
  28997. m.SetOrganizationID(v)
  28998. return nil
  28999. case soptask.FieldToken:
  29000. v, ok := value.([]string)
  29001. if !ok {
  29002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29003. }
  29004. m.SetToken(v)
  29005. return nil
  29006. }
  29007. return fmt.Errorf("unknown SopTask field %s", name)
  29008. }
  29009. // AddedFields returns all numeric fields that were incremented/decremented during
  29010. // this mutation.
  29011. func (m *SopTaskMutation) AddedFields() []string {
  29012. var fields []string
  29013. if m.addstatus != nil {
  29014. fields = append(fields, soptask.FieldStatus)
  29015. }
  29016. if m.add_type != nil {
  29017. fields = append(fields, soptask.FieldType)
  29018. }
  29019. if m.addorganization_id != nil {
  29020. fields = append(fields, soptask.FieldOrganizationID)
  29021. }
  29022. return fields
  29023. }
  29024. // AddedField returns the numeric value that was incremented/decremented on a field
  29025. // with the given name. The second boolean return value indicates that this field
  29026. // was not set, or was not defined in the schema.
  29027. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  29028. switch name {
  29029. case soptask.FieldStatus:
  29030. return m.AddedStatus()
  29031. case soptask.FieldType:
  29032. return m.AddedType()
  29033. case soptask.FieldOrganizationID:
  29034. return m.AddedOrganizationID()
  29035. }
  29036. return nil, false
  29037. }
  29038. // AddField adds the value to the field with the given name. It returns an error if
  29039. // the field is not defined in the schema, or if the type mismatched the field
  29040. // type.
  29041. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  29042. switch name {
  29043. case soptask.FieldStatus:
  29044. v, ok := value.(int8)
  29045. if !ok {
  29046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29047. }
  29048. m.AddStatus(v)
  29049. return nil
  29050. case soptask.FieldType:
  29051. v, ok := value.(int)
  29052. if !ok {
  29053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29054. }
  29055. m.AddType(v)
  29056. return nil
  29057. case soptask.FieldOrganizationID:
  29058. v, ok := value.(int64)
  29059. if !ok {
  29060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29061. }
  29062. m.AddOrganizationID(v)
  29063. return nil
  29064. }
  29065. return fmt.Errorf("unknown SopTask numeric field %s", name)
  29066. }
  29067. // ClearedFields returns all nullable fields that were cleared during this
  29068. // mutation.
  29069. func (m *SopTaskMutation) ClearedFields() []string {
  29070. var fields []string
  29071. if m.FieldCleared(soptask.FieldStatus) {
  29072. fields = append(fields, soptask.FieldStatus)
  29073. }
  29074. if m.FieldCleared(soptask.FieldDeletedAt) {
  29075. fields = append(fields, soptask.FieldDeletedAt)
  29076. }
  29077. if m.FieldCleared(soptask.FieldBotWxidList) {
  29078. fields = append(fields, soptask.FieldBotWxidList)
  29079. }
  29080. if m.FieldCleared(soptask.FieldPlanStartTime) {
  29081. fields = append(fields, soptask.FieldPlanStartTime)
  29082. }
  29083. if m.FieldCleared(soptask.FieldPlanEndTime) {
  29084. fields = append(fields, soptask.FieldPlanEndTime)
  29085. }
  29086. if m.FieldCleared(soptask.FieldCreatorID) {
  29087. fields = append(fields, soptask.FieldCreatorID)
  29088. }
  29089. if m.FieldCleared(soptask.FieldOrganizationID) {
  29090. fields = append(fields, soptask.FieldOrganizationID)
  29091. }
  29092. if m.FieldCleared(soptask.FieldToken) {
  29093. fields = append(fields, soptask.FieldToken)
  29094. }
  29095. return fields
  29096. }
  29097. // FieldCleared returns a boolean indicating if a field with the given name was
  29098. // cleared in this mutation.
  29099. func (m *SopTaskMutation) FieldCleared(name string) bool {
  29100. _, ok := m.clearedFields[name]
  29101. return ok
  29102. }
  29103. // ClearField clears the value of the field with the given name. It returns an
  29104. // error if the field is not defined in the schema.
  29105. func (m *SopTaskMutation) ClearField(name string) error {
  29106. switch name {
  29107. case soptask.FieldStatus:
  29108. m.ClearStatus()
  29109. return nil
  29110. case soptask.FieldDeletedAt:
  29111. m.ClearDeletedAt()
  29112. return nil
  29113. case soptask.FieldBotWxidList:
  29114. m.ClearBotWxidList()
  29115. return nil
  29116. case soptask.FieldPlanStartTime:
  29117. m.ClearPlanStartTime()
  29118. return nil
  29119. case soptask.FieldPlanEndTime:
  29120. m.ClearPlanEndTime()
  29121. return nil
  29122. case soptask.FieldCreatorID:
  29123. m.ClearCreatorID()
  29124. return nil
  29125. case soptask.FieldOrganizationID:
  29126. m.ClearOrganizationID()
  29127. return nil
  29128. case soptask.FieldToken:
  29129. m.ClearToken()
  29130. return nil
  29131. }
  29132. return fmt.Errorf("unknown SopTask nullable field %s", name)
  29133. }
  29134. // ResetField resets all changes in the mutation for the field with the given name.
  29135. // It returns an error if the field is not defined in the schema.
  29136. func (m *SopTaskMutation) ResetField(name string) error {
  29137. switch name {
  29138. case soptask.FieldCreatedAt:
  29139. m.ResetCreatedAt()
  29140. return nil
  29141. case soptask.FieldUpdatedAt:
  29142. m.ResetUpdatedAt()
  29143. return nil
  29144. case soptask.FieldStatus:
  29145. m.ResetStatus()
  29146. return nil
  29147. case soptask.FieldDeletedAt:
  29148. m.ResetDeletedAt()
  29149. return nil
  29150. case soptask.FieldName:
  29151. m.ResetName()
  29152. return nil
  29153. case soptask.FieldBotWxidList:
  29154. m.ResetBotWxidList()
  29155. return nil
  29156. case soptask.FieldType:
  29157. m.ResetType()
  29158. return nil
  29159. case soptask.FieldPlanStartTime:
  29160. m.ResetPlanStartTime()
  29161. return nil
  29162. case soptask.FieldPlanEndTime:
  29163. m.ResetPlanEndTime()
  29164. return nil
  29165. case soptask.FieldCreatorID:
  29166. m.ResetCreatorID()
  29167. return nil
  29168. case soptask.FieldOrganizationID:
  29169. m.ResetOrganizationID()
  29170. return nil
  29171. case soptask.FieldToken:
  29172. m.ResetToken()
  29173. return nil
  29174. }
  29175. return fmt.Errorf("unknown SopTask field %s", name)
  29176. }
  29177. // AddedEdges returns all edge names that were set/added in this mutation.
  29178. func (m *SopTaskMutation) AddedEdges() []string {
  29179. edges := make([]string, 0, 1)
  29180. if m.task_stages != nil {
  29181. edges = append(edges, soptask.EdgeTaskStages)
  29182. }
  29183. return edges
  29184. }
  29185. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29186. // name in this mutation.
  29187. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  29188. switch name {
  29189. case soptask.EdgeTaskStages:
  29190. ids := make([]ent.Value, 0, len(m.task_stages))
  29191. for id := range m.task_stages {
  29192. ids = append(ids, id)
  29193. }
  29194. return ids
  29195. }
  29196. return nil
  29197. }
  29198. // RemovedEdges returns all edge names that were removed in this mutation.
  29199. func (m *SopTaskMutation) RemovedEdges() []string {
  29200. edges := make([]string, 0, 1)
  29201. if m.removedtask_stages != nil {
  29202. edges = append(edges, soptask.EdgeTaskStages)
  29203. }
  29204. return edges
  29205. }
  29206. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29207. // the given name in this mutation.
  29208. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  29209. switch name {
  29210. case soptask.EdgeTaskStages:
  29211. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  29212. for id := range m.removedtask_stages {
  29213. ids = append(ids, id)
  29214. }
  29215. return ids
  29216. }
  29217. return nil
  29218. }
  29219. // ClearedEdges returns all edge names that were cleared in this mutation.
  29220. func (m *SopTaskMutation) ClearedEdges() []string {
  29221. edges := make([]string, 0, 1)
  29222. if m.clearedtask_stages {
  29223. edges = append(edges, soptask.EdgeTaskStages)
  29224. }
  29225. return edges
  29226. }
  29227. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29228. // was cleared in this mutation.
  29229. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  29230. switch name {
  29231. case soptask.EdgeTaskStages:
  29232. return m.clearedtask_stages
  29233. }
  29234. return false
  29235. }
  29236. // ClearEdge clears the value of the edge with the given name. It returns an error
  29237. // if that edge is not defined in the schema.
  29238. func (m *SopTaskMutation) ClearEdge(name string) error {
  29239. switch name {
  29240. }
  29241. return fmt.Errorf("unknown SopTask unique edge %s", name)
  29242. }
  29243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29244. // It returns an error if the edge is not defined in the schema.
  29245. func (m *SopTaskMutation) ResetEdge(name string) error {
  29246. switch name {
  29247. case soptask.EdgeTaskStages:
  29248. m.ResetTaskStages()
  29249. return nil
  29250. }
  29251. return fmt.Errorf("unknown SopTask edge %s", name)
  29252. }
  29253. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  29254. type TokenMutation struct {
  29255. config
  29256. op Op
  29257. typ string
  29258. id *uint64
  29259. created_at *time.Time
  29260. updated_at *time.Time
  29261. deleted_at *time.Time
  29262. expire_at *time.Time
  29263. token *string
  29264. mac *string
  29265. organization_id *uint64
  29266. addorganization_id *int64
  29267. custom_agent_base *string
  29268. custom_agent_key *string
  29269. openai_base *string
  29270. openai_key *string
  29271. clearedFields map[string]struct{}
  29272. agent *uint64
  29273. clearedagent bool
  29274. done bool
  29275. oldValue func(context.Context) (*Token, error)
  29276. predicates []predicate.Token
  29277. }
  29278. var _ ent.Mutation = (*TokenMutation)(nil)
  29279. // tokenOption allows management of the mutation configuration using functional options.
  29280. type tokenOption func(*TokenMutation)
  29281. // newTokenMutation creates new mutation for the Token entity.
  29282. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  29283. m := &TokenMutation{
  29284. config: c,
  29285. op: op,
  29286. typ: TypeToken,
  29287. clearedFields: make(map[string]struct{}),
  29288. }
  29289. for _, opt := range opts {
  29290. opt(m)
  29291. }
  29292. return m
  29293. }
  29294. // withTokenID sets the ID field of the mutation.
  29295. func withTokenID(id uint64) tokenOption {
  29296. return func(m *TokenMutation) {
  29297. var (
  29298. err error
  29299. once sync.Once
  29300. value *Token
  29301. )
  29302. m.oldValue = func(ctx context.Context) (*Token, error) {
  29303. once.Do(func() {
  29304. if m.done {
  29305. err = errors.New("querying old values post mutation is not allowed")
  29306. } else {
  29307. value, err = m.Client().Token.Get(ctx, id)
  29308. }
  29309. })
  29310. return value, err
  29311. }
  29312. m.id = &id
  29313. }
  29314. }
  29315. // withToken sets the old Token of the mutation.
  29316. func withToken(node *Token) tokenOption {
  29317. return func(m *TokenMutation) {
  29318. m.oldValue = func(context.Context) (*Token, error) {
  29319. return node, nil
  29320. }
  29321. m.id = &node.ID
  29322. }
  29323. }
  29324. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29325. // executed in a transaction (ent.Tx), a transactional client is returned.
  29326. func (m TokenMutation) Client() *Client {
  29327. client := &Client{config: m.config}
  29328. client.init()
  29329. return client
  29330. }
  29331. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29332. // it returns an error otherwise.
  29333. func (m TokenMutation) Tx() (*Tx, error) {
  29334. if _, ok := m.driver.(*txDriver); !ok {
  29335. return nil, errors.New("ent: mutation is not running in a transaction")
  29336. }
  29337. tx := &Tx{config: m.config}
  29338. tx.init()
  29339. return tx, nil
  29340. }
  29341. // SetID sets the value of the id field. Note that this
  29342. // operation is only accepted on creation of Token entities.
  29343. func (m *TokenMutation) SetID(id uint64) {
  29344. m.id = &id
  29345. }
  29346. // ID returns the ID value in the mutation. Note that the ID is only available
  29347. // if it was provided to the builder or after it was returned from the database.
  29348. func (m *TokenMutation) ID() (id uint64, exists bool) {
  29349. if m.id == nil {
  29350. return
  29351. }
  29352. return *m.id, true
  29353. }
  29354. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29355. // That means, if the mutation is applied within a transaction with an isolation level such
  29356. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29357. // or updated by the mutation.
  29358. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  29359. switch {
  29360. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29361. id, exists := m.ID()
  29362. if exists {
  29363. return []uint64{id}, nil
  29364. }
  29365. fallthrough
  29366. case m.op.Is(OpUpdate | OpDelete):
  29367. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  29368. default:
  29369. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29370. }
  29371. }
  29372. // SetCreatedAt sets the "created_at" field.
  29373. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  29374. m.created_at = &t
  29375. }
  29376. // CreatedAt returns the value of the "created_at" field in the mutation.
  29377. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  29378. v := m.created_at
  29379. if v == nil {
  29380. return
  29381. }
  29382. return *v, true
  29383. }
  29384. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  29385. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29387. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29388. if !m.op.Is(OpUpdateOne) {
  29389. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29390. }
  29391. if m.id == nil || m.oldValue == nil {
  29392. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29393. }
  29394. oldValue, err := m.oldValue(ctx)
  29395. if err != nil {
  29396. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29397. }
  29398. return oldValue.CreatedAt, nil
  29399. }
  29400. // ResetCreatedAt resets all changes to the "created_at" field.
  29401. func (m *TokenMutation) ResetCreatedAt() {
  29402. m.created_at = nil
  29403. }
  29404. // SetUpdatedAt sets the "updated_at" field.
  29405. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  29406. m.updated_at = &t
  29407. }
  29408. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29409. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  29410. v := m.updated_at
  29411. if v == nil {
  29412. return
  29413. }
  29414. return *v, true
  29415. }
  29416. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  29417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29419. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29420. if !m.op.Is(OpUpdateOne) {
  29421. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29422. }
  29423. if m.id == nil || m.oldValue == nil {
  29424. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29425. }
  29426. oldValue, err := m.oldValue(ctx)
  29427. if err != nil {
  29428. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29429. }
  29430. return oldValue.UpdatedAt, nil
  29431. }
  29432. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29433. func (m *TokenMutation) ResetUpdatedAt() {
  29434. m.updated_at = nil
  29435. }
  29436. // SetDeletedAt sets the "deleted_at" field.
  29437. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  29438. m.deleted_at = &t
  29439. }
  29440. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29441. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  29442. v := m.deleted_at
  29443. if v == nil {
  29444. return
  29445. }
  29446. return *v, true
  29447. }
  29448. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  29449. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29451. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29452. if !m.op.Is(OpUpdateOne) {
  29453. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29454. }
  29455. if m.id == nil || m.oldValue == nil {
  29456. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29457. }
  29458. oldValue, err := m.oldValue(ctx)
  29459. if err != nil {
  29460. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29461. }
  29462. return oldValue.DeletedAt, nil
  29463. }
  29464. // ClearDeletedAt clears the value of the "deleted_at" field.
  29465. func (m *TokenMutation) ClearDeletedAt() {
  29466. m.deleted_at = nil
  29467. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  29468. }
  29469. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29470. func (m *TokenMutation) DeletedAtCleared() bool {
  29471. _, ok := m.clearedFields[token.FieldDeletedAt]
  29472. return ok
  29473. }
  29474. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29475. func (m *TokenMutation) ResetDeletedAt() {
  29476. m.deleted_at = nil
  29477. delete(m.clearedFields, token.FieldDeletedAt)
  29478. }
  29479. // SetExpireAt sets the "expire_at" field.
  29480. func (m *TokenMutation) SetExpireAt(t time.Time) {
  29481. m.expire_at = &t
  29482. }
  29483. // ExpireAt returns the value of the "expire_at" field in the mutation.
  29484. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  29485. v := m.expire_at
  29486. if v == nil {
  29487. return
  29488. }
  29489. return *v, true
  29490. }
  29491. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  29492. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29494. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  29495. if !m.op.Is(OpUpdateOne) {
  29496. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  29497. }
  29498. if m.id == nil || m.oldValue == nil {
  29499. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  29500. }
  29501. oldValue, err := m.oldValue(ctx)
  29502. if err != nil {
  29503. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  29504. }
  29505. return oldValue.ExpireAt, nil
  29506. }
  29507. // ClearExpireAt clears the value of the "expire_at" field.
  29508. func (m *TokenMutation) ClearExpireAt() {
  29509. m.expire_at = nil
  29510. m.clearedFields[token.FieldExpireAt] = struct{}{}
  29511. }
  29512. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  29513. func (m *TokenMutation) ExpireAtCleared() bool {
  29514. _, ok := m.clearedFields[token.FieldExpireAt]
  29515. return ok
  29516. }
  29517. // ResetExpireAt resets all changes to the "expire_at" field.
  29518. func (m *TokenMutation) ResetExpireAt() {
  29519. m.expire_at = nil
  29520. delete(m.clearedFields, token.FieldExpireAt)
  29521. }
  29522. // SetToken sets the "token" field.
  29523. func (m *TokenMutation) SetToken(s string) {
  29524. m.token = &s
  29525. }
  29526. // Token returns the value of the "token" field in the mutation.
  29527. func (m *TokenMutation) Token() (r string, exists bool) {
  29528. v := m.token
  29529. if v == nil {
  29530. return
  29531. }
  29532. return *v, true
  29533. }
  29534. // OldToken returns the old "token" field's value of the Token entity.
  29535. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29537. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  29538. if !m.op.Is(OpUpdateOne) {
  29539. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  29540. }
  29541. if m.id == nil || m.oldValue == nil {
  29542. return v, errors.New("OldToken requires an ID field in the mutation")
  29543. }
  29544. oldValue, err := m.oldValue(ctx)
  29545. if err != nil {
  29546. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  29547. }
  29548. return oldValue.Token, nil
  29549. }
  29550. // ClearToken clears the value of the "token" field.
  29551. func (m *TokenMutation) ClearToken() {
  29552. m.token = nil
  29553. m.clearedFields[token.FieldToken] = struct{}{}
  29554. }
  29555. // TokenCleared returns if the "token" field was cleared in this mutation.
  29556. func (m *TokenMutation) TokenCleared() bool {
  29557. _, ok := m.clearedFields[token.FieldToken]
  29558. return ok
  29559. }
  29560. // ResetToken resets all changes to the "token" field.
  29561. func (m *TokenMutation) ResetToken() {
  29562. m.token = nil
  29563. delete(m.clearedFields, token.FieldToken)
  29564. }
  29565. // SetMAC sets the "mac" field.
  29566. func (m *TokenMutation) SetMAC(s string) {
  29567. m.mac = &s
  29568. }
  29569. // MAC returns the value of the "mac" field in the mutation.
  29570. func (m *TokenMutation) MAC() (r string, exists bool) {
  29571. v := m.mac
  29572. if v == nil {
  29573. return
  29574. }
  29575. return *v, true
  29576. }
  29577. // OldMAC returns the old "mac" field's value of the Token entity.
  29578. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29580. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  29581. if !m.op.Is(OpUpdateOne) {
  29582. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  29583. }
  29584. if m.id == nil || m.oldValue == nil {
  29585. return v, errors.New("OldMAC requires an ID field in the mutation")
  29586. }
  29587. oldValue, err := m.oldValue(ctx)
  29588. if err != nil {
  29589. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  29590. }
  29591. return oldValue.MAC, nil
  29592. }
  29593. // ClearMAC clears the value of the "mac" field.
  29594. func (m *TokenMutation) ClearMAC() {
  29595. m.mac = nil
  29596. m.clearedFields[token.FieldMAC] = struct{}{}
  29597. }
  29598. // MACCleared returns if the "mac" field was cleared in this mutation.
  29599. func (m *TokenMutation) MACCleared() bool {
  29600. _, ok := m.clearedFields[token.FieldMAC]
  29601. return ok
  29602. }
  29603. // ResetMAC resets all changes to the "mac" field.
  29604. func (m *TokenMutation) ResetMAC() {
  29605. m.mac = nil
  29606. delete(m.clearedFields, token.FieldMAC)
  29607. }
  29608. // SetOrganizationID sets the "organization_id" field.
  29609. func (m *TokenMutation) SetOrganizationID(u uint64) {
  29610. m.organization_id = &u
  29611. m.addorganization_id = nil
  29612. }
  29613. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29614. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  29615. v := m.organization_id
  29616. if v == nil {
  29617. return
  29618. }
  29619. return *v, true
  29620. }
  29621. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  29622. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29624. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29625. if !m.op.Is(OpUpdateOne) {
  29626. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29627. }
  29628. if m.id == nil || m.oldValue == nil {
  29629. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29630. }
  29631. oldValue, err := m.oldValue(ctx)
  29632. if err != nil {
  29633. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29634. }
  29635. return oldValue.OrganizationID, nil
  29636. }
  29637. // AddOrganizationID adds u to the "organization_id" field.
  29638. func (m *TokenMutation) AddOrganizationID(u int64) {
  29639. if m.addorganization_id != nil {
  29640. *m.addorganization_id += u
  29641. } else {
  29642. m.addorganization_id = &u
  29643. }
  29644. }
  29645. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29646. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  29647. v := m.addorganization_id
  29648. if v == nil {
  29649. return
  29650. }
  29651. return *v, true
  29652. }
  29653. // ResetOrganizationID resets all changes to the "organization_id" field.
  29654. func (m *TokenMutation) ResetOrganizationID() {
  29655. m.organization_id = nil
  29656. m.addorganization_id = nil
  29657. }
  29658. // SetAgentID sets the "agent_id" field.
  29659. func (m *TokenMutation) SetAgentID(u uint64) {
  29660. m.agent = &u
  29661. }
  29662. // AgentID returns the value of the "agent_id" field in the mutation.
  29663. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  29664. v := m.agent
  29665. if v == nil {
  29666. return
  29667. }
  29668. return *v, true
  29669. }
  29670. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  29671. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29673. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  29674. if !m.op.Is(OpUpdateOne) {
  29675. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  29676. }
  29677. if m.id == nil || m.oldValue == nil {
  29678. return v, errors.New("OldAgentID requires an ID field in the mutation")
  29679. }
  29680. oldValue, err := m.oldValue(ctx)
  29681. if err != nil {
  29682. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  29683. }
  29684. return oldValue.AgentID, nil
  29685. }
  29686. // ResetAgentID resets all changes to the "agent_id" field.
  29687. func (m *TokenMutation) ResetAgentID() {
  29688. m.agent = nil
  29689. }
  29690. // SetCustomAgentBase sets the "custom_agent_base" field.
  29691. func (m *TokenMutation) SetCustomAgentBase(s string) {
  29692. m.custom_agent_base = &s
  29693. }
  29694. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  29695. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  29696. v := m.custom_agent_base
  29697. if v == nil {
  29698. return
  29699. }
  29700. return *v, true
  29701. }
  29702. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  29703. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29705. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  29706. if !m.op.Is(OpUpdateOne) {
  29707. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  29708. }
  29709. if m.id == nil || m.oldValue == nil {
  29710. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  29711. }
  29712. oldValue, err := m.oldValue(ctx)
  29713. if err != nil {
  29714. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  29715. }
  29716. return oldValue.CustomAgentBase, nil
  29717. }
  29718. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  29719. func (m *TokenMutation) ClearCustomAgentBase() {
  29720. m.custom_agent_base = nil
  29721. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  29722. }
  29723. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  29724. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  29725. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  29726. return ok
  29727. }
  29728. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  29729. func (m *TokenMutation) ResetCustomAgentBase() {
  29730. m.custom_agent_base = nil
  29731. delete(m.clearedFields, token.FieldCustomAgentBase)
  29732. }
  29733. // SetCustomAgentKey sets the "custom_agent_key" field.
  29734. func (m *TokenMutation) SetCustomAgentKey(s string) {
  29735. m.custom_agent_key = &s
  29736. }
  29737. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  29738. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  29739. v := m.custom_agent_key
  29740. if v == nil {
  29741. return
  29742. }
  29743. return *v, true
  29744. }
  29745. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  29746. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29748. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  29749. if !m.op.Is(OpUpdateOne) {
  29750. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  29751. }
  29752. if m.id == nil || m.oldValue == nil {
  29753. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  29754. }
  29755. oldValue, err := m.oldValue(ctx)
  29756. if err != nil {
  29757. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  29758. }
  29759. return oldValue.CustomAgentKey, nil
  29760. }
  29761. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  29762. func (m *TokenMutation) ClearCustomAgentKey() {
  29763. m.custom_agent_key = nil
  29764. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  29765. }
  29766. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  29767. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  29768. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  29769. return ok
  29770. }
  29771. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  29772. func (m *TokenMutation) ResetCustomAgentKey() {
  29773. m.custom_agent_key = nil
  29774. delete(m.clearedFields, token.FieldCustomAgentKey)
  29775. }
  29776. // SetOpenaiBase sets the "openai_base" field.
  29777. func (m *TokenMutation) SetOpenaiBase(s string) {
  29778. m.openai_base = &s
  29779. }
  29780. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  29781. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  29782. v := m.openai_base
  29783. if v == nil {
  29784. return
  29785. }
  29786. return *v, true
  29787. }
  29788. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  29789. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29791. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  29792. if !m.op.Is(OpUpdateOne) {
  29793. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  29794. }
  29795. if m.id == nil || m.oldValue == nil {
  29796. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  29797. }
  29798. oldValue, err := m.oldValue(ctx)
  29799. if err != nil {
  29800. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  29801. }
  29802. return oldValue.OpenaiBase, nil
  29803. }
  29804. // ClearOpenaiBase clears the value of the "openai_base" field.
  29805. func (m *TokenMutation) ClearOpenaiBase() {
  29806. m.openai_base = nil
  29807. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  29808. }
  29809. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  29810. func (m *TokenMutation) OpenaiBaseCleared() bool {
  29811. _, ok := m.clearedFields[token.FieldOpenaiBase]
  29812. return ok
  29813. }
  29814. // ResetOpenaiBase resets all changes to the "openai_base" field.
  29815. func (m *TokenMutation) ResetOpenaiBase() {
  29816. m.openai_base = nil
  29817. delete(m.clearedFields, token.FieldOpenaiBase)
  29818. }
  29819. // SetOpenaiKey sets the "openai_key" field.
  29820. func (m *TokenMutation) SetOpenaiKey(s string) {
  29821. m.openai_key = &s
  29822. }
  29823. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  29824. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  29825. v := m.openai_key
  29826. if v == nil {
  29827. return
  29828. }
  29829. return *v, true
  29830. }
  29831. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  29832. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  29833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29834. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  29835. if !m.op.Is(OpUpdateOne) {
  29836. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  29837. }
  29838. if m.id == nil || m.oldValue == nil {
  29839. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  29840. }
  29841. oldValue, err := m.oldValue(ctx)
  29842. if err != nil {
  29843. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  29844. }
  29845. return oldValue.OpenaiKey, nil
  29846. }
  29847. // ClearOpenaiKey clears the value of the "openai_key" field.
  29848. func (m *TokenMutation) ClearOpenaiKey() {
  29849. m.openai_key = nil
  29850. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  29851. }
  29852. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  29853. func (m *TokenMutation) OpenaiKeyCleared() bool {
  29854. _, ok := m.clearedFields[token.FieldOpenaiKey]
  29855. return ok
  29856. }
  29857. // ResetOpenaiKey resets all changes to the "openai_key" field.
  29858. func (m *TokenMutation) ResetOpenaiKey() {
  29859. m.openai_key = nil
  29860. delete(m.clearedFields, token.FieldOpenaiKey)
  29861. }
  29862. // ClearAgent clears the "agent" edge to the Agent entity.
  29863. func (m *TokenMutation) ClearAgent() {
  29864. m.clearedagent = true
  29865. m.clearedFields[token.FieldAgentID] = struct{}{}
  29866. }
  29867. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  29868. func (m *TokenMutation) AgentCleared() bool {
  29869. return m.clearedagent
  29870. }
  29871. // AgentIDs returns the "agent" edge IDs in the mutation.
  29872. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29873. // AgentID instead. It exists only for internal usage by the builders.
  29874. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  29875. if id := m.agent; id != nil {
  29876. ids = append(ids, *id)
  29877. }
  29878. return
  29879. }
  29880. // ResetAgent resets all changes to the "agent" edge.
  29881. func (m *TokenMutation) ResetAgent() {
  29882. m.agent = nil
  29883. m.clearedagent = false
  29884. }
  29885. // Where appends a list predicates to the TokenMutation builder.
  29886. func (m *TokenMutation) Where(ps ...predicate.Token) {
  29887. m.predicates = append(m.predicates, ps...)
  29888. }
  29889. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  29890. // users can use type-assertion to append predicates that do not depend on any generated package.
  29891. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  29892. p := make([]predicate.Token, len(ps))
  29893. for i := range ps {
  29894. p[i] = ps[i]
  29895. }
  29896. m.Where(p...)
  29897. }
  29898. // Op returns the operation name.
  29899. func (m *TokenMutation) Op() Op {
  29900. return m.op
  29901. }
  29902. // SetOp allows setting the mutation operation.
  29903. func (m *TokenMutation) SetOp(op Op) {
  29904. m.op = op
  29905. }
  29906. // Type returns the node type of this mutation (Token).
  29907. func (m *TokenMutation) Type() string {
  29908. return m.typ
  29909. }
  29910. // Fields returns all fields that were changed during this mutation. Note that in
  29911. // order to get all numeric fields that were incremented/decremented, call
  29912. // AddedFields().
  29913. func (m *TokenMutation) Fields() []string {
  29914. fields := make([]string, 0, 12)
  29915. if m.created_at != nil {
  29916. fields = append(fields, token.FieldCreatedAt)
  29917. }
  29918. if m.updated_at != nil {
  29919. fields = append(fields, token.FieldUpdatedAt)
  29920. }
  29921. if m.deleted_at != nil {
  29922. fields = append(fields, token.FieldDeletedAt)
  29923. }
  29924. if m.expire_at != nil {
  29925. fields = append(fields, token.FieldExpireAt)
  29926. }
  29927. if m.token != nil {
  29928. fields = append(fields, token.FieldToken)
  29929. }
  29930. if m.mac != nil {
  29931. fields = append(fields, token.FieldMAC)
  29932. }
  29933. if m.organization_id != nil {
  29934. fields = append(fields, token.FieldOrganizationID)
  29935. }
  29936. if m.agent != nil {
  29937. fields = append(fields, token.FieldAgentID)
  29938. }
  29939. if m.custom_agent_base != nil {
  29940. fields = append(fields, token.FieldCustomAgentBase)
  29941. }
  29942. if m.custom_agent_key != nil {
  29943. fields = append(fields, token.FieldCustomAgentKey)
  29944. }
  29945. if m.openai_base != nil {
  29946. fields = append(fields, token.FieldOpenaiBase)
  29947. }
  29948. if m.openai_key != nil {
  29949. fields = append(fields, token.FieldOpenaiKey)
  29950. }
  29951. return fields
  29952. }
  29953. // Field returns the value of a field with the given name. The second boolean
  29954. // return value indicates that this field was not set, or was not defined in the
  29955. // schema.
  29956. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  29957. switch name {
  29958. case token.FieldCreatedAt:
  29959. return m.CreatedAt()
  29960. case token.FieldUpdatedAt:
  29961. return m.UpdatedAt()
  29962. case token.FieldDeletedAt:
  29963. return m.DeletedAt()
  29964. case token.FieldExpireAt:
  29965. return m.ExpireAt()
  29966. case token.FieldToken:
  29967. return m.Token()
  29968. case token.FieldMAC:
  29969. return m.MAC()
  29970. case token.FieldOrganizationID:
  29971. return m.OrganizationID()
  29972. case token.FieldAgentID:
  29973. return m.AgentID()
  29974. case token.FieldCustomAgentBase:
  29975. return m.CustomAgentBase()
  29976. case token.FieldCustomAgentKey:
  29977. return m.CustomAgentKey()
  29978. case token.FieldOpenaiBase:
  29979. return m.OpenaiBase()
  29980. case token.FieldOpenaiKey:
  29981. return m.OpenaiKey()
  29982. }
  29983. return nil, false
  29984. }
  29985. // OldField returns the old value of the field from the database. An error is
  29986. // returned if the mutation operation is not UpdateOne, or the query to the
  29987. // database failed.
  29988. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29989. switch name {
  29990. case token.FieldCreatedAt:
  29991. return m.OldCreatedAt(ctx)
  29992. case token.FieldUpdatedAt:
  29993. return m.OldUpdatedAt(ctx)
  29994. case token.FieldDeletedAt:
  29995. return m.OldDeletedAt(ctx)
  29996. case token.FieldExpireAt:
  29997. return m.OldExpireAt(ctx)
  29998. case token.FieldToken:
  29999. return m.OldToken(ctx)
  30000. case token.FieldMAC:
  30001. return m.OldMAC(ctx)
  30002. case token.FieldOrganizationID:
  30003. return m.OldOrganizationID(ctx)
  30004. case token.FieldAgentID:
  30005. return m.OldAgentID(ctx)
  30006. case token.FieldCustomAgentBase:
  30007. return m.OldCustomAgentBase(ctx)
  30008. case token.FieldCustomAgentKey:
  30009. return m.OldCustomAgentKey(ctx)
  30010. case token.FieldOpenaiBase:
  30011. return m.OldOpenaiBase(ctx)
  30012. case token.FieldOpenaiKey:
  30013. return m.OldOpenaiKey(ctx)
  30014. }
  30015. return nil, fmt.Errorf("unknown Token field %s", name)
  30016. }
  30017. // SetField sets the value of a field with the given name. It returns an error if
  30018. // the field is not defined in the schema, or if the type mismatched the field
  30019. // type.
  30020. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  30021. switch name {
  30022. case token.FieldCreatedAt:
  30023. v, ok := value.(time.Time)
  30024. if !ok {
  30025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30026. }
  30027. m.SetCreatedAt(v)
  30028. return nil
  30029. case token.FieldUpdatedAt:
  30030. v, ok := value.(time.Time)
  30031. if !ok {
  30032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30033. }
  30034. m.SetUpdatedAt(v)
  30035. return nil
  30036. case token.FieldDeletedAt:
  30037. v, ok := value.(time.Time)
  30038. if !ok {
  30039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30040. }
  30041. m.SetDeletedAt(v)
  30042. return nil
  30043. case token.FieldExpireAt:
  30044. v, ok := value.(time.Time)
  30045. if !ok {
  30046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30047. }
  30048. m.SetExpireAt(v)
  30049. return nil
  30050. case token.FieldToken:
  30051. v, ok := value.(string)
  30052. if !ok {
  30053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30054. }
  30055. m.SetToken(v)
  30056. return nil
  30057. case token.FieldMAC:
  30058. v, ok := value.(string)
  30059. if !ok {
  30060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30061. }
  30062. m.SetMAC(v)
  30063. return nil
  30064. case token.FieldOrganizationID:
  30065. v, ok := value.(uint64)
  30066. if !ok {
  30067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30068. }
  30069. m.SetOrganizationID(v)
  30070. return nil
  30071. case token.FieldAgentID:
  30072. v, ok := value.(uint64)
  30073. if !ok {
  30074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30075. }
  30076. m.SetAgentID(v)
  30077. return nil
  30078. case token.FieldCustomAgentBase:
  30079. v, ok := value.(string)
  30080. if !ok {
  30081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30082. }
  30083. m.SetCustomAgentBase(v)
  30084. return nil
  30085. case token.FieldCustomAgentKey:
  30086. v, ok := value.(string)
  30087. if !ok {
  30088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30089. }
  30090. m.SetCustomAgentKey(v)
  30091. return nil
  30092. case token.FieldOpenaiBase:
  30093. v, ok := value.(string)
  30094. if !ok {
  30095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30096. }
  30097. m.SetOpenaiBase(v)
  30098. return nil
  30099. case token.FieldOpenaiKey:
  30100. v, ok := value.(string)
  30101. if !ok {
  30102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30103. }
  30104. m.SetOpenaiKey(v)
  30105. return nil
  30106. }
  30107. return fmt.Errorf("unknown Token field %s", name)
  30108. }
  30109. // AddedFields returns all numeric fields that were incremented/decremented during
  30110. // this mutation.
  30111. func (m *TokenMutation) AddedFields() []string {
  30112. var fields []string
  30113. if m.addorganization_id != nil {
  30114. fields = append(fields, token.FieldOrganizationID)
  30115. }
  30116. return fields
  30117. }
  30118. // AddedField returns the numeric value that was incremented/decremented on a field
  30119. // with the given name. The second boolean return value indicates that this field
  30120. // was not set, or was not defined in the schema.
  30121. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  30122. switch name {
  30123. case token.FieldOrganizationID:
  30124. return m.AddedOrganizationID()
  30125. }
  30126. return nil, false
  30127. }
  30128. // AddField adds the value to the field with the given name. It returns an error if
  30129. // the field is not defined in the schema, or if the type mismatched the field
  30130. // type.
  30131. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  30132. switch name {
  30133. case token.FieldOrganizationID:
  30134. v, ok := value.(int64)
  30135. if !ok {
  30136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30137. }
  30138. m.AddOrganizationID(v)
  30139. return nil
  30140. }
  30141. return fmt.Errorf("unknown Token numeric field %s", name)
  30142. }
  30143. // ClearedFields returns all nullable fields that were cleared during this
  30144. // mutation.
  30145. func (m *TokenMutation) ClearedFields() []string {
  30146. var fields []string
  30147. if m.FieldCleared(token.FieldDeletedAt) {
  30148. fields = append(fields, token.FieldDeletedAt)
  30149. }
  30150. if m.FieldCleared(token.FieldExpireAt) {
  30151. fields = append(fields, token.FieldExpireAt)
  30152. }
  30153. if m.FieldCleared(token.FieldToken) {
  30154. fields = append(fields, token.FieldToken)
  30155. }
  30156. if m.FieldCleared(token.FieldMAC) {
  30157. fields = append(fields, token.FieldMAC)
  30158. }
  30159. if m.FieldCleared(token.FieldCustomAgentBase) {
  30160. fields = append(fields, token.FieldCustomAgentBase)
  30161. }
  30162. if m.FieldCleared(token.FieldCustomAgentKey) {
  30163. fields = append(fields, token.FieldCustomAgentKey)
  30164. }
  30165. if m.FieldCleared(token.FieldOpenaiBase) {
  30166. fields = append(fields, token.FieldOpenaiBase)
  30167. }
  30168. if m.FieldCleared(token.FieldOpenaiKey) {
  30169. fields = append(fields, token.FieldOpenaiKey)
  30170. }
  30171. return fields
  30172. }
  30173. // FieldCleared returns a boolean indicating if a field with the given name was
  30174. // cleared in this mutation.
  30175. func (m *TokenMutation) FieldCleared(name string) bool {
  30176. _, ok := m.clearedFields[name]
  30177. return ok
  30178. }
  30179. // ClearField clears the value of the field with the given name. It returns an
  30180. // error if the field is not defined in the schema.
  30181. func (m *TokenMutation) ClearField(name string) error {
  30182. switch name {
  30183. case token.FieldDeletedAt:
  30184. m.ClearDeletedAt()
  30185. return nil
  30186. case token.FieldExpireAt:
  30187. m.ClearExpireAt()
  30188. return nil
  30189. case token.FieldToken:
  30190. m.ClearToken()
  30191. return nil
  30192. case token.FieldMAC:
  30193. m.ClearMAC()
  30194. return nil
  30195. case token.FieldCustomAgentBase:
  30196. m.ClearCustomAgentBase()
  30197. return nil
  30198. case token.FieldCustomAgentKey:
  30199. m.ClearCustomAgentKey()
  30200. return nil
  30201. case token.FieldOpenaiBase:
  30202. m.ClearOpenaiBase()
  30203. return nil
  30204. case token.FieldOpenaiKey:
  30205. m.ClearOpenaiKey()
  30206. return nil
  30207. }
  30208. return fmt.Errorf("unknown Token nullable field %s", name)
  30209. }
  30210. // ResetField resets all changes in the mutation for the field with the given name.
  30211. // It returns an error if the field is not defined in the schema.
  30212. func (m *TokenMutation) ResetField(name string) error {
  30213. switch name {
  30214. case token.FieldCreatedAt:
  30215. m.ResetCreatedAt()
  30216. return nil
  30217. case token.FieldUpdatedAt:
  30218. m.ResetUpdatedAt()
  30219. return nil
  30220. case token.FieldDeletedAt:
  30221. m.ResetDeletedAt()
  30222. return nil
  30223. case token.FieldExpireAt:
  30224. m.ResetExpireAt()
  30225. return nil
  30226. case token.FieldToken:
  30227. m.ResetToken()
  30228. return nil
  30229. case token.FieldMAC:
  30230. m.ResetMAC()
  30231. return nil
  30232. case token.FieldOrganizationID:
  30233. m.ResetOrganizationID()
  30234. return nil
  30235. case token.FieldAgentID:
  30236. m.ResetAgentID()
  30237. return nil
  30238. case token.FieldCustomAgentBase:
  30239. m.ResetCustomAgentBase()
  30240. return nil
  30241. case token.FieldCustomAgentKey:
  30242. m.ResetCustomAgentKey()
  30243. return nil
  30244. case token.FieldOpenaiBase:
  30245. m.ResetOpenaiBase()
  30246. return nil
  30247. case token.FieldOpenaiKey:
  30248. m.ResetOpenaiKey()
  30249. return nil
  30250. }
  30251. return fmt.Errorf("unknown Token field %s", name)
  30252. }
  30253. // AddedEdges returns all edge names that were set/added in this mutation.
  30254. func (m *TokenMutation) AddedEdges() []string {
  30255. edges := make([]string, 0, 1)
  30256. if m.agent != nil {
  30257. edges = append(edges, token.EdgeAgent)
  30258. }
  30259. return edges
  30260. }
  30261. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30262. // name in this mutation.
  30263. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  30264. switch name {
  30265. case token.EdgeAgent:
  30266. if id := m.agent; id != nil {
  30267. return []ent.Value{*id}
  30268. }
  30269. }
  30270. return nil
  30271. }
  30272. // RemovedEdges returns all edge names that were removed in this mutation.
  30273. func (m *TokenMutation) RemovedEdges() []string {
  30274. edges := make([]string, 0, 1)
  30275. return edges
  30276. }
  30277. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30278. // the given name in this mutation.
  30279. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  30280. return nil
  30281. }
  30282. // ClearedEdges returns all edge names that were cleared in this mutation.
  30283. func (m *TokenMutation) ClearedEdges() []string {
  30284. edges := make([]string, 0, 1)
  30285. if m.clearedagent {
  30286. edges = append(edges, token.EdgeAgent)
  30287. }
  30288. return edges
  30289. }
  30290. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30291. // was cleared in this mutation.
  30292. func (m *TokenMutation) EdgeCleared(name string) bool {
  30293. switch name {
  30294. case token.EdgeAgent:
  30295. return m.clearedagent
  30296. }
  30297. return false
  30298. }
  30299. // ClearEdge clears the value of the edge with the given name. It returns an error
  30300. // if that edge is not defined in the schema.
  30301. func (m *TokenMutation) ClearEdge(name string) error {
  30302. switch name {
  30303. case token.EdgeAgent:
  30304. m.ClearAgent()
  30305. return nil
  30306. }
  30307. return fmt.Errorf("unknown Token unique edge %s", name)
  30308. }
  30309. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30310. // It returns an error if the edge is not defined in the schema.
  30311. func (m *TokenMutation) ResetEdge(name string) error {
  30312. switch name {
  30313. case token.EdgeAgent:
  30314. m.ResetAgent()
  30315. return nil
  30316. }
  30317. return fmt.Errorf("unknown Token edge %s", name)
  30318. }
  30319. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  30320. type TutorialMutation struct {
  30321. config
  30322. op Op
  30323. typ string
  30324. id *uint64
  30325. created_at *time.Time
  30326. updated_at *time.Time
  30327. deleted_at *time.Time
  30328. index *int
  30329. addindex *int
  30330. title *string
  30331. content *string
  30332. organization_id *uint64
  30333. addorganization_id *int64
  30334. clearedFields map[string]struct{}
  30335. employee *uint64
  30336. clearedemployee bool
  30337. done bool
  30338. oldValue func(context.Context) (*Tutorial, error)
  30339. predicates []predicate.Tutorial
  30340. }
  30341. var _ ent.Mutation = (*TutorialMutation)(nil)
  30342. // tutorialOption allows management of the mutation configuration using functional options.
  30343. type tutorialOption func(*TutorialMutation)
  30344. // newTutorialMutation creates new mutation for the Tutorial entity.
  30345. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  30346. m := &TutorialMutation{
  30347. config: c,
  30348. op: op,
  30349. typ: TypeTutorial,
  30350. clearedFields: make(map[string]struct{}),
  30351. }
  30352. for _, opt := range opts {
  30353. opt(m)
  30354. }
  30355. return m
  30356. }
  30357. // withTutorialID sets the ID field of the mutation.
  30358. func withTutorialID(id uint64) tutorialOption {
  30359. return func(m *TutorialMutation) {
  30360. var (
  30361. err error
  30362. once sync.Once
  30363. value *Tutorial
  30364. )
  30365. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  30366. once.Do(func() {
  30367. if m.done {
  30368. err = errors.New("querying old values post mutation is not allowed")
  30369. } else {
  30370. value, err = m.Client().Tutorial.Get(ctx, id)
  30371. }
  30372. })
  30373. return value, err
  30374. }
  30375. m.id = &id
  30376. }
  30377. }
  30378. // withTutorial sets the old Tutorial of the mutation.
  30379. func withTutorial(node *Tutorial) tutorialOption {
  30380. return func(m *TutorialMutation) {
  30381. m.oldValue = func(context.Context) (*Tutorial, error) {
  30382. return node, nil
  30383. }
  30384. m.id = &node.ID
  30385. }
  30386. }
  30387. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30388. // executed in a transaction (ent.Tx), a transactional client is returned.
  30389. func (m TutorialMutation) Client() *Client {
  30390. client := &Client{config: m.config}
  30391. client.init()
  30392. return client
  30393. }
  30394. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30395. // it returns an error otherwise.
  30396. func (m TutorialMutation) Tx() (*Tx, error) {
  30397. if _, ok := m.driver.(*txDriver); !ok {
  30398. return nil, errors.New("ent: mutation is not running in a transaction")
  30399. }
  30400. tx := &Tx{config: m.config}
  30401. tx.init()
  30402. return tx, nil
  30403. }
  30404. // SetID sets the value of the id field. Note that this
  30405. // operation is only accepted on creation of Tutorial entities.
  30406. func (m *TutorialMutation) SetID(id uint64) {
  30407. m.id = &id
  30408. }
  30409. // ID returns the ID value in the mutation. Note that the ID is only available
  30410. // if it was provided to the builder or after it was returned from the database.
  30411. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  30412. if m.id == nil {
  30413. return
  30414. }
  30415. return *m.id, true
  30416. }
  30417. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30418. // That means, if the mutation is applied within a transaction with an isolation level such
  30419. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30420. // or updated by the mutation.
  30421. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  30422. switch {
  30423. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30424. id, exists := m.ID()
  30425. if exists {
  30426. return []uint64{id}, nil
  30427. }
  30428. fallthrough
  30429. case m.op.Is(OpUpdate | OpDelete):
  30430. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  30431. default:
  30432. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30433. }
  30434. }
  30435. // SetCreatedAt sets the "created_at" field.
  30436. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  30437. m.created_at = &t
  30438. }
  30439. // CreatedAt returns the value of the "created_at" field in the mutation.
  30440. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  30441. v := m.created_at
  30442. if v == nil {
  30443. return
  30444. }
  30445. return *v, true
  30446. }
  30447. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  30448. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30450. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30451. if !m.op.Is(OpUpdateOne) {
  30452. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30453. }
  30454. if m.id == nil || m.oldValue == nil {
  30455. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30456. }
  30457. oldValue, err := m.oldValue(ctx)
  30458. if err != nil {
  30459. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30460. }
  30461. return oldValue.CreatedAt, nil
  30462. }
  30463. // ResetCreatedAt resets all changes to the "created_at" field.
  30464. func (m *TutorialMutation) ResetCreatedAt() {
  30465. m.created_at = nil
  30466. }
  30467. // SetUpdatedAt sets the "updated_at" field.
  30468. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  30469. m.updated_at = &t
  30470. }
  30471. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30472. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  30473. v := m.updated_at
  30474. if v == nil {
  30475. return
  30476. }
  30477. return *v, true
  30478. }
  30479. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  30480. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30482. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30483. if !m.op.Is(OpUpdateOne) {
  30484. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30485. }
  30486. if m.id == nil || m.oldValue == nil {
  30487. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30488. }
  30489. oldValue, err := m.oldValue(ctx)
  30490. if err != nil {
  30491. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30492. }
  30493. return oldValue.UpdatedAt, nil
  30494. }
  30495. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30496. func (m *TutorialMutation) ResetUpdatedAt() {
  30497. m.updated_at = nil
  30498. }
  30499. // SetDeletedAt sets the "deleted_at" field.
  30500. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  30501. m.deleted_at = &t
  30502. }
  30503. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30504. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  30505. v := m.deleted_at
  30506. if v == nil {
  30507. return
  30508. }
  30509. return *v, true
  30510. }
  30511. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  30512. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30514. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30515. if !m.op.Is(OpUpdateOne) {
  30516. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30517. }
  30518. if m.id == nil || m.oldValue == nil {
  30519. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30520. }
  30521. oldValue, err := m.oldValue(ctx)
  30522. if err != nil {
  30523. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30524. }
  30525. return oldValue.DeletedAt, nil
  30526. }
  30527. // ClearDeletedAt clears the value of the "deleted_at" field.
  30528. func (m *TutorialMutation) ClearDeletedAt() {
  30529. m.deleted_at = nil
  30530. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  30531. }
  30532. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30533. func (m *TutorialMutation) DeletedAtCleared() bool {
  30534. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  30535. return ok
  30536. }
  30537. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30538. func (m *TutorialMutation) ResetDeletedAt() {
  30539. m.deleted_at = nil
  30540. delete(m.clearedFields, tutorial.FieldDeletedAt)
  30541. }
  30542. // SetEmployeeID sets the "employee_id" field.
  30543. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  30544. m.employee = &u
  30545. }
  30546. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30547. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  30548. v := m.employee
  30549. if v == nil {
  30550. return
  30551. }
  30552. return *v, true
  30553. }
  30554. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  30555. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30557. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30558. if !m.op.Is(OpUpdateOne) {
  30559. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30560. }
  30561. if m.id == nil || m.oldValue == nil {
  30562. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30563. }
  30564. oldValue, err := m.oldValue(ctx)
  30565. if err != nil {
  30566. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30567. }
  30568. return oldValue.EmployeeID, nil
  30569. }
  30570. // ResetEmployeeID resets all changes to the "employee_id" field.
  30571. func (m *TutorialMutation) ResetEmployeeID() {
  30572. m.employee = nil
  30573. }
  30574. // SetIndex sets the "index" field.
  30575. func (m *TutorialMutation) SetIndex(i int) {
  30576. m.index = &i
  30577. m.addindex = nil
  30578. }
  30579. // Index returns the value of the "index" field in the mutation.
  30580. func (m *TutorialMutation) Index() (r int, exists bool) {
  30581. v := m.index
  30582. if v == nil {
  30583. return
  30584. }
  30585. return *v, true
  30586. }
  30587. // OldIndex returns the old "index" field's value of the Tutorial entity.
  30588. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30590. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  30591. if !m.op.Is(OpUpdateOne) {
  30592. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  30593. }
  30594. if m.id == nil || m.oldValue == nil {
  30595. return v, errors.New("OldIndex requires an ID field in the mutation")
  30596. }
  30597. oldValue, err := m.oldValue(ctx)
  30598. if err != nil {
  30599. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  30600. }
  30601. return oldValue.Index, nil
  30602. }
  30603. // AddIndex adds i to the "index" field.
  30604. func (m *TutorialMutation) AddIndex(i int) {
  30605. if m.addindex != nil {
  30606. *m.addindex += i
  30607. } else {
  30608. m.addindex = &i
  30609. }
  30610. }
  30611. // AddedIndex returns the value that was added to the "index" field in this mutation.
  30612. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  30613. v := m.addindex
  30614. if v == nil {
  30615. return
  30616. }
  30617. return *v, true
  30618. }
  30619. // ResetIndex resets all changes to the "index" field.
  30620. func (m *TutorialMutation) ResetIndex() {
  30621. m.index = nil
  30622. m.addindex = nil
  30623. }
  30624. // SetTitle sets the "title" field.
  30625. func (m *TutorialMutation) SetTitle(s string) {
  30626. m.title = &s
  30627. }
  30628. // Title returns the value of the "title" field in the mutation.
  30629. func (m *TutorialMutation) Title() (r string, exists bool) {
  30630. v := m.title
  30631. if v == nil {
  30632. return
  30633. }
  30634. return *v, true
  30635. }
  30636. // OldTitle returns the old "title" field's value of the Tutorial entity.
  30637. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30639. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  30640. if !m.op.Is(OpUpdateOne) {
  30641. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  30642. }
  30643. if m.id == nil || m.oldValue == nil {
  30644. return v, errors.New("OldTitle requires an ID field in the mutation")
  30645. }
  30646. oldValue, err := m.oldValue(ctx)
  30647. if err != nil {
  30648. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  30649. }
  30650. return oldValue.Title, nil
  30651. }
  30652. // ResetTitle resets all changes to the "title" field.
  30653. func (m *TutorialMutation) ResetTitle() {
  30654. m.title = nil
  30655. }
  30656. // SetContent sets the "content" field.
  30657. func (m *TutorialMutation) SetContent(s string) {
  30658. m.content = &s
  30659. }
  30660. // Content returns the value of the "content" field in the mutation.
  30661. func (m *TutorialMutation) Content() (r string, exists bool) {
  30662. v := m.content
  30663. if v == nil {
  30664. return
  30665. }
  30666. return *v, true
  30667. }
  30668. // OldContent returns the old "content" field's value of the Tutorial entity.
  30669. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30671. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  30672. if !m.op.Is(OpUpdateOne) {
  30673. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  30674. }
  30675. if m.id == nil || m.oldValue == nil {
  30676. return v, errors.New("OldContent requires an ID field in the mutation")
  30677. }
  30678. oldValue, err := m.oldValue(ctx)
  30679. if err != nil {
  30680. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  30681. }
  30682. return oldValue.Content, nil
  30683. }
  30684. // ResetContent resets all changes to the "content" field.
  30685. func (m *TutorialMutation) ResetContent() {
  30686. m.content = nil
  30687. }
  30688. // SetOrganizationID sets the "organization_id" field.
  30689. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  30690. m.organization_id = &u
  30691. m.addorganization_id = nil
  30692. }
  30693. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30694. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  30695. v := m.organization_id
  30696. if v == nil {
  30697. return
  30698. }
  30699. return *v, true
  30700. }
  30701. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  30702. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  30703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30704. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30705. if !m.op.Is(OpUpdateOne) {
  30706. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30707. }
  30708. if m.id == nil || m.oldValue == nil {
  30709. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30710. }
  30711. oldValue, err := m.oldValue(ctx)
  30712. if err != nil {
  30713. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30714. }
  30715. return oldValue.OrganizationID, nil
  30716. }
  30717. // AddOrganizationID adds u to the "organization_id" field.
  30718. func (m *TutorialMutation) AddOrganizationID(u int64) {
  30719. if m.addorganization_id != nil {
  30720. *m.addorganization_id += u
  30721. } else {
  30722. m.addorganization_id = &u
  30723. }
  30724. }
  30725. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30726. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  30727. v := m.addorganization_id
  30728. if v == nil {
  30729. return
  30730. }
  30731. return *v, true
  30732. }
  30733. // ResetOrganizationID resets all changes to the "organization_id" field.
  30734. func (m *TutorialMutation) ResetOrganizationID() {
  30735. m.organization_id = nil
  30736. m.addorganization_id = nil
  30737. }
  30738. // ClearEmployee clears the "employee" edge to the Employee entity.
  30739. func (m *TutorialMutation) ClearEmployee() {
  30740. m.clearedemployee = true
  30741. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  30742. }
  30743. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30744. func (m *TutorialMutation) EmployeeCleared() bool {
  30745. return m.clearedemployee
  30746. }
  30747. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30748. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30749. // EmployeeID instead. It exists only for internal usage by the builders.
  30750. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  30751. if id := m.employee; id != nil {
  30752. ids = append(ids, *id)
  30753. }
  30754. return
  30755. }
  30756. // ResetEmployee resets all changes to the "employee" edge.
  30757. func (m *TutorialMutation) ResetEmployee() {
  30758. m.employee = nil
  30759. m.clearedemployee = false
  30760. }
  30761. // Where appends a list predicates to the TutorialMutation builder.
  30762. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  30763. m.predicates = append(m.predicates, ps...)
  30764. }
  30765. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  30766. // users can use type-assertion to append predicates that do not depend on any generated package.
  30767. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  30768. p := make([]predicate.Tutorial, len(ps))
  30769. for i := range ps {
  30770. p[i] = ps[i]
  30771. }
  30772. m.Where(p...)
  30773. }
  30774. // Op returns the operation name.
  30775. func (m *TutorialMutation) Op() Op {
  30776. return m.op
  30777. }
  30778. // SetOp allows setting the mutation operation.
  30779. func (m *TutorialMutation) SetOp(op Op) {
  30780. m.op = op
  30781. }
  30782. // Type returns the node type of this mutation (Tutorial).
  30783. func (m *TutorialMutation) Type() string {
  30784. return m.typ
  30785. }
  30786. // Fields returns all fields that were changed during this mutation. Note that in
  30787. // order to get all numeric fields that were incremented/decremented, call
  30788. // AddedFields().
  30789. func (m *TutorialMutation) Fields() []string {
  30790. fields := make([]string, 0, 8)
  30791. if m.created_at != nil {
  30792. fields = append(fields, tutorial.FieldCreatedAt)
  30793. }
  30794. if m.updated_at != nil {
  30795. fields = append(fields, tutorial.FieldUpdatedAt)
  30796. }
  30797. if m.deleted_at != nil {
  30798. fields = append(fields, tutorial.FieldDeletedAt)
  30799. }
  30800. if m.employee != nil {
  30801. fields = append(fields, tutorial.FieldEmployeeID)
  30802. }
  30803. if m.index != nil {
  30804. fields = append(fields, tutorial.FieldIndex)
  30805. }
  30806. if m.title != nil {
  30807. fields = append(fields, tutorial.FieldTitle)
  30808. }
  30809. if m.content != nil {
  30810. fields = append(fields, tutorial.FieldContent)
  30811. }
  30812. if m.organization_id != nil {
  30813. fields = append(fields, tutorial.FieldOrganizationID)
  30814. }
  30815. return fields
  30816. }
  30817. // Field returns the value of a field with the given name. The second boolean
  30818. // return value indicates that this field was not set, or was not defined in the
  30819. // schema.
  30820. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  30821. switch name {
  30822. case tutorial.FieldCreatedAt:
  30823. return m.CreatedAt()
  30824. case tutorial.FieldUpdatedAt:
  30825. return m.UpdatedAt()
  30826. case tutorial.FieldDeletedAt:
  30827. return m.DeletedAt()
  30828. case tutorial.FieldEmployeeID:
  30829. return m.EmployeeID()
  30830. case tutorial.FieldIndex:
  30831. return m.Index()
  30832. case tutorial.FieldTitle:
  30833. return m.Title()
  30834. case tutorial.FieldContent:
  30835. return m.Content()
  30836. case tutorial.FieldOrganizationID:
  30837. return m.OrganizationID()
  30838. }
  30839. return nil, false
  30840. }
  30841. // OldField returns the old value of the field from the database. An error is
  30842. // returned if the mutation operation is not UpdateOne, or the query to the
  30843. // database failed.
  30844. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30845. switch name {
  30846. case tutorial.FieldCreatedAt:
  30847. return m.OldCreatedAt(ctx)
  30848. case tutorial.FieldUpdatedAt:
  30849. return m.OldUpdatedAt(ctx)
  30850. case tutorial.FieldDeletedAt:
  30851. return m.OldDeletedAt(ctx)
  30852. case tutorial.FieldEmployeeID:
  30853. return m.OldEmployeeID(ctx)
  30854. case tutorial.FieldIndex:
  30855. return m.OldIndex(ctx)
  30856. case tutorial.FieldTitle:
  30857. return m.OldTitle(ctx)
  30858. case tutorial.FieldContent:
  30859. return m.OldContent(ctx)
  30860. case tutorial.FieldOrganizationID:
  30861. return m.OldOrganizationID(ctx)
  30862. }
  30863. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  30864. }
  30865. // SetField sets the value of a field with the given name. It returns an error if
  30866. // the field is not defined in the schema, or if the type mismatched the field
  30867. // type.
  30868. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  30869. switch name {
  30870. case tutorial.FieldCreatedAt:
  30871. v, ok := value.(time.Time)
  30872. if !ok {
  30873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30874. }
  30875. m.SetCreatedAt(v)
  30876. return nil
  30877. case tutorial.FieldUpdatedAt:
  30878. v, ok := value.(time.Time)
  30879. if !ok {
  30880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30881. }
  30882. m.SetUpdatedAt(v)
  30883. return nil
  30884. case tutorial.FieldDeletedAt:
  30885. v, ok := value.(time.Time)
  30886. if !ok {
  30887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30888. }
  30889. m.SetDeletedAt(v)
  30890. return nil
  30891. case tutorial.FieldEmployeeID:
  30892. v, ok := value.(uint64)
  30893. if !ok {
  30894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30895. }
  30896. m.SetEmployeeID(v)
  30897. return nil
  30898. case tutorial.FieldIndex:
  30899. v, ok := value.(int)
  30900. if !ok {
  30901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30902. }
  30903. m.SetIndex(v)
  30904. return nil
  30905. case tutorial.FieldTitle:
  30906. v, ok := value.(string)
  30907. if !ok {
  30908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30909. }
  30910. m.SetTitle(v)
  30911. return nil
  30912. case tutorial.FieldContent:
  30913. v, ok := value.(string)
  30914. if !ok {
  30915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30916. }
  30917. m.SetContent(v)
  30918. return nil
  30919. case tutorial.FieldOrganizationID:
  30920. v, ok := value.(uint64)
  30921. if !ok {
  30922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30923. }
  30924. m.SetOrganizationID(v)
  30925. return nil
  30926. }
  30927. return fmt.Errorf("unknown Tutorial field %s", name)
  30928. }
  30929. // AddedFields returns all numeric fields that were incremented/decremented during
  30930. // this mutation.
  30931. func (m *TutorialMutation) AddedFields() []string {
  30932. var fields []string
  30933. if m.addindex != nil {
  30934. fields = append(fields, tutorial.FieldIndex)
  30935. }
  30936. if m.addorganization_id != nil {
  30937. fields = append(fields, tutorial.FieldOrganizationID)
  30938. }
  30939. return fields
  30940. }
  30941. // AddedField returns the numeric value that was incremented/decremented on a field
  30942. // with the given name. The second boolean return value indicates that this field
  30943. // was not set, or was not defined in the schema.
  30944. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  30945. switch name {
  30946. case tutorial.FieldIndex:
  30947. return m.AddedIndex()
  30948. case tutorial.FieldOrganizationID:
  30949. return m.AddedOrganizationID()
  30950. }
  30951. return nil, false
  30952. }
  30953. // AddField adds the value to the field with the given name. It returns an error if
  30954. // the field is not defined in the schema, or if the type mismatched the field
  30955. // type.
  30956. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  30957. switch name {
  30958. case tutorial.FieldIndex:
  30959. v, ok := value.(int)
  30960. if !ok {
  30961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30962. }
  30963. m.AddIndex(v)
  30964. return nil
  30965. case tutorial.FieldOrganizationID:
  30966. v, ok := value.(int64)
  30967. if !ok {
  30968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30969. }
  30970. m.AddOrganizationID(v)
  30971. return nil
  30972. }
  30973. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  30974. }
  30975. // ClearedFields returns all nullable fields that were cleared during this
  30976. // mutation.
  30977. func (m *TutorialMutation) ClearedFields() []string {
  30978. var fields []string
  30979. if m.FieldCleared(tutorial.FieldDeletedAt) {
  30980. fields = append(fields, tutorial.FieldDeletedAt)
  30981. }
  30982. return fields
  30983. }
  30984. // FieldCleared returns a boolean indicating if a field with the given name was
  30985. // cleared in this mutation.
  30986. func (m *TutorialMutation) FieldCleared(name string) bool {
  30987. _, ok := m.clearedFields[name]
  30988. return ok
  30989. }
  30990. // ClearField clears the value of the field with the given name. It returns an
  30991. // error if the field is not defined in the schema.
  30992. func (m *TutorialMutation) ClearField(name string) error {
  30993. switch name {
  30994. case tutorial.FieldDeletedAt:
  30995. m.ClearDeletedAt()
  30996. return nil
  30997. }
  30998. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  30999. }
  31000. // ResetField resets all changes in the mutation for the field with the given name.
  31001. // It returns an error if the field is not defined in the schema.
  31002. func (m *TutorialMutation) ResetField(name string) error {
  31003. switch name {
  31004. case tutorial.FieldCreatedAt:
  31005. m.ResetCreatedAt()
  31006. return nil
  31007. case tutorial.FieldUpdatedAt:
  31008. m.ResetUpdatedAt()
  31009. return nil
  31010. case tutorial.FieldDeletedAt:
  31011. m.ResetDeletedAt()
  31012. return nil
  31013. case tutorial.FieldEmployeeID:
  31014. m.ResetEmployeeID()
  31015. return nil
  31016. case tutorial.FieldIndex:
  31017. m.ResetIndex()
  31018. return nil
  31019. case tutorial.FieldTitle:
  31020. m.ResetTitle()
  31021. return nil
  31022. case tutorial.FieldContent:
  31023. m.ResetContent()
  31024. return nil
  31025. case tutorial.FieldOrganizationID:
  31026. m.ResetOrganizationID()
  31027. return nil
  31028. }
  31029. return fmt.Errorf("unknown Tutorial field %s", name)
  31030. }
  31031. // AddedEdges returns all edge names that were set/added in this mutation.
  31032. func (m *TutorialMutation) AddedEdges() []string {
  31033. edges := make([]string, 0, 1)
  31034. if m.employee != nil {
  31035. edges = append(edges, tutorial.EdgeEmployee)
  31036. }
  31037. return edges
  31038. }
  31039. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31040. // name in this mutation.
  31041. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  31042. switch name {
  31043. case tutorial.EdgeEmployee:
  31044. if id := m.employee; id != nil {
  31045. return []ent.Value{*id}
  31046. }
  31047. }
  31048. return nil
  31049. }
  31050. // RemovedEdges returns all edge names that were removed in this mutation.
  31051. func (m *TutorialMutation) RemovedEdges() []string {
  31052. edges := make([]string, 0, 1)
  31053. return edges
  31054. }
  31055. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31056. // the given name in this mutation.
  31057. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  31058. return nil
  31059. }
  31060. // ClearedEdges returns all edge names that were cleared in this mutation.
  31061. func (m *TutorialMutation) ClearedEdges() []string {
  31062. edges := make([]string, 0, 1)
  31063. if m.clearedemployee {
  31064. edges = append(edges, tutorial.EdgeEmployee)
  31065. }
  31066. return edges
  31067. }
  31068. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31069. // was cleared in this mutation.
  31070. func (m *TutorialMutation) EdgeCleared(name string) bool {
  31071. switch name {
  31072. case tutorial.EdgeEmployee:
  31073. return m.clearedemployee
  31074. }
  31075. return false
  31076. }
  31077. // ClearEdge clears the value of the edge with the given name. It returns an error
  31078. // if that edge is not defined in the schema.
  31079. func (m *TutorialMutation) ClearEdge(name string) error {
  31080. switch name {
  31081. case tutorial.EdgeEmployee:
  31082. m.ClearEmployee()
  31083. return nil
  31084. }
  31085. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  31086. }
  31087. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31088. // It returns an error if the edge is not defined in the schema.
  31089. func (m *TutorialMutation) ResetEdge(name string) error {
  31090. switch name {
  31091. case tutorial.EdgeEmployee:
  31092. m.ResetEmployee()
  31093. return nil
  31094. }
  31095. return fmt.Errorf("unknown Tutorial edge %s", name)
  31096. }
  31097. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  31098. type UsageDetailMutation struct {
  31099. config
  31100. op Op
  31101. typ string
  31102. id *uint64
  31103. created_at *time.Time
  31104. updated_at *time.Time
  31105. status *uint8
  31106. addstatus *int8
  31107. _type *int
  31108. add_type *int
  31109. bot_id *string
  31110. receiver_id *string
  31111. app *int
  31112. addapp *int
  31113. session_id *uint64
  31114. addsession_id *int64
  31115. request *string
  31116. response *string
  31117. original_data *custom_types.OriginalData
  31118. total_tokens *uint64
  31119. addtotal_tokens *int64
  31120. prompt_tokens *uint64
  31121. addprompt_tokens *int64
  31122. completion_tokens *uint64
  31123. addcompletion_tokens *int64
  31124. organization_id *uint64
  31125. addorganization_id *int64
  31126. clearedFields map[string]struct{}
  31127. done bool
  31128. oldValue func(context.Context) (*UsageDetail, error)
  31129. predicates []predicate.UsageDetail
  31130. }
  31131. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  31132. // usagedetailOption allows management of the mutation configuration using functional options.
  31133. type usagedetailOption func(*UsageDetailMutation)
  31134. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  31135. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  31136. m := &UsageDetailMutation{
  31137. config: c,
  31138. op: op,
  31139. typ: TypeUsageDetail,
  31140. clearedFields: make(map[string]struct{}),
  31141. }
  31142. for _, opt := range opts {
  31143. opt(m)
  31144. }
  31145. return m
  31146. }
  31147. // withUsageDetailID sets the ID field of the mutation.
  31148. func withUsageDetailID(id uint64) usagedetailOption {
  31149. return func(m *UsageDetailMutation) {
  31150. var (
  31151. err error
  31152. once sync.Once
  31153. value *UsageDetail
  31154. )
  31155. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  31156. once.Do(func() {
  31157. if m.done {
  31158. err = errors.New("querying old values post mutation is not allowed")
  31159. } else {
  31160. value, err = m.Client().UsageDetail.Get(ctx, id)
  31161. }
  31162. })
  31163. return value, err
  31164. }
  31165. m.id = &id
  31166. }
  31167. }
  31168. // withUsageDetail sets the old UsageDetail of the mutation.
  31169. func withUsageDetail(node *UsageDetail) usagedetailOption {
  31170. return func(m *UsageDetailMutation) {
  31171. m.oldValue = func(context.Context) (*UsageDetail, error) {
  31172. return node, nil
  31173. }
  31174. m.id = &node.ID
  31175. }
  31176. }
  31177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31178. // executed in a transaction (ent.Tx), a transactional client is returned.
  31179. func (m UsageDetailMutation) Client() *Client {
  31180. client := &Client{config: m.config}
  31181. client.init()
  31182. return client
  31183. }
  31184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31185. // it returns an error otherwise.
  31186. func (m UsageDetailMutation) Tx() (*Tx, error) {
  31187. if _, ok := m.driver.(*txDriver); !ok {
  31188. return nil, errors.New("ent: mutation is not running in a transaction")
  31189. }
  31190. tx := &Tx{config: m.config}
  31191. tx.init()
  31192. return tx, nil
  31193. }
  31194. // SetID sets the value of the id field. Note that this
  31195. // operation is only accepted on creation of UsageDetail entities.
  31196. func (m *UsageDetailMutation) SetID(id uint64) {
  31197. m.id = &id
  31198. }
  31199. // ID returns the ID value in the mutation. Note that the ID is only available
  31200. // if it was provided to the builder or after it was returned from the database.
  31201. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  31202. if m.id == nil {
  31203. return
  31204. }
  31205. return *m.id, true
  31206. }
  31207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31208. // That means, if the mutation is applied within a transaction with an isolation level such
  31209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31210. // or updated by the mutation.
  31211. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  31212. switch {
  31213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31214. id, exists := m.ID()
  31215. if exists {
  31216. return []uint64{id}, nil
  31217. }
  31218. fallthrough
  31219. case m.op.Is(OpUpdate | OpDelete):
  31220. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  31221. default:
  31222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31223. }
  31224. }
  31225. // SetCreatedAt sets the "created_at" field.
  31226. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  31227. m.created_at = &t
  31228. }
  31229. // CreatedAt returns the value of the "created_at" field in the mutation.
  31230. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  31231. v := m.created_at
  31232. if v == nil {
  31233. return
  31234. }
  31235. return *v, true
  31236. }
  31237. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  31238. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31240. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31241. if !m.op.Is(OpUpdateOne) {
  31242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31243. }
  31244. if m.id == nil || m.oldValue == nil {
  31245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31246. }
  31247. oldValue, err := m.oldValue(ctx)
  31248. if err != nil {
  31249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31250. }
  31251. return oldValue.CreatedAt, nil
  31252. }
  31253. // ResetCreatedAt resets all changes to the "created_at" field.
  31254. func (m *UsageDetailMutation) ResetCreatedAt() {
  31255. m.created_at = nil
  31256. }
  31257. // SetUpdatedAt sets the "updated_at" field.
  31258. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  31259. m.updated_at = &t
  31260. }
  31261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31262. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  31263. v := m.updated_at
  31264. if v == nil {
  31265. return
  31266. }
  31267. return *v, true
  31268. }
  31269. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  31270. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31272. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31273. if !m.op.Is(OpUpdateOne) {
  31274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31275. }
  31276. if m.id == nil || m.oldValue == nil {
  31277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31278. }
  31279. oldValue, err := m.oldValue(ctx)
  31280. if err != nil {
  31281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31282. }
  31283. return oldValue.UpdatedAt, nil
  31284. }
  31285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31286. func (m *UsageDetailMutation) ResetUpdatedAt() {
  31287. m.updated_at = nil
  31288. }
  31289. // SetStatus sets the "status" field.
  31290. func (m *UsageDetailMutation) SetStatus(u uint8) {
  31291. m.status = &u
  31292. m.addstatus = nil
  31293. }
  31294. // Status returns the value of the "status" field in the mutation.
  31295. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  31296. v := m.status
  31297. if v == nil {
  31298. return
  31299. }
  31300. return *v, true
  31301. }
  31302. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  31303. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31305. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31306. if !m.op.Is(OpUpdateOne) {
  31307. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31308. }
  31309. if m.id == nil || m.oldValue == nil {
  31310. return v, errors.New("OldStatus requires an ID field in the mutation")
  31311. }
  31312. oldValue, err := m.oldValue(ctx)
  31313. if err != nil {
  31314. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31315. }
  31316. return oldValue.Status, nil
  31317. }
  31318. // AddStatus adds u to the "status" field.
  31319. func (m *UsageDetailMutation) AddStatus(u int8) {
  31320. if m.addstatus != nil {
  31321. *m.addstatus += u
  31322. } else {
  31323. m.addstatus = &u
  31324. }
  31325. }
  31326. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31327. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  31328. v := m.addstatus
  31329. if v == nil {
  31330. return
  31331. }
  31332. return *v, true
  31333. }
  31334. // ClearStatus clears the value of the "status" field.
  31335. func (m *UsageDetailMutation) ClearStatus() {
  31336. m.status = nil
  31337. m.addstatus = nil
  31338. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  31339. }
  31340. // StatusCleared returns if the "status" field was cleared in this mutation.
  31341. func (m *UsageDetailMutation) StatusCleared() bool {
  31342. _, ok := m.clearedFields[usagedetail.FieldStatus]
  31343. return ok
  31344. }
  31345. // ResetStatus resets all changes to the "status" field.
  31346. func (m *UsageDetailMutation) ResetStatus() {
  31347. m.status = nil
  31348. m.addstatus = nil
  31349. delete(m.clearedFields, usagedetail.FieldStatus)
  31350. }
  31351. // SetType sets the "type" field.
  31352. func (m *UsageDetailMutation) SetType(i int) {
  31353. m._type = &i
  31354. m.add_type = nil
  31355. }
  31356. // GetType returns the value of the "type" field in the mutation.
  31357. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  31358. v := m._type
  31359. if v == nil {
  31360. return
  31361. }
  31362. return *v, true
  31363. }
  31364. // OldType returns the old "type" field's value of the UsageDetail entity.
  31365. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31367. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  31368. if !m.op.Is(OpUpdateOne) {
  31369. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31370. }
  31371. if m.id == nil || m.oldValue == nil {
  31372. return v, errors.New("OldType requires an ID field in the mutation")
  31373. }
  31374. oldValue, err := m.oldValue(ctx)
  31375. if err != nil {
  31376. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31377. }
  31378. return oldValue.Type, nil
  31379. }
  31380. // AddType adds i to the "type" field.
  31381. func (m *UsageDetailMutation) AddType(i int) {
  31382. if m.add_type != nil {
  31383. *m.add_type += i
  31384. } else {
  31385. m.add_type = &i
  31386. }
  31387. }
  31388. // AddedType returns the value that was added to the "type" field in this mutation.
  31389. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  31390. v := m.add_type
  31391. if v == nil {
  31392. return
  31393. }
  31394. return *v, true
  31395. }
  31396. // ClearType clears the value of the "type" field.
  31397. func (m *UsageDetailMutation) ClearType() {
  31398. m._type = nil
  31399. m.add_type = nil
  31400. m.clearedFields[usagedetail.FieldType] = struct{}{}
  31401. }
  31402. // TypeCleared returns if the "type" field was cleared in this mutation.
  31403. func (m *UsageDetailMutation) TypeCleared() bool {
  31404. _, ok := m.clearedFields[usagedetail.FieldType]
  31405. return ok
  31406. }
  31407. // ResetType resets all changes to the "type" field.
  31408. func (m *UsageDetailMutation) ResetType() {
  31409. m._type = nil
  31410. m.add_type = nil
  31411. delete(m.clearedFields, usagedetail.FieldType)
  31412. }
  31413. // SetBotID sets the "bot_id" field.
  31414. func (m *UsageDetailMutation) SetBotID(s string) {
  31415. m.bot_id = &s
  31416. }
  31417. // BotID returns the value of the "bot_id" field in the mutation.
  31418. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  31419. v := m.bot_id
  31420. if v == nil {
  31421. return
  31422. }
  31423. return *v, true
  31424. }
  31425. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  31426. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31428. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  31429. if !m.op.Is(OpUpdateOne) {
  31430. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31431. }
  31432. if m.id == nil || m.oldValue == nil {
  31433. return v, errors.New("OldBotID requires an ID field in the mutation")
  31434. }
  31435. oldValue, err := m.oldValue(ctx)
  31436. if err != nil {
  31437. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31438. }
  31439. return oldValue.BotID, nil
  31440. }
  31441. // ResetBotID resets all changes to the "bot_id" field.
  31442. func (m *UsageDetailMutation) ResetBotID() {
  31443. m.bot_id = nil
  31444. }
  31445. // SetReceiverID sets the "receiver_id" field.
  31446. func (m *UsageDetailMutation) SetReceiverID(s string) {
  31447. m.receiver_id = &s
  31448. }
  31449. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  31450. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  31451. v := m.receiver_id
  31452. if v == nil {
  31453. return
  31454. }
  31455. return *v, true
  31456. }
  31457. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  31458. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31460. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  31461. if !m.op.Is(OpUpdateOne) {
  31462. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  31463. }
  31464. if m.id == nil || m.oldValue == nil {
  31465. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  31466. }
  31467. oldValue, err := m.oldValue(ctx)
  31468. if err != nil {
  31469. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  31470. }
  31471. return oldValue.ReceiverID, nil
  31472. }
  31473. // ResetReceiverID resets all changes to the "receiver_id" field.
  31474. func (m *UsageDetailMutation) ResetReceiverID() {
  31475. m.receiver_id = nil
  31476. }
  31477. // SetApp sets the "app" field.
  31478. func (m *UsageDetailMutation) SetApp(i int) {
  31479. m.app = &i
  31480. m.addapp = nil
  31481. }
  31482. // App returns the value of the "app" field in the mutation.
  31483. func (m *UsageDetailMutation) App() (r int, exists bool) {
  31484. v := m.app
  31485. if v == nil {
  31486. return
  31487. }
  31488. return *v, true
  31489. }
  31490. // OldApp returns the old "app" field's value of the UsageDetail entity.
  31491. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31493. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  31494. if !m.op.Is(OpUpdateOne) {
  31495. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  31496. }
  31497. if m.id == nil || m.oldValue == nil {
  31498. return v, errors.New("OldApp requires an ID field in the mutation")
  31499. }
  31500. oldValue, err := m.oldValue(ctx)
  31501. if err != nil {
  31502. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  31503. }
  31504. return oldValue.App, nil
  31505. }
  31506. // AddApp adds i to the "app" field.
  31507. func (m *UsageDetailMutation) AddApp(i int) {
  31508. if m.addapp != nil {
  31509. *m.addapp += i
  31510. } else {
  31511. m.addapp = &i
  31512. }
  31513. }
  31514. // AddedApp returns the value that was added to the "app" field in this mutation.
  31515. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  31516. v := m.addapp
  31517. if v == nil {
  31518. return
  31519. }
  31520. return *v, true
  31521. }
  31522. // ClearApp clears the value of the "app" field.
  31523. func (m *UsageDetailMutation) ClearApp() {
  31524. m.app = nil
  31525. m.addapp = nil
  31526. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  31527. }
  31528. // AppCleared returns if the "app" field was cleared in this mutation.
  31529. func (m *UsageDetailMutation) AppCleared() bool {
  31530. _, ok := m.clearedFields[usagedetail.FieldApp]
  31531. return ok
  31532. }
  31533. // ResetApp resets all changes to the "app" field.
  31534. func (m *UsageDetailMutation) ResetApp() {
  31535. m.app = nil
  31536. m.addapp = nil
  31537. delete(m.clearedFields, usagedetail.FieldApp)
  31538. }
  31539. // SetSessionID sets the "session_id" field.
  31540. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  31541. m.session_id = &u
  31542. m.addsession_id = nil
  31543. }
  31544. // SessionID returns the value of the "session_id" field in the mutation.
  31545. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  31546. v := m.session_id
  31547. if v == nil {
  31548. return
  31549. }
  31550. return *v, true
  31551. }
  31552. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  31553. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31555. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  31556. if !m.op.Is(OpUpdateOne) {
  31557. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  31558. }
  31559. if m.id == nil || m.oldValue == nil {
  31560. return v, errors.New("OldSessionID requires an ID field in the mutation")
  31561. }
  31562. oldValue, err := m.oldValue(ctx)
  31563. if err != nil {
  31564. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  31565. }
  31566. return oldValue.SessionID, nil
  31567. }
  31568. // AddSessionID adds u to the "session_id" field.
  31569. func (m *UsageDetailMutation) AddSessionID(u int64) {
  31570. if m.addsession_id != nil {
  31571. *m.addsession_id += u
  31572. } else {
  31573. m.addsession_id = &u
  31574. }
  31575. }
  31576. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  31577. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  31578. v := m.addsession_id
  31579. if v == nil {
  31580. return
  31581. }
  31582. return *v, true
  31583. }
  31584. // ClearSessionID clears the value of the "session_id" field.
  31585. func (m *UsageDetailMutation) ClearSessionID() {
  31586. m.session_id = nil
  31587. m.addsession_id = nil
  31588. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  31589. }
  31590. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  31591. func (m *UsageDetailMutation) SessionIDCleared() bool {
  31592. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  31593. return ok
  31594. }
  31595. // ResetSessionID resets all changes to the "session_id" field.
  31596. func (m *UsageDetailMutation) ResetSessionID() {
  31597. m.session_id = nil
  31598. m.addsession_id = nil
  31599. delete(m.clearedFields, usagedetail.FieldSessionID)
  31600. }
  31601. // SetRequest sets the "request" field.
  31602. func (m *UsageDetailMutation) SetRequest(s string) {
  31603. m.request = &s
  31604. }
  31605. // Request returns the value of the "request" field in the mutation.
  31606. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  31607. v := m.request
  31608. if v == nil {
  31609. return
  31610. }
  31611. return *v, true
  31612. }
  31613. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  31614. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31616. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  31617. if !m.op.Is(OpUpdateOne) {
  31618. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  31619. }
  31620. if m.id == nil || m.oldValue == nil {
  31621. return v, errors.New("OldRequest requires an ID field in the mutation")
  31622. }
  31623. oldValue, err := m.oldValue(ctx)
  31624. if err != nil {
  31625. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  31626. }
  31627. return oldValue.Request, nil
  31628. }
  31629. // ResetRequest resets all changes to the "request" field.
  31630. func (m *UsageDetailMutation) ResetRequest() {
  31631. m.request = nil
  31632. }
  31633. // SetResponse sets the "response" field.
  31634. func (m *UsageDetailMutation) SetResponse(s string) {
  31635. m.response = &s
  31636. }
  31637. // Response returns the value of the "response" field in the mutation.
  31638. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  31639. v := m.response
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  31646. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldResponse requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  31658. }
  31659. return oldValue.Response, nil
  31660. }
  31661. // ResetResponse resets all changes to the "response" field.
  31662. func (m *UsageDetailMutation) ResetResponse() {
  31663. m.response = nil
  31664. }
  31665. // SetOriginalData sets the "original_data" field.
  31666. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  31667. m.original_data = &ctd
  31668. }
  31669. // OriginalData returns the value of the "original_data" field in the mutation.
  31670. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  31671. v := m.original_data
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  31678. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31680. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  31681. if !m.op.Is(OpUpdateOne) {
  31682. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  31683. }
  31684. if m.id == nil || m.oldValue == nil {
  31685. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  31686. }
  31687. oldValue, err := m.oldValue(ctx)
  31688. if err != nil {
  31689. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  31690. }
  31691. return oldValue.OriginalData, nil
  31692. }
  31693. // ResetOriginalData resets all changes to the "original_data" field.
  31694. func (m *UsageDetailMutation) ResetOriginalData() {
  31695. m.original_data = nil
  31696. }
  31697. // SetTotalTokens sets the "total_tokens" field.
  31698. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  31699. m.total_tokens = &u
  31700. m.addtotal_tokens = nil
  31701. }
  31702. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  31703. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  31704. v := m.total_tokens
  31705. if v == nil {
  31706. return
  31707. }
  31708. return *v, true
  31709. }
  31710. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  31711. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31713. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  31714. if !m.op.Is(OpUpdateOne) {
  31715. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  31716. }
  31717. if m.id == nil || m.oldValue == nil {
  31718. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  31719. }
  31720. oldValue, err := m.oldValue(ctx)
  31721. if err != nil {
  31722. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  31723. }
  31724. return oldValue.TotalTokens, nil
  31725. }
  31726. // AddTotalTokens adds u to the "total_tokens" field.
  31727. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  31728. if m.addtotal_tokens != nil {
  31729. *m.addtotal_tokens += u
  31730. } else {
  31731. m.addtotal_tokens = &u
  31732. }
  31733. }
  31734. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  31735. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  31736. v := m.addtotal_tokens
  31737. if v == nil {
  31738. return
  31739. }
  31740. return *v, true
  31741. }
  31742. // ClearTotalTokens clears the value of the "total_tokens" field.
  31743. func (m *UsageDetailMutation) ClearTotalTokens() {
  31744. m.total_tokens = nil
  31745. m.addtotal_tokens = nil
  31746. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  31747. }
  31748. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  31749. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  31750. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  31751. return ok
  31752. }
  31753. // ResetTotalTokens resets all changes to the "total_tokens" field.
  31754. func (m *UsageDetailMutation) ResetTotalTokens() {
  31755. m.total_tokens = nil
  31756. m.addtotal_tokens = nil
  31757. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  31758. }
  31759. // SetPromptTokens sets the "prompt_tokens" field.
  31760. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  31761. m.prompt_tokens = &u
  31762. m.addprompt_tokens = nil
  31763. }
  31764. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  31765. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  31766. v := m.prompt_tokens
  31767. if v == nil {
  31768. return
  31769. }
  31770. return *v, true
  31771. }
  31772. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  31773. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31775. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  31776. if !m.op.Is(OpUpdateOne) {
  31777. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  31778. }
  31779. if m.id == nil || m.oldValue == nil {
  31780. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  31781. }
  31782. oldValue, err := m.oldValue(ctx)
  31783. if err != nil {
  31784. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  31785. }
  31786. return oldValue.PromptTokens, nil
  31787. }
  31788. // AddPromptTokens adds u to the "prompt_tokens" field.
  31789. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  31790. if m.addprompt_tokens != nil {
  31791. *m.addprompt_tokens += u
  31792. } else {
  31793. m.addprompt_tokens = &u
  31794. }
  31795. }
  31796. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  31797. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  31798. v := m.addprompt_tokens
  31799. if v == nil {
  31800. return
  31801. }
  31802. return *v, true
  31803. }
  31804. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  31805. func (m *UsageDetailMutation) ClearPromptTokens() {
  31806. m.prompt_tokens = nil
  31807. m.addprompt_tokens = nil
  31808. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  31809. }
  31810. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  31811. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  31812. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  31813. return ok
  31814. }
  31815. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  31816. func (m *UsageDetailMutation) ResetPromptTokens() {
  31817. m.prompt_tokens = nil
  31818. m.addprompt_tokens = nil
  31819. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  31820. }
  31821. // SetCompletionTokens sets the "completion_tokens" field.
  31822. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  31823. m.completion_tokens = &u
  31824. m.addcompletion_tokens = nil
  31825. }
  31826. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  31827. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  31828. v := m.completion_tokens
  31829. if v == nil {
  31830. return
  31831. }
  31832. return *v, true
  31833. }
  31834. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  31835. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31837. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  31838. if !m.op.Is(OpUpdateOne) {
  31839. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  31840. }
  31841. if m.id == nil || m.oldValue == nil {
  31842. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  31843. }
  31844. oldValue, err := m.oldValue(ctx)
  31845. if err != nil {
  31846. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  31847. }
  31848. return oldValue.CompletionTokens, nil
  31849. }
  31850. // AddCompletionTokens adds u to the "completion_tokens" field.
  31851. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  31852. if m.addcompletion_tokens != nil {
  31853. *m.addcompletion_tokens += u
  31854. } else {
  31855. m.addcompletion_tokens = &u
  31856. }
  31857. }
  31858. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  31859. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  31860. v := m.addcompletion_tokens
  31861. if v == nil {
  31862. return
  31863. }
  31864. return *v, true
  31865. }
  31866. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  31867. func (m *UsageDetailMutation) ClearCompletionTokens() {
  31868. m.completion_tokens = nil
  31869. m.addcompletion_tokens = nil
  31870. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  31871. }
  31872. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  31873. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  31874. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  31875. return ok
  31876. }
  31877. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  31878. func (m *UsageDetailMutation) ResetCompletionTokens() {
  31879. m.completion_tokens = nil
  31880. m.addcompletion_tokens = nil
  31881. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  31882. }
  31883. // SetOrganizationID sets the "organization_id" field.
  31884. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  31885. m.organization_id = &u
  31886. m.addorganization_id = nil
  31887. }
  31888. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31889. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  31890. v := m.organization_id
  31891. if v == nil {
  31892. return
  31893. }
  31894. return *v, true
  31895. }
  31896. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  31897. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  31898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31899. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31900. if !m.op.Is(OpUpdateOne) {
  31901. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31902. }
  31903. if m.id == nil || m.oldValue == nil {
  31904. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31905. }
  31906. oldValue, err := m.oldValue(ctx)
  31907. if err != nil {
  31908. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31909. }
  31910. return oldValue.OrganizationID, nil
  31911. }
  31912. // AddOrganizationID adds u to the "organization_id" field.
  31913. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  31914. if m.addorganization_id != nil {
  31915. *m.addorganization_id += u
  31916. } else {
  31917. m.addorganization_id = &u
  31918. }
  31919. }
  31920. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31921. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  31922. v := m.addorganization_id
  31923. if v == nil {
  31924. return
  31925. }
  31926. return *v, true
  31927. }
  31928. // ClearOrganizationID clears the value of the "organization_id" field.
  31929. func (m *UsageDetailMutation) ClearOrganizationID() {
  31930. m.organization_id = nil
  31931. m.addorganization_id = nil
  31932. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  31933. }
  31934. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31935. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  31936. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  31937. return ok
  31938. }
  31939. // ResetOrganizationID resets all changes to the "organization_id" field.
  31940. func (m *UsageDetailMutation) ResetOrganizationID() {
  31941. m.organization_id = nil
  31942. m.addorganization_id = nil
  31943. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  31944. }
  31945. // Where appends a list predicates to the UsageDetailMutation builder.
  31946. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  31947. m.predicates = append(m.predicates, ps...)
  31948. }
  31949. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  31950. // users can use type-assertion to append predicates that do not depend on any generated package.
  31951. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  31952. p := make([]predicate.UsageDetail, len(ps))
  31953. for i := range ps {
  31954. p[i] = ps[i]
  31955. }
  31956. m.Where(p...)
  31957. }
  31958. // Op returns the operation name.
  31959. func (m *UsageDetailMutation) Op() Op {
  31960. return m.op
  31961. }
  31962. // SetOp allows setting the mutation operation.
  31963. func (m *UsageDetailMutation) SetOp(op Op) {
  31964. m.op = op
  31965. }
  31966. // Type returns the node type of this mutation (UsageDetail).
  31967. func (m *UsageDetailMutation) Type() string {
  31968. return m.typ
  31969. }
  31970. // Fields returns all fields that were changed during this mutation. Note that in
  31971. // order to get all numeric fields that were incremented/decremented, call
  31972. // AddedFields().
  31973. func (m *UsageDetailMutation) Fields() []string {
  31974. fields := make([]string, 0, 15)
  31975. if m.created_at != nil {
  31976. fields = append(fields, usagedetail.FieldCreatedAt)
  31977. }
  31978. if m.updated_at != nil {
  31979. fields = append(fields, usagedetail.FieldUpdatedAt)
  31980. }
  31981. if m.status != nil {
  31982. fields = append(fields, usagedetail.FieldStatus)
  31983. }
  31984. if m._type != nil {
  31985. fields = append(fields, usagedetail.FieldType)
  31986. }
  31987. if m.bot_id != nil {
  31988. fields = append(fields, usagedetail.FieldBotID)
  31989. }
  31990. if m.receiver_id != nil {
  31991. fields = append(fields, usagedetail.FieldReceiverID)
  31992. }
  31993. if m.app != nil {
  31994. fields = append(fields, usagedetail.FieldApp)
  31995. }
  31996. if m.session_id != nil {
  31997. fields = append(fields, usagedetail.FieldSessionID)
  31998. }
  31999. if m.request != nil {
  32000. fields = append(fields, usagedetail.FieldRequest)
  32001. }
  32002. if m.response != nil {
  32003. fields = append(fields, usagedetail.FieldResponse)
  32004. }
  32005. if m.original_data != nil {
  32006. fields = append(fields, usagedetail.FieldOriginalData)
  32007. }
  32008. if m.total_tokens != nil {
  32009. fields = append(fields, usagedetail.FieldTotalTokens)
  32010. }
  32011. if m.prompt_tokens != nil {
  32012. fields = append(fields, usagedetail.FieldPromptTokens)
  32013. }
  32014. if m.completion_tokens != nil {
  32015. fields = append(fields, usagedetail.FieldCompletionTokens)
  32016. }
  32017. if m.organization_id != nil {
  32018. fields = append(fields, usagedetail.FieldOrganizationID)
  32019. }
  32020. return fields
  32021. }
  32022. // Field returns the value of a field with the given name. The second boolean
  32023. // return value indicates that this field was not set, or was not defined in the
  32024. // schema.
  32025. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  32026. switch name {
  32027. case usagedetail.FieldCreatedAt:
  32028. return m.CreatedAt()
  32029. case usagedetail.FieldUpdatedAt:
  32030. return m.UpdatedAt()
  32031. case usagedetail.FieldStatus:
  32032. return m.Status()
  32033. case usagedetail.FieldType:
  32034. return m.GetType()
  32035. case usagedetail.FieldBotID:
  32036. return m.BotID()
  32037. case usagedetail.FieldReceiverID:
  32038. return m.ReceiverID()
  32039. case usagedetail.FieldApp:
  32040. return m.App()
  32041. case usagedetail.FieldSessionID:
  32042. return m.SessionID()
  32043. case usagedetail.FieldRequest:
  32044. return m.Request()
  32045. case usagedetail.FieldResponse:
  32046. return m.Response()
  32047. case usagedetail.FieldOriginalData:
  32048. return m.OriginalData()
  32049. case usagedetail.FieldTotalTokens:
  32050. return m.TotalTokens()
  32051. case usagedetail.FieldPromptTokens:
  32052. return m.PromptTokens()
  32053. case usagedetail.FieldCompletionTokens:
  32054. return m.CompletionTokens()
  32055. case usagedetail.FieldOrganizationID:
  32056. return m.OrganizationID()
  32057. }
  32058. return nil, false
  32059. }
  32060. // OldField returns the old value of the field from the database. An error is
  32061. // returned if the mutation operation is not UpdateOne, or the query to the
  32062. // database failed.
  32063. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32064. switch name {
  32065. case usagedetail.FieldCreatedAt:
  32066. return m.OldCreatedAt(ctx)
  32067. case usagedetail.FieldUpdatedAt:
  32068. return m.OldUpdatedAt(ctx)
  32069. case usagedetail.FieldStatus:
  32070. return m.OldStatus(ctx)
  32071. case usagedetail.FieldType:
  32072. return m.OldType(ctx)
  32073. case usagedetail.FieldBotID:
  32074. return m.OldBotID(ctx)
  32075. case usagedetail.FieldReceiverID:
  32076. return m.OldReceiverID(ctx)
  32077. case usagedetail.FieldApp:
  32078. return m.OldApp(ctx)
  32079. case usagedetail.FieldSessionID:
  32080. return m.OldSessionID(ctx)
  32081. case usagedetail.FieldRequest:
  32082. return m.OldRequest(ctx)
  32083. case usagedetail.FieldResponse:
  32084. return m.OldResponse(ctx)
  32085. case usagedetail.FieldOriginalData:
  32086. return m.OldOriginalData(ctx)
  32087. case usagedetail.FieldTotalTokens:
  32088. return m.OldTotalTokens(ctx)
  32089. case usagedetail.FieldPromptTokens:
  32090. return m.OldPromptTokens(ctx)
  32091. case usagedetail.FieldCompletionTokens:
  32092. return m.OldCompletionTokens(ctx)
  32093. case usagedetail.FieldOrganizationID:
  32094. return m.OldOrganizationID(ctx)
  32095. }
  32096. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  32097. }
  32098. // SetField sets the value of a field with the given name. It returns an error if
  32099. // the field is not defined in the schema, or if the type mismatched the field
  32100. // type.
  32101. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  32102. switch name {
  32103. case usagedetail.FieldCreatedAt:
  32104. v, ok := value.(time.Time)
  32105. if !ok {
  32106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32107. }
  32108. m.SetCreatedAt(v)
  32109. return nil
  32110. case usagedetail.FieldUpdatedAt:
  32111. v, ok := value.(time.Time)
  32112. if !ok {
  32113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32114. }
  32115. m.SetUpdatedAt(v)
  32116. return nil
  32117. case usagedetail.FieldStatus:
  32118. v, ok := value.(uint8)
  32119. if !ok {
  32120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32121. }
  32122. m.SetStatus(v)
  32123. return nil
  32124. case usagedetail.FieldType:
  32125. v, ok := value.(int)
  32126. if !ok {
  32127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32128. }
  32129. m.SetType(v)
  32130. return nil
  32131. case usagedetail.FieldBotID:
  32132. v, ok := value.(string)
  32133. if !ok {
  32134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32135. }
  32136. m.SetBotID(v)
  32137. return nil
  32138. case usagedetail.FieldReceiverID:
  32139. v, ok := value.(string)
  32140. if !ok {
  32141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32142. }
  32143. m.SetReceiverID(v)
  32144. return nil
  32145. case usagedetail.FieldApp:
  32146. v, ok := value.(int)
  32147. if !ok {
  32148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32149. }
  32150. m.SetApp(v)
  32151. return nil
  32152. case usagedetail.FieldSessionID:
  32153. v, ok := value.(uint64)
  32154. if !ok {
  32155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32156. }
  32157. m.SetSessionID(v)
  32158. return nil
  32159. case usagedetail.FieldRequest:
  32160. v, ok := value.(string)
  32161. if !ok {
  32162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32163. }
  32164. m.SetRequest(v)
  32165. return nil
  32166. case usagedetail.FieldResponse:
  32167. v, ok := value.(string)
  32168. if !ok {
  32169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32170. }
  32171. m.SetResponse(v)
  32172. return nil
  32173. case usagedetail.FieldOriginalData:
  32174. v, ok := value.(custom_types.OriginalData)
  32175. if !ok {
  32176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32177. }
  32178. m.SetOriginalData(v)
  32179. return nil
  32180. case usagedetail.FieldTotalTokens:
  32181. v, ok := value.(uint64)
  32182. if !ok {
  32183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32184. }
  32185. m.SetTotalTokens(v)
  32186. return nil
  32187. case usagedetail.FieldPromptTokens:
  32188. v, ok := value.(uint64)
  32189. if !ok {
  32190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32191. }
  32192. m.SetPromptTokens(v)
  32193. return nil
  32194. case usagedetail.FieldCompletionTokens:
  32195. v, ok := value.(uint64)
  32196. if !ok {
  32197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32198. }
  32199. m.SetCompletionTokens(v)
  32200. return nil
  32201. case usagedetail.FieldOrganizationID:
  32202. v, ok := value.(uint64)
  32203. if !ok {
  32204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32205. }
  32206. m.SetOrganizationID(v)
  32207. return nil
  32208. }
  32209. return fmt.Errorf("unknown UsageDetail field %s", name)
  32210. }
  32211. // AddedFields returns all numeric fields that were incremented/decremented during
  32212. // this mutation.
  32213. func (m *UsageDetailMutation) AddedFields() []string {
  32214. var fields []string
  32215. if m.addstatus != nil {
  32216. fields = append(fields, usagedetail.FieldStatus)
  32217. }
  32218. if m.add_type != nil {
  32219. fields = append(fields, usagedetail.FieldType)
  32220. }
  32221. if m.addapp != nil {
  32222. fields = append(fields, usagedetail.FieldApp)
  32223. }
  32224. if m.addsession_id != nil {
  32225. fields = append(fields, usagedetail.FieldSessionID)
  32226. }
  32227. if m.addtotal_tokens != nil {
  32228. fields = append(fields, usagedetail.FieldTotalTokens)
  32229. }
  32230. if m.addprompt_tokens != nil {
  32231. fields = append(fields, usagedetail.FieldPromptTokens)
  32232. }
  32233. if m.addcompletion_tokens != nil {
  32234. fields = append(fields, usagedetail.FieldCompletionTokens)
  32235. }
  32236. if m.addorganization_id != nil {
  32237. fields = append(fields, usagedetail.FieldOrganizationID)
  32238. }
  32239. return fields
  32240. }
  32241. // AddedField returns the numeric value that was incremented/decremented on a field
  32242. // with the given name. The second boolean return value indicates that this field
  32243. // was not set, or was not defined in the schema.
  32244. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  32245. switch name {
  32246. case usagedetail.FieldStatus:
  32247. return m.AddedStatus()
  32248. case usagedetail.FieldType:
  32249. return m.AddedType()
  32250. case usagedetail.FieldApp:
  32251. return m.AddedApp()
  32252. case usagedetail.FieldSessionID:
  32253. return m.AddedSessionID()
  32254. case usagedetail.FieldTotalTokens:
  32255. return m.AddedTotalTokens()
  32256. case usagedetail.FieldPromptTokens:
  32257. return m.AddedPromptTokens()
  32258. case usagedetail.FieldCompletionTokens:
  32259. return m.AddedCompletionTokens()
  32260. case usagedetail.FieldOrganizationID:
  32261. return m.AddedOrganizationID()
  32262. }
  32263. return nil, false
  32264. }
  32265. // AddField adds the value to the field with the given name. It returns an error if
  32266. // the field is not defined in the schema, or if the type mismatched the field
  32267. // type.
  32268. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  32269. switch name {
  32270. case usagedetail.FieldStatus:
  32271. v, ok := value.(int8)
  32272. if !ok {
  32273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32274. }
  32275. m.AddStatus(v)
  32276. return nil
  32277. case usagedetail.FieldType:
  32278. v, ok := value.(int)
  32279. if !ok {
  32280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32281. }
  32282. m.AddType(v)
  32283. return nil
  32284. case usagedetail.FieldApp:
  32285. v, ok := value.(int)
  32286. if !ok {
  32287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32288. }
  32289. m.AddApp(v)
  32290. return nil
  32291. case usagedetail.FieldSessionID:
  32292. v, ok := value.(int64)
  32293. if !ok {
  32294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32295. }
  32296. m.AddSessionID(v)
  32297. return nil
  32298. case usagedetail.FieldTotalTokens:
  32299. v, ok := value.(int64)
  32300. if !ok {
  32301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32302. }
  32303. m.AddTotalTokens(v)
  32304. return nil
  32305. case usagedetail.FieldPromptTokens:
  32306. v, ok := value.(int64)
  32307. if !ok {
  32308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32309. }
  32310. m.AddPromptTokens(v)
  32311. return nil
  32312. case usagedetail.FieldCompletionTokens:
  32313. v, ok := value.(int64)
  32314. if !ok {
  32315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32316. }
  32317. m.AddCompletionTokens(v)
  32318. return nil
  32319. case usagedetail.FieldOrganizationID:
  32320. v, ok := value.(int64)
  32321. if !ok {
  32322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32323. }
  32324. m.AddOrganizationID(v)
  32325. return nil
  32326. }
  32327. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  32328. }
  32329. // ClearedFields returns all nullable fields that were cleared during this
  32330. // mutation.
  32331. func (m *UsageDetailMutation) ClearedFields() []string {
  32332. var fields []string
  32333. if m.FieldCleared(usagedetail.FieldStatus) {
  32334. fields = append(fields, usagedetail.FieldStatus)
  32335. }
  32336. if m.FieldCleared(usagedetail.FieldType) {
  32337. fields = append(fields, usagedetail.FieldType)
  32338. }
  32339. if m.FieldCleared(usagedetail.FieldApp) {
  32340. fields = append(fields, usagedetail.FieldApp)
  32341. }
  32342. if m.FieldCleared(usagedetail.FieldSessionID) {
  32343. fields = append(fields, usagedetail.FieldSessionID)
  32344. }
  32345. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  32346. fields = append(fields, usagedetail.FieldTotalTokens)
  32347. }
  32348. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  32349. fields = append(fields, usagedetail.FieldPromptTokens)
  32350. }
  32351. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  32352. fields = append(fields, usagedetail.FieldCompletionTokens)
  32353. }
  32354. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  32355. fields = append(fields, usagedetail.FieldOrganizationID)
  32356. }
  32357. return fields
  32358. }
  32359. // FieldCleared returns a boolean indicating if a field with the given name was
  32360. // cleared in this mutation.
  32361. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  32362. _, ok := m.clearedFields[name]
  32363. return ok
  32364. }
  32365. // ClearField clears the value of the field with the given name. It returns an
  32366. // error if the field is not defined in the schema.
  32367. func (m *UsageDetailMutation) ClearField(name string) error {
  32368. switch name {
  32369. case usagedetail.FieldStatus:
  32370. m.ClearStatus()
  32371. return nil
  32372. case usagedetail.FieldType:
  32373. m.ClearType()
  32374. return nil
  32375. case usagedetail.FieldApp:
  32376. m.ClearApp()
  32377. return nil
  32378. case usagedetail.FieldSessionID:
  32379. m.ClearSessionID()
  32380. return nil
  32381. case usagedetail.FieldTotalTokens:
  32382. m.ClearTotalTokens()
  32383. return nil
  32384. case usagedetail.FieldPromptTokens:
  32385. m.ClearPromptTokens()
  32386. return nil
  32387. case usagedetail.FieldCompletionTokens:
  32388. m.ClearCompletionTokens()
  32389. return nil
  32390. case usagedetail.FieldOrganizationID:
  32391. m.ClearOrganizationID()
  32392. return nil
  32393. }
  32394. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  32395. }
  32396. // ResetField resets all changes in the mutation for the field with the given name.
  32397. // It returns an error if the field is not defined in the schema.
  32398. func (m *UsageDetailMutation) ResetField(name string) error {
  32399. switch name {
  32400. case usagedetail.FieldCreatedAt:
  32401. m.ResetCreatedAt()
  32402. return nil
  32403. case usagedetail.FieldUpdatedAt:
  32404. m.ResetUpdatedAt()
  32405. return nil
  32406. case usagedetail.FieldStatus:
  32407. m.ResetStatus()
  32408. return nil
  32409. case usagedetail.FieldType:
  32410. m.ResetType()
  32411. return nil
  32412. case usagedetail.FieldBotID:
  32413. m.ResetBotID()
  32414. return nil
  32415. case usagedetail.FieldReceiverID:
  32416. m.ResetReceiverID()
  32417. return nil
  32418. case usagedetail.FieldApp:
  32419. m.ResetApp()
  32420. return nil
  32421. case usagedetail.FieldSessionID:
  32422. m.ResetSessionID()
  32423. return nil
  32424. case usagedetail.FieldRequest:
  32425. m.ResetRequest()
  32426. return nil
  32427. case usagedetail.FieldResponse:
  32428. m.ResetResponse()
  32429. return nil
  32430. case usagedetail.FieldOriginalData:
  32431. m.ResetOriginalData()
  32432. return nil
  32433. case usagedetail.FieldTotalTokens:
  32434. m.ResetTotalTokens()
  32435. return nil
  32436. case usagedetail.FieldPromptTokens:
  32437. m.ResetPromptTokens()
  32438. return nil
  32439. case usagedetail.FieldCompletionTokens:
  32440. m.ResetCompletionTokens()
  32441. return nil
  32442. case usagedetail.FieldOrganizationID:
  32443. m.ResetOrganizationID()
  32444. return nil
  32445. }
  32446. return fmt.Errorf("unknown UsageDetail field %s", name)
  32447. }
  32448. // AddedEdges returns all edge names that were set/added in this mutation.
  32449. func (m *UsageDetailMutation) AddedEdges() []string {
  32450. edges := make([]string, 0, 0)
  32451. return edges
  32452. }
  32453. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32454. // name in this mutation.
  32455. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  32456. return nil
  32457. }
  32458. // RemovedEdges returns all edge names that were removed in this mutation.
  32459. func (m *UsageDetailMutation) RemovedEdges() []string {
  32460. edges := make([]string, 0, 0)
  32461. return edges
  32462. }
  32463. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32464. // the given name in this mutation.
  32465. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  32466. return nil
  32467. }
  32468. // ClearedEdges returns all edge names that were cleared in this mutation.
  32469. func (m *UsageDetailMutation) ClearedEdges() []string {
  32470. edges := make([]string, 0, 0)
  32471. return edges
  32472. }
  32473. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32474. // was cleared in this mutation.
  32475. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  32476. return false
  32477. }
  32478. // ClearEdge clears the value of the edge with the given name. It returns an error
  32479. // if that edge is not defined in the schema.
  32480. func (m *UsageDetailMutation) ClearEdge(name string) error {
  32481. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  32482. }
  32483. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32484. // It returns an error if the edge is not defined in the schema.
  32485. func (m *UsageDetailMutation) ResetEdge(name string) error {
  32486. return fmt.Errorf("unknown UsageDetail edge %s", name)
  32487. }
  32488. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  32489. type UsageStatisticDayMutation struct {
  32490. config
  32491. op Op
  32492. typ string
  32493. id *uint64
  32494. created_at *time.Time
  32495. updated_at *time.Time
  32496. status *uint8
  32497. addstatus *int8
  32498. deleted_at *time.Time
  32499. addtime *uint64
  32500. addaddtime *int64
  32501. _type *int
  32502. add_type *int
  32503. bot_id *string
  32504. organization_id *uint64
  32505. addorganization_id *int64
  32506. ai_response *uint64
  32507. addai_response *int64
  32508. sop_run *uint64
  32509. addsop_run *int64
  32510. total_friend *uint64
  32511. addtotal_friend *int64
  32512. total_group *uint64
  32513. addtotal_group *int64
  32514. account_balance *uint64
  32515. addaccount_balance *int64
  32516. consume_token *uint64
  32517. addconsume_token *int64
  32518. active_user *uint64
  32519. addactive_user *int64
  32520. new_user *int64
  32521. addnew_user *int64
  32522. label_dist *[]custom_types.LabelDist
  32523. appendlabel_dist []custom_types.LabelDist
  32524. clearedFields map[string]struct{}
  32525. done bool
  32526. oldValue func(context.Context) (*UsageStatisticDay, error)
  32527. predicates []predicate.UsageStatisticDay
  32528. }
  32529. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  32530. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  32531. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  32532. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  32533. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  32534. m := &UsageStatisticDayMutation{
  32535. config: c,
  32536. op: op,
  32537. typ: TypeUsageStatisticDay,
  32538. clearedFields: make(map[string]struct{}),
  32539. }
  32540. for _, opt := range opts {
  32541. opt(m)
  32542. }
  32543. return m
  32544. }
  32545. // withUsageStatisticDayID sets the ID field of the mutation.
  32546. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  32547. return func(m *UsageStatisticDayMutation) {
  32548. var (
  32549. err error
  32550. once sync.Once
  32551. value *UsageStatisticDay
  32552. )
  32553. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  32554. once.Do(func() {
  32555. if m.done {
  32556. err = errors.New("querying old values post mutation is not allowed")
  32557. } else {
  32558. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  32559. }
  32560. })
  32561. return value, err
  32562. }
  32563. m.id = &id
  32564. }
  32565. }
  32566. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  32567. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  32568. return func(m *UsageStatisticDayMutation) {
  32569. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  32570. return node, nil
  32571. }
  32572. m.id = &node.ID
  32573. }
  32574. }
  32575. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32576. // executed in a transaction (ent.Tx), a transactional client is returned.
  32577. func (m UsageStatisticDayMutation) Client() *Client {
  32578. client := &Client{config: m.config}
  32579. client.init()
  32580. return client
  32581. }
  32582. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32583. // it returns an error otherwise.
  32584. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  32585. if _, ok := m.driver.(*txDriver); !ok {
  32586. return nil, errors.New("ent: mutation is not running in a transaction")
  32587. }
  32588. tx := &Tx{config: m.config}
  32589. tx.init()
  32590. return tx, nil
  32591. }
  32592. // SetID sets the value of the id field. Note that this
  32593. // operation is only accepted on creation of UsageStatisticDay entities.
  32594. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  32595. m.id = &id
  32596. }
  32597. // ID returns the ID value in the mutation. Note that the ID is only available
  32598. // if it was provided to the builder or after it was returned from the database.
  32599. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  32600. if m.id == nil {
  32601. return
  32602. }
  32603. return *m.id, true
  32604. }
  32605. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32606. // That means, if the mutation is applied within a transaction with an isolation level such
  32607. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32608. // or updated by the mutation.
  32609. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  32610. switch {
  32611. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32612. id, exists := m.ID()
  32613. if exists {
  32614. return []uint64{id}, nil
  32615. }
  32616. fallthrough
  32617. case m.op.Is(OpUpdate | OpDelete):
  32618. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  32619. default:
  32620. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32621. }
  32622. }
  32623. // SetCreatedAt sets the "created_at" field.
  32624. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  32625. m.created_at = &t
  32626. }
  32627. // CreatedAt returns the value of the "created_at" field in the mutation.
  32628. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  32629. v := m.created_at
  32630. if v == nil {
  32631. return
  32632. }
  32633. return *v, true
  32634. }
  32635. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  32636. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32638. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32639. if !m.op.Is(OpUpdateOne) {
  32640. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32641. }
  32642. if m.id == nil || m.oldValue == nil {
  32643. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32644. }
  32645. oldValue, err := m.oldValue(ctx)
  32646. if err != nil {
  32647. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32648. }
  32649. return oldValue.CreatedAt, nil
  32650. }
  32651. // ResetCreatedAt resets all changes to the "created_at" field.
  32652. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  32653. m.created_at = nil
  32654. }
  32655. // SetUpdatedAt sets the "updated_at" field.
  32656. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  32657. m.updated_at = &t
  32658. }
  32659. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32660. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  32661. v := m.updated_at
  32662. if v == nil {
  32663. return
  32664. }
  32665. return *v, true
  32666. }
  32667. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  32668. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32670. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32671. if !m.op.Is(OpUpdateOne) {
  32672. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32673. }
  32674. if m.id == nil || m.oldValue == nil {
  32675. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32676. }
  32677. oldValue, err := m.oldValue(ctx)
  32678. if err != nil {
  32679. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32680. }
  32681. return oldValue.UpdatedAt, nil
  32682. }
  32683. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32684. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  32685. m.updated_at = nil
  32686. }
  32687. // SetStatus sets the "status" field.
  32688. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  32689. m.status = &u
  32690. m.addstatus = nil
  32691. }
  32692. // Status returns the value of the "status" field in the mutation.
  32693. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  32694. v := m.status
  32695. if v == nil {
  32696. return
  32697. }
  32698. return *v, true
  32699. }
  32700. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  32701. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32703. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32704. if !m.op.Is(OpUpdateOne) {
  32705. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32706. }
  32707. if m.id == nil || m.oldValue == nil {
  32708. return v, errors.New("OldStatus requires an ID field in the mutation")
  32709. }
  32710. oldValue, err := m.oldValue(ctx)
  32711. if err != nil {
  32712. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32713. }
  32714. return oldValue.Status, nil
  32715. }
  32716. // AddStatus adds u to the "status" field.
  32717. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  32718. if m.addstatus != nil {
  32719. *m.addstatus += u
  32720. } else {
  32721. m.addstatus = &u
  32722. }
  32723. }
  32724. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32725. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  32726. v := m.addstatus
  32727. if v == nil {
  32728. return
  32729. }
  32730. return *v, true
  32731. }
  32732. // ClearStatus clears the value of the "status" field.
  32733. func (m *UsageStatisticDayMutation) ClearStatus() {
  32734. m.status = nil
  32735. m.addstatus = nil
  32736. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  32737. }
  32738. // StatusCleared returns if the "status" field was cleared in this mutation.
  32739. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  32740. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  32741. return ok
  32742. }
  32743. // ResetStatus resets all changes to the "status" field.
  32744. func (m *UsageStatisticDayMutation) ResetStatus() {
  32745. m.status = nil
  32746. m.addstatus = nil
  32747. delete(m.clearedFields, usagestatisticday.FieldStatus)
  32748. }
  32749. // SetDeletedAt sets the "deleted_at" field.
  32750. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  32751. m.deleted_at = &t
  32752. }
  32753. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32754. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  32755. v := m.deleted_at
  32756. if v == nil {
  32757. return
  32758. }
  32759. return *v, true
  32760. }
  32761. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  32762. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32764. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32765. if !m.op.Is(OpUpdateOne) {
  32766. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32767. }
  32768. if m.id == nil || m.oldValue == nil {
  32769. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32770. }
  32771. oldValue, err := m.oldValue(ctx)
  32772. if err != nil {
  32773. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32774. }
  32775. return oldValue.DeletedAt, nil
  32776. }
  32777. // ClearDeletedAt clears the value of the "deleted_at" field.
  32778. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  32779. m.deleted_at = nil
  32780. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  32781. }
  32782. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32783. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  32784. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  32785. return ok
  32786. }
  32787. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32788. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  32789. m.deleted_at = nil
  32790. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  32791. }
  32792. // SetAddtime sets the "addtime" field.
  32793. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  32794. m.addtime = &u
  32795. m.addaddtime = nil
  32796. }
  32797. // Addtime returns the value of the "addtime" field in the mutation.
  32798. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  32799. v := m.addtime
  32800. if v == nil {
  32801. return
  32802. }
  32803. return *v, true
  32804. }
  32805. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  32806. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32808. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32809. if !m.op.Is(OpUpdateOne) {
  32810. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32811. }
  32812. if m.id == nil || m.oldValue == nil {
  32813. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32814. }
  32815. oldValue, err := m.oldValue(ctx)
  32816. if err != nil {
  32817. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32818. }
  32819. return oldValue.Addtime, nil
  32820. }
  32821. // AddAddtime adds u to the "addtime" field.
  32822. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  32823. if m.addaddtime != nil {
  32824. *m.addaddtime += u
  32825. } else {
  32826. m.addaddtime = &u
  32827. }
  32828. }
  32829. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32830. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  32831. v := m.addaddtime
  32832. if v == nil {
  32833. return
  32834. }
  32835. return *v, true
  32836. }
  32837. // ResetAddtime resets all changes to the "addtime" field.
  32838. func (m *UsageStatisticDayMutation) ResetAddtime() {
  32839. m.addtime = nil
  32840. m.addaddtime = nil
  32841. }
  32842. // SetType sets the "type" field.
  32843. func (m *UsageStatisticDayMutation) SetType(i int) {
  32844. m._type = &i
  32845. m.add_type = nil
  32846. }
  32847. // GetType returns the value of the "type" field in the mutation.
  32848. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  32849. v := m._type
  32850. if v == nil {
  32851. return
  32852. }
  32853. return *v, true
  32854. }
  32855. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  32856. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32858. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  32859. if !m.op.Is(OpUpdateOne) {
  32860. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32861. }
  32862. if m.id == nil || m.oldValue == nil {
  32863. return v, errors.New("OldType requires an ID field in the mutation")
  32864. }
  32865. oldValue, err := m.oldValue(ctx)
  32866. if err != nil {
  32867. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32868. }
  32869. return oldValue.Type, nil
  32870. }
  32871. // AddType adds i to the "type" field.
  32872. func (m *UsageStatisticDayMutation) AddType(i int) {
  32873. if m.add_type != nil {
  32874. *m.add_type += i
  32875. } else {
  32876. m.add_type = &i
  32877. }
  32878. }
  32879. // AddedType returns the value that was added to the "type" field in this mutation.
  32880. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  32881. v := m.add_type
  32882. if v == nil {
  32883. return
  32884. }
  32885. return *v, true
  32886. }
  32887. // ResetType resets all changes to the "type" field.
  32888. func (m *UsageStatisticDayMutation) ResetType() {
  32889. m._type = nil
  32890. m.add_type = nil
  32891. }
  32892. // SetBotID sets the "bot_id" field.
  32893. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  32894. m.bot_id = &s
  32895. }
  32896. // BotID returns the value of the "bot_id" field in the mutation.
  32897. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  32898. v := m.bot_id
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  32905. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldBotID requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32917. }
  32918. return oldValue.BotID, nil
  32919. }
  32920. // ClearBotID clears the value of the "bot_id" field.
  32921. func (m *UsageStatisticDayMutation) ClearBotID() {
  32922. m.bot_id = nil
  32923. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  32924. }
  32925. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32926. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  32927. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  32928. return ok
  32929. }
  32930. // ResetBotID resets all changes to the "bot_id" field.
  32931. func (m *UsageStatisticDayMutation) ResetBotID() {
  32932. m.bot_id = nil
  32933. delete(m.clearedFields, usagestatisticday.FieldBotID)
  32934. }
  32935. // SetOrganizationID sets the "organization_id" field.
  32936. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  32937. m.organization_id = &u
  32938. m.addorganization_id = nil
  32939. }
  32940. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32941. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  32942. v := m.organization_id
  32943. if v == nil {
  32944. return
  32945. }
  32946. return *v, true
  32947. }
  32948. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  32949. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32951. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32952. if !m.op.Is(OpUpdateOne) {
  32953. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32954. }
  32955. if m.id == nil || m.oldValue == nil {
  32956. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32957. }
  32958. oldValue, err := m.oldValue(ctx)
  32959. if err != nil {
  32960. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32961. }
  32962. return oldValue.OrganizationID, nil
  32963. }
  32964. // AddOrganizationID adds u to the "organization_id" field.
  32965. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  32966. if m.addorganization_id != nil {
  32967. *m.addorganization_id += u
  32968. } else {
  32969. m.addorganization_id = &u
  32970. }
  32971. }
  32972. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32973. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  32974. v := m.addorganization_id
  32975. if v == nil {
  32976. return
  32977. }
  32978. return *v, true
  32979. }
  32980. // ClearOrganizationID clears the value of the "organization_id" field.
  32981. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  32982. m.organization_id = nil
  32983. m.addorganization_id = nil
  32984. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  32985. }
  32986. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32987. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  32988. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  32989. return ok
  32990. }
  32991. // ResetOrganizationID resets all changes to the "organization_id" field.
  32992. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  32993. m.organization_id = nil
  32994. m.addorganization_id = nil
  32995. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  32996. }
  32997. // SetAiResponse sets the "ai_response" field.
  32998. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  32999. m.ai_response = &u
  33000. m.addai_response = nil
  33001. }
  33002. // AiResponse returns the value of the "ai_response" field in the mutation.
  33003. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  33004. v := m.ai_response
  33005. if v == nil {
  33006. return
  33007. }
  33008. return *v, true
  33009. }
  33010. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  33011. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33013. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33014. if !m.op.Is(OpUpdateOne) {
  33015. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33016. }
  33017. if m.id == nil || m.oldValue == nil {
  33018. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33019. }
  33020. oldValue, err := m.oldValue(ctx)
  33021. if err != nil {
  33022. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33023. }
  33024. return oldValue.AiResponse, nil
  33025. }
  33026. // AddAiResponse adds u to the "ai_response" field.
  33027. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  33028. if m.addai_response != nil {
  33029. *m.addai_response += u
  33030. } else {
  33031. m.addai_response = &u
  33032. }
  33033. }
  33034. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33035. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  33036. v := m.addai_response
  33037. if v == nil {
  33038. return
  33039. }
  33040. return *v, true
  33041. }
  33042. // ResetAiResponse resets all changes to the "ai_response" field.
  33043. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  33044. m.ai_response = nil
  33045. m.addai_response = nil
  33046. }
  33047. // SetSopRun sets the "sop_run" field.
  33048. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  33049. m.sop_run = &u
  33050. m.addsop_run = nil
  33051. }
  33052. // SopRun returns the value of the "sop_run" field in the mutation.
  33053. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  33054. v := m.sop_run
  33055. if v == nil {
  33056. return
  33057. }
  33058. return *v, true
  33059. }
  33060. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  33061. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33063. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33064. if !m.op.Is(OpUpdateOne) {
  33065. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33066. }
  33067. if m.id == nil || m.oldValue == nil {
  33068. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33069. }
  33070. oldValue, err := m.oldValue(ctx)
  33071. if err != nil {
  33072. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33073. }
  33074. return oldValue.SopRun, nil
  33075. }
  33076. // AddSopRun adds u to the "sop_run" field.
  33077. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  33078. if m.addsop_run != nil {
  33079. *m.addsop_run += u
  33080. } else {
  33081. m.addsop_run = &u
  33082. }
  33083. }
  33084. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33085. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  33086. v := m.addsop_run
  33087. if v == nil {
  33088. return
  33089. }
  33090. return *v, true
  33091. }
  33092. // ResetSopRun resets all changes to the "sop_run" field.
  33093. func (m *UsageStatisticDayMutation) ResetSopRun() {
  33094. m.sop_run = nil
  33095. m.addsop_run = nil
  33096. }
  33097. // SetTotalFriend sets the "total_friend" field.
  33098. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  33099. m.total_friend = &u
  33100. m.addtotal_friend = nil
  33101. }
  33102. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33103. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  33104. v := m.total_friend
  33105. if v == nil {
  33106. return
  33107. }
  33108. return *v, true
  33109. }
  33110. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  33111. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33113. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33114. if !m.op.Is(OpUpdateOne) {
  33115. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33116. }
  33117. if m.id == nil || m.oldValue == nil {
  33118. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33119. }
  33120. oldValue, err := m.oldValue(ctx)
  33121. if err != nil {
  33122. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33123. }
  33124. return oldValue.TotalFriend, nil
  33125. }
  33126. // AddTotalFriend adds u to the "total_friend" field.
  33127. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  33128. if m.addtotal_friend != nil {
  33129. *m.addtotal_friend += u
  33130. } else {
  33131. m.addtotal_friend = &u
  33132. }
  33133. }
  33134. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33135. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  33136. v := m.addtotal_friend
  33137. if v == nil {
  33138. return
  33139. }
  33140. return *v, true
  33141. }
  33142. // ResetTotalFriend resets all changes to the "total_friend" field.
  33143. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  33144. m.total_friend = nil
  33145. m.addtotal_friend = nil
  33146. }
  33147. // SetTotalGroup sets the "total_group" field.
  33148. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  33149. m.total_group = &u
  33150. m.addtotal_group = nil
  33151. }
  33152. // TotalGroup returns the value of the "total_group" field in the mutation.
  33153. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  33154. v := m.total_group
  33155. if v == nil {
  33156. return
  33157. }
  33158. return *v, true
  33159. }
  33160. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  33161. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33163. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33164. if !m.op.Is(OpUpdateOne) {
  33165. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33166. }
  33167. if m.id == nil || m.oldValue == nil {
  33168. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33169. }
  33170. oldValue, err := m.oldValue(ctx)
  33171. if err != nil {
  33172. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33173. }
  33174. return oldValue.TotalGroup, nil
  33175. }
  33176. // AddTotalGroup adds u to the "total_group" field.
  33177. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  33178. if m.addtotal_group != nil {
  33179. *m.addtotal_group += u
  33180. } else {
  33181. m.addtotal_group = &u
  33182. }
  33183. }
  33184. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33185. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  33186. v := m.addtotal_group
  33187. if v == nil {
  33188. return
  33189. }
  33190. return *v, true
  33191. }
  33192. // ResetTotalGroup resets all changes to the "total_group" field.
  33193. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  33194. m.total_group = nil
  33195. m.addtotal_group = nil
  33196. }
  33197. // SetAccountBalance sets the "account_balance" field.
  33198. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  33199. m.account_balance = &u
  33200. m.addaccount_balance = nil
  33201. }
  33202. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33203. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  33204. v := m.account_balance
  33205. if v == nil {
  33206. return
  33207. }
  33208. return *v, true
  33209. }
  33210. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  33211. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33213. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33214. if !m.op.Is(OpUpdateOne) {
  33215. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33216. }
  33217. if m.id == nil || m.oldValue == nil {
  33218. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33219. }
  33220. oldValue, err := m.oldValue(ctx)
  33221. if err != nil {
  33222. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33223. }
  33224. return oldValue.AccountBalance, nil
  33225. }
  33226. // AddAccountBalance adds u to the "account_balance" field.
  33227. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  33228. if m.addaccount_balance != nil {
  33229. *m.addaccount_balance += u
  33230. } else {
  33231. m.addaccount_balance = &u
  33232. }
  33233. }
  33234. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33235. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  33236. v := m.addaccount_balance
  33237. if v == nil {
  33238. return
  33239. }
  33240. return *v, true
  33241. }
  33242. // ResetAccountBalance resets all changes to the "account_balance" field.
  33243. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  33244. m.account_balance = nil
  33245. m.addaccount_balance = nil
  33246. }
  33247. // SetConsumeToken sets the "consume_token" field.
  33248. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  33249. m.consume_token = &u
  33250. m.addconsume_token = nil
  33251. }
  33252. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33253. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  33254. v := m.consume_token
  33255. if v == nil {
  33256. return
  33257. }
  33258. return *v, true
  33259. }
  33260. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  33261. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33263. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33264. if !m.op.Is(OpUpdateOne) {
  33265. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33266. }
  33267. if m.id == nil || m.oldValue == nil {
  33268. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33269. }
  33270. oldValue, err := m.oldValue(ctx)
  33271. if err != nil {
  33272. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33273. }
  33274. return oldValue.ConsumeToken, nil
  33275. }
  33276. // AddConsumeToken adds u to the "consume_token" field.
  33277. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  33278. if m.addconsume_token != nil {
  33279. *m.addconsume_token += u
  33280. } else {
  33281. m.addconsume_token = &u
  33282. }
  33283. }
  33284. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33285. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  33286. v := m.addconsume_token
  33287. if v == nil {
  33288. return
  33289. }
  33290. return *v, true
  33291. }
  33292. // ResetConsumeToken resets all changes to the "consume_token" field.
  33293. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  33294. m.consume_token = nil
  33295. m.addconsume_token = nil
  33296. }
  33297. // SetActiveUser sets the "active_user" field.
  33298. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  33299. m.active_user = &u
  33300. m.addactive_user = nil
  33301. }
  33302. // ActiveUser returns the value of the "active_user" field in the mutation.
  33303. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  33304. v := m.active_user
  33305. if v == nil {
  33306. return
  33307. }
  33308. return *v, true
  33309. }
  33310. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  33311. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33313. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33314. if !m.op.Is(OpUpdateOne) {
  33315. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33316. }
  33317. if m.id == nil || m.oldValue == nil {
  33318. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33319. }
  33320. oldValue, err := m.oldValue(ctx)
  33321. if err != nil {
  33322. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33323. }
  33324. return oldValue.ActiveUser, nil
  33325. }
  33326. // AddActiveUser adds u to the "active_user" field.
  33327. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  33328. if m.addactive_user != nil {
  33329. *m.addactive_user += u
  33330. } else {
  33331. m.addactive_user = &u
  33332. }
  33333. }
  33334. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33335. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  33336. v := m.addactive_user
  33337. if v == nil {
  33338. return
  33339. }
  33340. return *v, true
  33341. }
  33342. // ResetActiveUser resets all changes to the "active_user" field.
  33343. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  33344. m.active_user = nil
  33345. m.addactive_user = nil
  33346. }
  33347. // SetNewUser sets the "new_user" field.
  33348. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  33349. m.new_user = &i
  33350. m.addnew_user = nil
  33351. }
  33352. // NewUser returns the value of the "new_user" field in the mutation.
  33353. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  33354. v := m.new_user
  33355. if v == nil {
  33356. return
  33357. }
  33358. return *v, true
  33359. }
  33360. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  33361. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33363. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33364. if !m.op.Is(OpUpdateOne) {
  33365. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33366. }
  33367. if m.id == nil || m.oldValue == nil {
  33368. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33369. }
  33370. oldValue, err := m.oldValue(ctx)
  33371. if err != nil {
  33372. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33373. }
  33374. return oldValue.NewUser, nil
  33375. }
  33376. // AddNewUser adds i to the "new_user" field.
  33377. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  33378. if m.addnew_user != nil {
  33379. *m.addnew_user += i
  33380. } else {
  33381. m.addnew_user = &i
  33382. }
  33383. }
  33384. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33385. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  33386. v := m.addnew_user
  33387. if v == nil {
  33388. return
  33389. }
  33390. return *v, true
  33391. }
  33392. // ResetNewUser resets all changes to the "new_user" field.
  33393. func (m *UsageStatisticDayMutation) ResetNewUser() {
  33394. m.new_user = nil
  33395. m.addnew_user = nil
  33396. }
  33397. // SetLabelDist sets the "label_dist" field.
  33398. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33399. m.label_dist = &ctd
  33400. m.appendlabel_dist = nil
  33401. }
  33402. // LabelDist returns the value of the "label_dist" field in the mutation.
  33403. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33404. v := m.label_dist
  33405. if v == nil {
  33406. return
  33407. }
  33408. return *v, true
  33409. }
  33410. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  33411. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  33412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33413. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33414. if !m.op.Is(OpUpdateOne) {
  33415. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33416. }
  33417. if m.id == nil || m.oldValue == nil {
  33418. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33419. }
  33420. oldValue, err := m.oldValue(ctx)
  33421. if err != nil {
  33422. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33423. }
  33424. return oldValue.LabelDist, nil
  33425. }
  33426. // AppendLabelDist adds ctd to the "label_dist" field.
  33427. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33428. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33429. }
  33430. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33431. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33432. if len(m.appendlabel_dist) == 0 {
  33433. return nil, false
  33434. }
  33435. return m.appendlabel_dist, true
  33436. }
  33437. // ResetLabelDist resets all changes to the "label_dist" field.
  33438. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  33439. m.label_dist = nil
  33440. m.appendlabel_dist = nil
  33441. }
  33442. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  33443. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  33444. m.predicates = append(m.predicates, ps...)
  33445. }
  33446. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  33447. // users can use type-assertion to append predicates that do not depend on any generated package.
  33448. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  33449. p := make([]predicate.UsageStatisticDay, len(ps))
  33450. for i := range ps {
  33451. p[i] = ps[i]
  33452. }
  33453. m.Where(p...)
  33454. }
  33455. // Op returns the operation name.
  33456. func (m *UsageStatisticDayMutation) Op() Op {
  33457. return m.op
  33458. }
  33459. // SetOp allows setting the mutation operation.
  33460. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  33461. m.op = op
  33462. }
  33463. // Type returns the node type of this mutation (UsageStatisticDay).
  33464. func (m *UsageStatisticDayMutation) Type() string {
  33465. return m.typ
  33466. }
  33467. // Fields returns all fields that were changed during this mutation. Note that in
  33468. // order to get all numeric fields that were incremented/decremented, call
  33469. // AddedFields().
  33470. func (m *UsageStatisticDayMutation) Fields() []string {
  33471. fields := make([]string, 0, 17)
  33472. if m.created_at != nil {
  33473. fields = append(fields, usagestatisticday.FieldCreatedAt)
  33474. }
  33475. if m.updated_at != nil {
  33476. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  33477. }
  33478. if m.status != nil {
  33479. fields = append(fields, usagestatisticday.FieldStatus)
  33480. }
  33481. if m.deleted_at != nil {
  33482. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33483. }
  33484. if m.addtime != nil {
  33485. fields = append(fields, usagestatisticday.FieldAddtime)
  33486. }
  33487. if m._type != nil {
  33488. fields = append(fields, usagestatisticday.FieldType)
  33489. }
  33490. if m.bot_id != nil {
  33491. fields = append(fields, usagestatisticday.FieldBotID)
  33492. }
  33493. if m.organization_id != nil {
  33494. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33495. }
  33496. if m.ai_response != nil {
  33497. fields = append(fields, usagestatisticday.FieldAiResponse)
  33498. }
  33499. if m.sop_run != nil {
  33500. fields = append(fields, usagestatisticday.FieldSopRun)
  33501. }
  33502. if m.total_friend != nil {
  33503. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33504. }
  33505. if m.total_group != nil {
  33506. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33507. }
  33508. if m.account_balance != nil {
  33509. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33510. }
  33511. if m.consume_token != nil {
  33512. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33513. }
  33514. if m.active_user != nil {
  33515. fields = append(fields, usagestatisticday.FieldActiveUser)
  33516. }
  33517. if m.new_user != nil {
  33518. fields = append(fields, usagestatisticday.FieldNewUser)
  33519. }
  33520. if m.label_dist != nil {
  33521. fields = append(fields, usagestatisticday.FieldLabelDist)
  33522. }
  33523. return fields
  33524. }
  33525. // Field returns the value of a field with the given name. The second boolean
  33526. // return value indicates that this field was not set, or was not defined in the
  33527. // schema.
  33528. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  33529. switch name {
  33530. case usagestatisticday.FieldCreatedAt:
  33531. return m.CreatedAt()
  33532. case usagestatisticday.FieldUpdatedAt:
  33533. return m.UpdatedAt()
  33534. case usagestatisticday.FieldStatus:
  33535. return m.Status()
  33536. case usagestatisticday.FieldDeletedAt:
  33537. return m.DeletedAt()
  33538. case usagestatisticday.FieldAddtime:
  33539. return m.Addtime()
  33540. case usagestatisticday.FieldType:
  33541. return m.GetType()
  33542. case usagestatisticday.FieldBotID:
  33543. return m.BotID()
  33544. case usagestatisticday.FieldOrganizationID:
  33545. return m.OrganizationID()
  33546. case usagestatisticday.FieldAiResponse:
  33547. return m.AiResponse()
  33548. case usagestatisticday.FieldSopRun:
  33549. return m.SopRun()
  33550. case usagestatisticday.FieldTotalFriend:
  33551. return m.TotalFriend()
  33552. case usagestatisticday.FieldTotalGroup:
  33553. return m.TotalGroup()
  33554. case usagestatisticday.FieldAccountBalance:
  33555. return m.AccountBalance()
  33556. case usagestatisticday.FieldConsumeToken:
  33557. return m.ConsumeToken()
  33558. case usagestatisticday.FieldActiveUser:
  33559. return m.ActiveUser()
  33560. case usagestatisticday.FieldNewUser:
  33561. return m.NewUser()
  33562. case usagestatisticday.FieldLabelDist:
  33563. return m.LabelDist()
  33564. }
  33565. return nil, false
  33566. }
  33567. // OldField returns the old value of the field from the database. An error is
  33568. // returned if the mutation operation is not UpdateOne, or the query to the
  33569. // database failed.
  33570. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33571. switch name {
  33572. case usagestatisticday.FieldCreatedAt:
  33573. return m.OldCreatedAt(ctx)
  33574. case usagestatisticday.FieldUpdatedAt:
  33575. return m.OldUpdatedAt(ctx)
  33576. case usagestatisticday.FieldStatus:
  33577. return m.OldStatus(ctx)
  33578. case usagestatisticday.FieldDeletedAt:
  33579. return m.OldDeletedAt(ctx)
  33580. case usagestatisticday.FieldAddtime:
  33581. return m.OldAddtime(ctx)
  33582. case usagestatisticday.FieldType:
  33583. return m.OldType(ctx)
  33584. case usagestatisticday.FieldBotID:
  33585. return m.OldBotID(ctx)
  33586. case usagestatisticday.FieldOrganizationID:
  33587. return m.OldOrganizationID(ctx)
  33588. case usagestatisticday.FieldAiResponse:
  33589. return m.OldAiResponse(ctx)
  33590. case usagestatisticday.FieldSopRun:
  33591. return m.OldSopRun(ctx)
  33592. case usagestatisticday.FieldTotalFriend:
  33593. return m.OldTotalFriend(ctx)
  33594. case usagestatisticday.FieldTotalGroup:
  33595. return m.OldTotalGroup(ctx)
  33596. case usagestatisticday.FieldAccountBalance:
  33597. return m.OldAccountBalance(ctx)
  33598. case usagestatisticday.FieldConsumeToken:
  33599. return m.OldConsumeToken(ctx)
  33600. case usagestatisticday.FieldActiveUser:
  33601. return m.OldActiveUser(ctx)
  33602. case usagestatisticday.FieldNewUser:
  33603. return m.OldNewUser(ctx)
  33604. case usagestatisticday.FieldLabelDist:
  33605. return m.OldLabelDist(ctx)
  33606. }
  33607. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33608. }
  33609. // SetField sets the value of a field with the given name. It returns an error if
  33610. // the field is not defined in the schema, or if the type mismatched the field
  33611. // type.
  33612. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  33613. switch name {
  33614. case usagestatisticday.FieldCreatedAt:
  33615. v, ok := value.(time.Time)
  33616. if !ok {
  33617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33618. }
  33619. m.SetCreatedAt(v)
  33620. return nil
  33621. case usagestatisticday.FieldUpdatedAt:
  33622. v, ok := value.(time.Time)
  33623. if !ok {
  33624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33625. }
  33626. m.SetUpdatedAt(v)
  33627. return nil
  33628. case usagestatisticday.FieldStatus:
  33629. v, ok := value.(uint8)
  33630. if !ok {
  33631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33632. }
  33633. m.SetStatus(v)
  33634. return nil
  33635. case usagestatisticday.FieldDeletedAt:
  33636. v, ok := value.(time.Time)
  33637. if !ok {
  33638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33639. }
  33640. m.SetDeletedAt(v)
  33641. return nil
  33642. case usagestatisticday.FieldAddtime:
  33643. v, ok := value.(uint64)
  33644. if !ok {
  33645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33646. }
  33647. m.SetAddtime(v)
  33648. return nil
  33649. case usagestatisticday.FieldType:
  33650. v, ok := value.(int)
  33651. if !ok {
  33652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33653. }
  33654. m.SetType(v)
  33655. return nil
  33656. case usagestatisticday.FieldBotID:
  33657. v, ok := value.(string)
  33658. if !ok {
  33659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33660. }
  33661. m.SetBotID(v)
  33662. return nil
  33663. case usagestatisticday.FieldOrganizationID:
  33664. v, ok := value.(uint64)
  33665. if !ok {
  33666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33667. }
  33668. m.SetOrganizationID(v)
  33669. return nil
  33670. case usagestatisticday.FieldAiResponse:
  33671. v, ok := value.(uint64)
  33672. if !ok {
  33673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33674. }
  33675. m.SetAiResponse(v)
  33676. return nil
  33677. case usagestatisticday.FieldSopRun:
  33678. v, ok := value.(uint64)
  33679. if !ok {
  33680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33681. }
  33682. m.SetSopRun(v)
  33683. return nil
  33684. case usagestatisticday.FieldTotalFriend:
  33685. v, ok := value.(uint64)
  33686. if !ok {
  33687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33688. }
  33689. m.SetTotalFriend(v)
  33690. return nil
  33691. case usagestatisticday.FieldTotalGroup:
  33692. v, ok := value.(uint64)
  33693. if !ok {
  33694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33695. }
  33696. m.SetTotalGroup(v)
  33697. return nil
  33698. case usagestatisticday.FieldAccountBalance:
  33699. v, ok := value.(uint64)
  33700. if !ok {
  33701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33702. }
  33703. m.SetAccountBalance(v)
  33704. return nil
  33705. case usagestatisticday.FieldConsumeToken:
  33706. v, ok := value.(uint64)
  33707. if !ok {
  33708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33709. }
  33710. m.SetConsumeToken(v)
  33711. return nil
  33712. case usagestatisticday.FieldActiveUser:
  33713. v, ok := value.(uint64)
  33714. if !ok {
  33715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33716. }
  33717. m.SetActiveUser(v)
  33718. return nil
  33719. case usagestatisticday.FieldNewUser:
  33720. v, ok := value.(int64)
  33721. if !ok {
  33722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33723. }
  33724. m.SetNewUser(v)
  33725. return nil
  33726. case usagestatisticday.FieldLabelDist:
  33727. v, ok := value.([]custom_types.LabelDist)
  33728. if !ok {
  33729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33730. }
  33731. m.SetLabelDist(v)
  33732. return nil
  33733. }
  33734. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  33735. }
  33736. // AddedFields returns all numeric fields that were incremented/decremented during
  33737. // this mutation.
  33738. func (m *UsageStatisticDayMutation) AddedFields() []string {
  33739. var fields []string
  33740. if m.addstatus != nil {
  33741. fields = append(fields, usagestatisticday.FieldStatus)
  33742. }
  33743. if m.addaddtime != nil {
  33744. fields = append(fields, usagestatisticday.FieldAddtime)
  33745. }
  33746. if m.add_type != nil {
  33747. fields = append(fields, usagestatisticday.FieldType)
  33748. }
  33749. if m.addorganization_id != nil {
  33750. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33751. }
  33752. if m.addai_response != nil {
  33753. fields = append(fields, usagestatisticday.FieldAiResponse)
  33754. }
  33755. if m.addsop_run != nil {
  33756. fields = append(fields, usagestatisticday.FieldSopRun)
  33757. }
  33758. if m.addtotal_friend != nil {
  33759. fields = append(fields, usagestatisticday.FieldTotalFriend)
  33760. }
  33761. if m.addtotal_group != nil {
  33762. fields = append(fields, usagestatisticday.FieldTotalGroup)
  33763. }
  33764. if m.addaccount_balance != nil {
  33765. fields = append(fields, usagestatisticday.FieldAccountBalance)
  33766. }
  33767. if m.addconsume_token != nil {
  33768. fields = append(fields, usagestatisticday.FieldConsumeToken)
  33769. }
  33770. if m.addactive_user != nil {
  33771. fields = append(fields, usagestatisticday.FieldActiveUser)
  33772. }
  33773. if m.addnew_user != nil {
  33774. fields = append(fields, usagestatisticday.FieldNewUser)
  33775. }
  33776. return fields
  33777. }
  33778. // AddedField returns the numeric value that was incremented/decremented on a field
  33779. // with the given name. The second boolean return value indicates that this field
  33780. // was not set, or was not defined in the schema.
  33781. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  33782. switch name {
  33783. case usagestatisticday.FieldStatus:
  33784. return m.AddedStatus()
  33785. case usagestatisticday.FieldAddtime:
  33786. return m.AddedAddtime()
  33787. case usagestatisticday.FieldType:
  33788. return m.AddedType()
  33789. case usagestatisticday.FieldOrganizationID:
  33790. return m.AddedOrganizationID()
  33791. case usagestatisticday.FieldAiResponse:
  33792. return m.AddedAiResponse()
  33793. case usagestatisticday.FieldSopRun:
  33794. return m.AddedSopRun()
  33795. case usagestatisticday.FieldTotalFriend:
  33796. return m.AddedTotalFriend()
  33797. case usagestatisticday.FieldTotalGroup:
  33798. return m.AddedTotalGroup()
  33799. case usagestatisticday.FieldAccountBalance:
  33800. return m.AddedAccountBalance()
  33801. case usagestatisticday.FieldConsumeToken:
  33802. return m.AddedConsumeToken()
  33803. case usagestatisticday.FieldActiveUser:
  33804. return m.AddedActiveUser()
  33805. case usagestatisticday.FieldNewUser:
  33806. return m.AddedNewUser()
  33807. }
  33808. return nil, false
  33809. }
  33810. // AddField adds the value to the field with the given name. It returns an error if
  33811. // the field is not defined in the schema, or if the type mismatched the field
  33812. // type.
  33813. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  33814. switch name {
  33815. case usagestatisticday.FieldStatus:
  33816. v, ok := value.(int8)
  33817. if !ok {
  33818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33819. }
  33820. m.AddStatus(v)
  33821. return nil
  33822. case usagestatisticday.FieldAddtime:
  33823. v, ok := value.(int64)
  33824. if !ok {
  33825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33826. }
  33827. m.AddAddtime(v)
  33828. return nil
  33829. case usagestatisticday.FieldType:
  33830. v, ok := value.(int)
  33831. if !ok {
  33832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33833. }
  33834. m.AddType(v)
  33835. return nil
  33836. case usagestatisticday.FieldOrganizationID:
  33837. v, ok := value.(int64)
  33838. if !ok {
  33839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33840. }
  33841. m.AddOrganizationID(v)
  33842. return nil
  33843. case usagestatisticday.FieldAiResponse:
  33844. v, ok := value.(int64)
  33845. if !ok {
  33846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33847. }
  33848. m.AddAiResponse(v)
  33849. return nil
  33850. case usagestatisticday.FieldSopRun:
  33851. v, ok := value.(int64)
  33852. if !ok {
  33853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33854. }
  33855. m.AddSopRun(v)
  33856. return nil
  33857. case usagestatisticday.FieldTotalFriend:
  33858. v, ok := value.(int64)
  33859. if !ok {
  33860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33861. }
  33862. m.AddTotalFriend(v)
  33863. return nil
  33864. case usagestatisticday.FieldTotalGroup:
  33865. v, ok := value.(int64)
  33866. if !ok {
  33867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33868. }
  33869. m.AddTotalGroup(v)
  33870. return nil
  33871. case usagestatisticday.FieldAccountBalance:
  33872. v, ok := value.(int64)
  33873. if !ok {
  33874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33875. }
  33876. m.AddAccountBalance(v)
  33877. return nil
  33878. case usagestatisticday.FieldConsumeToken:
  33879. v, ok := value.(int64)
  33880. if !ok {
  33881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33882. }
  33883. m.AddConsumeToken(v)
  33884. return nil
  33885. case usagestatisticday.FieldActiveUser:
  33886. v, ok := value.(int64)
  33887. if !ok {
  33888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33889. }
  33890. m.AddActiveUser(v)
  33891. return nil
  33892. case usagestatisticday.FieldNewUser:
  33893. v, ok := value.(int64)
  33894. if !ok {
  33895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33896. }
  33897. m.AddNewUser(v)
  33898. return nil
  33899. }
  33900. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  33901. }
  33902. // ClearedFields returns all nullable fields that were cleared during this
  33903. // mutation.
  33904. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  33905. var fields []string
  33906. if m.FieldCleared(usagestatisticday.FieldStatus) {
  33907. fields = append(fields, usagestatisticday.FieldStatus)
  33908. }
  33909. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  33910. fields = append(fields, usagestatisticday.FieldDeletedAt)
  33911. }
  33912. if m.FieldCleared(usagestatisticday.FieldBotID) {
  33913. fields = append(fields, usagestatisticday.FieldBotID)
  33914. }
  33915. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  33916. fields = append(fields, usagestatisticday.FieldOrganizationID)
  33917. }
  33918. return fields
  33919. }
  33920. // FieldCleared returns a boolean indicating if a field with the given name was
  33921. // cleared in this mutation.
  33922. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  33923. _, ok := m.clearedFields[name]
  33924. return ok
  33925. }
  33926. // ClearField clears the value of the field with the given name. It returns an
  33927. // error if the field is not defined in the schema.
  33928. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  33929. switch name {
  33930. case usagestatisticday.FieldStatus:
  33931. m.ClearStatus()
  33932. return nil
  33933. case usagestatisticday.FieldDeletedAt:
  33934. m.ClearDeletedAt()
  33935. return nil
  33936. case usagestatisticday.FieldBotID:
  33937. m.ClearBotID()
  33938. return nil
  33939. case usagestatisticday.FieldOrganizationID:
  33940. m.ClearOrganizationID()
  33941. return nil
  33942. }
  33943. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  33944. }
  33945. // ResetField resets all changes in the mutation for the field with the given name.
  33946. // It returns an error if the field is not defined in the schema.
  33947. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  33948. switch name {
  33949. case usagestatisticday.FieldCreatedAt:
  33950. m.ResetCreatedAt()
  33951. return nil
  33952. case usagestatisticday.FieldUpdatedAt:
  33953. m.ResetUpdatedAt()
  33954. return nil
  33955. case usagestatisticday.FieldStatus:
  33956. m.ResetStatus()
  33957. return nil
  33958. case usagestatisticday.FieldDeletedAt:
  33959. m.ResetDeletedAt()
  33960. return nil
  33961. case usagestatisticday.FieldAddtime:
  33962. m.ResetAddtime()
  33963. return nil
  33964. case usagestatisticday.FieldType:
  33965. m.ResetType()
  33966. return nil
  33967. case usagestatisticday.FieldBotID:
  33968. m.ResetBotID()
  33969. return nil
  33970. case usagestatisticday.FieldOrganizationID:
  33971. m.ResetOrganizationID()
  33972. return nil
  33973. case usagestatisticday.FieldAiResponse:
  33974. m.ResetAiResponse()
  33975. return nil
  33976. case usagestatisticday.FieldSopRun:
  33977. m.ResetSopRun()
  33978. return nil
  33979. case usagestatisticday.FieldTotalFriend:
  33980. m.ResetTotalFriend()
  33981. return nil
  33982. case usagestatisticday.FieldTotalGroup:
  33983. m.ResetTotalGroup()
  33984. return nil
  33985. case usagestatisticday.FieldAccountBalance:
  33986. m.ResetAccountBalance()
  33987. return nil
  33988. case usagestatisticday.FieldConsumeToken:
  33989. m.ResetConsumeToken()
  33990. return nil
  33991. case usagestatisticday.FieldActiveUser:
  33992. m.ResetActiveUser()
  33993. return nil
  33994. case usagestatisticday.FieldNewUser:
  33995. m.ResetNewUser()
  33996. return nil
  33997. case usagestatisticday.FieldLabelDist:
  33998. m.ResetLabelDist()
  33999. return nil
  34000. }
  34001. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34002. }
  34003. // AddedEdges returns all edge names that were set/added in this mutation.
  34004. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  34005. edges := make([]string, 0, 0)
  34006. return edges
  34007. }
  34008. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34009. // name in this mutation.
  34010. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  34011. return nil
  34012. }
  34013. // RemovedEdges returns all edge names that were removed in this mutation.
  34014. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  34015. edges := make([]string, 0, 0)
  34016. return edges
  34017. }
  34018. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34019. // the given name in this mutation.
  34020. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  34021. return nil
  34022. }
  34023. // ClearedEdges returns all edge names that were cleared in this mutation.
  34024. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  34025. edges := make([]string, 0, 0)
  34026. return edges
  34027. }
  34028. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34029. // was cleared in this mutation.
  34030. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  34031. return false
  34032. }
  34033. // ClearEdge clears the value of the edge with the given name. It returns an error
  34034. // if that edge is not defined in the schema.
  34035. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  34036. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  34037. }
  34038. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34039. // It returns an error if the edge is not defined in the schema.
  34040. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  34041. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  34042. }
  34043. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  34044. type UsageStatisticHourMutation struct {
  34045. config
  34046. op Op
  34047. typ string
  34048. id *uint64
  34049. created_at *time.Time
  34050. updated_at *time.Time
  34051. status *uint8
  34052. addstatus *int8
  34053. deleted_at *time.Time
  34054. addtime *uint64
  34055. addaddtime *int64
  34056. _type *int
  34057. add_type *int
  34058. bot_id *string
  34059. organization_id *uint64
  34060. addorganization_id *int64
  34061. ai_response *uint64
  34062. addai_response *int64
  34063. sop_run *uint64
  34064. addsop_run *int64
  34065. total_friend *uint64
  34066. addtotal_friend *int64
  34067. total_group *uint64
  34068. addtotal_group *int64
  34069. account_balance *uint64
  34070. addaccount_balance *int64
  34071. consume_token *uint64
  34072. addconsume_token *int64
  34073. active_user *uint64
  34074. addactive_user *int64
  34075. new_user *int64
  34076. addnew_user *int64
  34077. label_dist *[]custom_types.LabelDist
  34078. appendlabel_dist []custom_types.LabelDist
  34079. clearedFields map[string]struct{}
  34080. done bool
  34081. oldValue func(context.Context) (*UsageStatisticHour, error)
  34082. predicates []predicate.UsageStatisticHour
  34083. }
  34084. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  34085. // usagestatistichourOption allows management of the mutation configuration using functional options.
  34086. type usagestatistichourOption func(*UsageStatisticHourMutation)
  34087. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  34088. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  34089. m := &UsageStatisticHourMutation{
  34090. config: c,
  34091. op: op,
  34092. typ: TypeUsageStatisticHour,
  34093. clearedFields: make(map[string]struct{}),
  34094. }
  34095. for _, opt := range opts {
  34096. opt(m)
  34097. }
  34098. return m
  34099. }
  34100. // withUsageStatisticHourID sets the ID field of the mutation.
  34101. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  34102. return func(m *UsageStatisticHourMutation) {
  34103. var (
  34104. err error
  34105. once sync.Once
  34106. value *UsageStatisticHour
  34107. )
  34108. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  34109. once.Do(func() {
  34110. if m.done {
  34111. err = errors.New("querying old values post mutation is not allowed")
  34112. } else {
  34113. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  34114. }
  34115. })
  34116. return value, err
  34117. }
  34118. m.id = &id
  34119. }
  34120. }
  34121. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  34122. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  34123. return func(m *UsageStatisticHourMutation) {
  34124. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  34125. return node, nil
  34126. }
  34127. m.id = &node.ID
  34128. }
  34129. }
  34130. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34131. // executed in a transaction (ent.Tx), a transactional client is returned.
  34132. func (m UsageStatisticHourMutation) Client() *Client {
  34133. client := &Client{config: m.config}
  34134. client.init()
  34135. return client
  34136. }
  34137. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34138. // it returns an error otherwise.
  34139. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  34140. if _, ok := m.driver.(*txDriver); !ok {
  34141. return nil, errors.New("ent: mutation is not running in a transaction")
  34142. }
  34143. tx := &Tx{config: m.config}
  34144. tx.init()
  34145. return tx, nil
  34146. }
  34147. // SetID sets the value of the id field. Note that this
  34148. // operation is only accepted on creation of UsageStatisticHour entities.
  34149. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  34150. m.id = &id
  34151. }
  34152. // ID returns the ID value in the mutation. Note that the ID is only available
  34153. // if it was provided to the builder or after it was returned from the database.
  34154. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  34155. if m.id == nil {
  34156. return
  34157. }
  34158. return *m.id, true
  34159. }
  34160. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34161. // That means, if the mutation is applied within a transaction with an isolation level such
  34162. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34163. // or updated by the mutation.
  34164. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  34165. switch {
  34166. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34167. id, exists := m.ID()
  34168. if exists {
  34169. return []uint64{id}, nil
  34170. }
  34171. fallthrough
  34172. case m.op.Is(OpUpdate | OpDelete):
  34173. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  34174. default:
  34175. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34176. }
  34177. }
  34178. // SetCreatedAt sets the "created_at" field.
  34179. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  34180. m.created_at = &t
  34181. }
  34182. // CreatedAt returns the value of the "created_at" field in the mutation.
  34183. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  34184. v := m.created_at
  34185. if v == nil {
  34186. return
  34187. }
  34188. return *v, true
  34189. }
  34190. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  34191. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34193. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34194. if !m.op.Is(OpUpdateOne) {
  34195. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34196. }
  34197. if m.id == nil || m.oldValue == nil {
  34198. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34199. }
  34200. oldValue, err := m.oldValue(ctx)
  34201. if err != nil {
  34202. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34203. }
  34204. return oldValue.CreatedAt, nil
  34205. }
  34206. // ResetCreatedAt resets all changes to the "created_at" field.
  34207. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  34208. m.created_at = nil
  34209. }
  34210. // SetUpdatedAt sets the "updated_at" field.
  34211. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  34212. m.updated_at = &t
  34213. }
  34214. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34215. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  34216. v := m.updated_at
  34217. if v == nil {
  34218. return
  34219. }
  34220. return *v, true
  34221. }
  34222. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  34223. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34225. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34226. if !m.op.Is(OpUpdateOne) {
  34227. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34228. }
  34229. if m.id == nil || m.oldValue == nil {
  34230. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34231. }
  34232. oldValue, err := m.oldValue(ctx)
  34233. if err != nil {
  34234. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34235. }
  34236. return oldValue.UpdatedAt, nil
  34237. }
  34238. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34239. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  34240. m.updated_at = nil
  34241. }
  34242. // SetStatus sets the "status" field.
  34243. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  34244. m.status = &u
  34245. m.addstatus = nil
  34246. }
  34247. // Status returns the value of the "status" field in the mutation.
  34248. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  34249. v := m.status
  34250. if v == nil {
  34251. return
  34252. }
  34253. return *v, true
  34254. }
  34255. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  34256. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34258. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34259. if !m.op.Is(OpUpdateOne) {
  34260. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34261. }
  34262. if m.id == nil || m.oldValue == nil {
  34263. return v, errors.New("OldStatus requires an ID field in the mutation")
  34264. }
  34265. oldValue, err := m.oldValue(ctx)
  34266. if err != nil {
  34267. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34268. }
  34269. return oldValue.Status, nil
  34270. }
  34271. // AddStatus adds u to the "status" field.
  34272. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  34273. if m.addstatus != nil {
  34274. *m.addstatus += u
  34275. } else {
  34276. m.addstatus = &u
  34277. }
  34278. }
  34279. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34280. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  34281. v := m.addstatus
  34282. if v == nil {
  34283. return
  34284. }
  34285. return *v, true
  34286. }
  34287. // ClearStatus clears the value of the "status" field.
  34288. func (m *UsageStatisticHourMutation) ClearStatus() {
  34289. m.status = nil
  34290. m.addstatus = nil
  34291. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  34292. }
  34293. // StatusCleared returns if the "status" field was cleared in this mutation.
  34294. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  34295. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  34296. return ok
  34297. }
  34298. // ResetStatus resets all changes to the "status" field.
  34299. func (m *UsageStatisticHourMutation) ResetStatus() {
  34300. m.status = nil
  34301. m.addstatus = nil
  34302. delete(m.clearedFields, usagestatistichour.FieldStatus)
  34303. }
  34304. // SetDeletedAt sets the "deleted_at" field.
  34305. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  34306. m.deleted_at = &t
  34307. }
  34308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34309. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  34310. v := m.deleted_at
  34311. if v == nil {
  34312. return
  34313. }
  34314. return *v, true
  34315. }
  34316. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  34317. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34319. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34320. if !m.op.Is(OpUpdateOne) {
  34321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34322. }
  34323. if m.id == nil || m.oldValue == nil {
  34324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34325. }
  34326. oldValue, err := m.oldValue(ctx)
  34327. if err != nil {
  34328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34329. }
  34330. return oldValue.DeletedAt, nil
  34331. }
  34332. // ClearDeletedAt clears the value of the "deleted_at" field.
  34333. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  34334. m.deleted_at = nil
  34335. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  34336. }
  34337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34338. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  34339. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  34340. return ok
  34341. }
  34342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34343. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  34344. m.deleted_at = nil
  34345. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  34346. }
  34347. // SetAddtime sets the "addtime" field.
  34348. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  34349. m.addtime = &u
  34350. m.addaddtime = nil
  34351. }
  34352. // Addtime returns the value of the "addtime" field in the mutation.
  34353. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  34354. v := m.addtime
  34355. if v == nil {
  34356. return
  34357. }
  34358. return *v, true
  34359. }
  34360. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  34361. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34363. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34364. if !m.op.Is(OpUpdateOne) {
  34365. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34366. }
  34367. if m.id == nil || m.oldValue == nil {
  34368. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34369. }
  34370. oldValue, err := m.oldValue(ctx)
  34371. if err != nil {
  34372. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34373. }
  34374. return oldValue.Addtime, nil
  34375. }
  34376. // AddAddtime adds u to the "addtime" field.
  34377. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  34378. if m.addaddtime != nil {
  34379. *m.addaddtime += u
  34380. } else {
  34381. m.addaddtime = &u
  34382. }
  34383. }
  34384. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34385. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  34386. v := m.addaddtime
  34387. if v == nil {
  34388. return
  34389. }
  34390. return *v, true
  34391. }
  34392. // ResetAddtime resets all changes to the "addtime" field.
  34393. func (m *UsageStatisticHourMutation) ResetAddtime() {
  34394. m.addtime = nil
  34395. m.addaddtime = nil
  34396. }
  34397. // SetType sets the "type" field.
  34398. func (m *UsageStatisticHourMutation) SetType(i int) {
  34399. m._type = &i
  34400. m.add_type = nil
  34401. }
  34402. // GetType returns the value of the "type" field in the mutation.
  34403. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  34404. v := m._type
  34405. if v == nil {
  34406. return
  34407. }
  34408. return *v, true
  34409. }
  34410. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  34411. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34413. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  34414. if !m.op.Is(OpUpdateOne) {
  34415. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34416. }
  34417. if m.id == nil || m.oldValue == nil {
  34418. return v, errors.New("OldType requires an ID field in the mutation")
  34419. }
  34420. oldValue, err := m.oldValue(ctx)
  34421. if err != nil {
  34422. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34423. }
  34424. return oldValue.Type, nil
  34425. }
  34426. // AddType adds i to the "type" field.
  34427. func (m *UsageStatisticHourMutation) AddType(i int) {
  34428. if m.add_type != nil {
  34429. *m.add_type += i
  34430. } else {
  34431. m.add_type = &i
  34432. }
  34433. }
  34434. // AddedType returns the value that was added to the "type" field in this mutation.
  34435. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  34436. v := m.add_type
  34437. if v == nil {
  34438. return
  34439. }
  34440. return *v, true
  34441. }
  34442. // ResetType resets all changes to the "type" field.
  34443. func (m *UsageStatisticHourMutation) ResetType() {
  34444. m._type = nil
  34445. m.add_type = nil
  34446. }
  34447. // SetBotID sets the "bot_id" field.
  34448. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  34449. m.bot_id = &s
  34450. }
  34451. // BotID returns the value of the "bot_id" field in the mutation.
  34452. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  34453. v := m.bot_id
  34454. if v == nil {
  34455. return
  34456. }
  34457. return *v, true
  34458. }
  34459. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  34460. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34462. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  34463. if !m.op.Is(OpUpdateOne) {
  34464. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34465. }
  34466. if m.id == nil || m.oldValue == nil {
  34467. return v, errors.New("OldBotID requires an ID field in the mutation")
  34468. }
  34469. oldValue, err := m.oldValue(ctx)
  34470. if err != nil {
  34471. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34472. }
  34473. return oldValue.BotID, nil
  34474. }
  34475. // ClearBotID clears the value of the "bot_id" field.
  34476. func (m *UsageStatisticHourMutation) ClearBotID() {
  34477. m.bot_id = nil
  34478. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  34479. }
  34480. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34481. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  34482. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  34483. return ok
  34484. }
  34485. // ResetBotID resets all changes to the "bot_id" field.
  34486. func (m *UsageStatisticHourMutation) ResetBotID() {
  34487. m.bot_id = nil
  34488. delete(m.clearedFields, usagestatistichour.FieldBotID)
  34489. }
  34490. // SetOrganizationID sets the "organization_id" field.
  34491. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  34492. m.organization_id = &u
  34493. m.addorganization_id = nil
  34494. }
  34495. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34496. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  34497. v := m.organization_id
  34498. if v == nil {
  34499. return
  34500. }
  34501. return *v, true
  34502. }
  34503. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  34504. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34506. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34507. if !m.op.Is(OpUpdateOne) {
  34508. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34509. }
  34510. if m.id == nil || m.oldValue == nil {
  34511. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34512. }
  34513. oldValue, err := m.oldValue(ctx)
  34514. if err != nil {
  34515. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34516. }
  34517. return oldValue.OrganizationID, nil
  34518. }
  34519. // AddOrganizationID adds u to the "organization_id" field.
  34520. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  34521. if m.addorganization_id != nil {
  34522. *m.addorganization_id += u
  34523. } else {
  34524. m.addorganization_id = &u
  34525. }
  34526. }
  34527. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34528. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  34529. v := m.addorganization_id
  34530. if v == nil {
  34531. return
  34532. }
  34533. return *v, true
  34534. }
  34535. // ClearOrganizationID clears the value of the "organization_id" field.
  34536. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  34537. m.organization_id = nil
  34538. m.addorganization_id = nil
  34539. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  34540. }
  34541. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34542. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  34543. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  34544. return ok
  34545. }
  34546. // ResetOrganizationID resets all changes to the "organization_id" field.
  34547. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  34548. m.organization_id = nil
  34549. m.addorganization_id = nil
  34550. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  34551. }
  34552. // SetAiResponse sets the "ai_response" field.
  34553. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  34554. m.ai_response = &u
  34555. m.addai_response = nil
  34556. }
  34557. // AiResponse returns the value of the "ai_response" field in the mutation.
  34558. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  34559. v := m.ai_response
  34560. if v == nil {
  34561. return
  34562. }
  34563. return *v, true
  34564. }
  34565. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  34566. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34568. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34569. if !m.op.Is(OpUpdateOne) {
  34570. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34571. }
  34572. if m.id == nil || m.oldValue == nil {
  34573. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34574. }
  34575. oldValue, err := m.oldValue(ctx)
  34576. if err != nil {
  34577. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34578. }
  34579. return oldValue.AiResponse, nil
  34580. }
  34581. // AddAiResponse adds u to the "ai_response" field.
  34582. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  34583. if m.addai_response != nil {
  34584. *m.addai_response += u
  34585. } else {
  34586. m.addai_response = &u
  34587. }
  34588. }
  34589. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34590. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  34591. v := m.addai_response
  34592. if v == nil {
  34593. return
  34594. }
  34595. return *v, true
  34596. }
  34597. // ResetAiResponse resets all changes to the "ai_response" field.
  34598. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  34599. m.ai_response = nil
  34600. m.addai_response = nil
  34601. }
  34602. // SetSopRun sets the "sop_run" field.
  34603. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  34604. m.sop_run = &u
  34605. m.addsop_run = nil
  34606. }
  34607. // SopRun returns the value of the "sop_run" field in the mutation.
  34608. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  34609. v := m.sop_run
  34610. if v == nil {
  34611. return
  34612. }
  34613. return *v, true
  34614. }
  34615. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  34616. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34618. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34619. if !m.op.Is(OpUpdateOne) {
  34620. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34621. }
  34622. if m.id == nil || m.oldValue == nil {
  34623. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34624. }
  34625. oldValue, err := m.oldValue(ctx)
  34626. if err != nil {
  34627. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34628. }
  34629. return oldValue.SopRun, nil
  34630. }
  34631. // AddSopRun adds u to the "sop_run" field.
  34632. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  34633. if m.addsop_run != nil {
  34634. *m.addsop_run += u
  34635. } else {
  34636. m.addsop_run = &u
  34637. }
  34638. }
  34639. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34640. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  34641. v := m.addsop_run
  34642. if v == nil {
  34643. return
  34644. }
  34645. return *v, true
  34646. }
  34647. // ResetSopRun resets all changes to the "sop_run" field.
  34648. func (m *UsageStatisticHourMutation) ResetSopRun() {
  34649. m.sop_run = nil
  34650. m.addsop_run = nil
  34651. }
  34652. // SetTotalFriend sets the "total_friend" field.
  34653. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  34654. m.total_friend = &u
  34655. m.addtotal_friend = nil
  34656. }
  34657. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34658. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  34659. v := m.total_friend
  34660. if v == nil {
  34661. return
  34662. }
  34663. return *v, true
  34664. }
  34665. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  34666. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34668. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34669. if !m.op.Is(OpUpdateOne) {
  34670. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34671. }
  34672. if m.id == nil || m.oldValue == nil {
  34673. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34674. }
  34675. oldValue, err := m.oldValue(ctx)
  34676. if err != nil {
  34677. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34678. }
  34679. return oldValue.TotalFriend, nil
  34680. }
  34681. // AddTotalFriend adds u to the "total_friend" field.
  34682. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  34683. if m.addtotal_friend != nil {
  34684. *m.addtotal_friend += u
  34685. } else {
  34686. m.addtotal_friend = &u
  34687. }
  34688. }
  34689. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34690. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  34691. v := m.addtotal_friend
  34692. if v == nil {
  34693. return
  34694. }
  34695. return *v, true
  34696. }
  34697. // ResetTotalFriend resets all changes to the "total_friend" field.
  34698. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  34699. m.total_friend = nil
  34700. m.addtotal_friend = nil
  34701. }
  34702. // SetTotalGroup sets the "total_group" field.
  34703. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  34704. m.total_group = &u
  34705. m.addtotal_group = nil
  34706. }
  34707. // TotalGroup returns the value of the "total_group" field in the mutation.
  34708. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  34709. v := m.total_group
  34710. if v == nil {
  34711. return
  34712. }
  34713. return *v, true
  34714. }
  34715. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  34716. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34718. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34719. if !m.op.Is(OpUpdateOne) {
  34720. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34721. }
  34722. if m.id == nil || m.oldValue == nil {
  34723. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34724. }
  34725. oldValue, err := m.oldValue(ctx)
  34726. if err != nil {
  34727. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34728. }
  34729. return oldValue.TotalGroup, nil
  34730. }
  34731. // AddTotalGroup adds u to the "total_group" field.
  34732. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  34733. if m.addtotal_group != nil {
  34734. *m.addtotal_group += u
  34735. } else {
  34736. m.addtotal_group = &u
  34737. }
  34738. }
  34739. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34740. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  34741. v := m.addtotal_group
  34742. if v == nil {
  34743. return
  34744. }
  34745. return *v, true
  34746. }
  34747. // ResetTotalGroup resets all changes to the "total_group" field.
  34748. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  34749. m.total_group = nil
  34750. m.addtotal_group = nil
  34751. }
  34752. // SetAccountBalance sets the "account_balance" field.
  34753. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  34754. m.account_balance = &u
  34755. m.addaccount_balance = nil
  34756. }
  34757. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34758. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  34759. v := m.account_balance
  34760. if v == nil {
  34761. return
  34762. }
  34763. return *v, true
  34764. }
  34765. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  34766. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34768. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34769. if !m.op.Is(OpUpdateOne) {
  34770. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34771. }
  34772. if m.id == nil || m.oldValue == nil {
  34773. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34774. }
  34775. oldValue, err := m.oldValue(ctx)
  34776. if err != nil {
  34777. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34778. }
  34779. return oldValue.AccountBalance, nil
  34780. }
  34781. // AddAccountBalance adds u to the "account_balance" field.
  34782. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  34783. if m.addaccount_balance != nil {
  34784. *m.addaccount_balance += u
  34785. } else {
  34786. m.addaccount_balance = &u
  34787. }
  34788. }
  34789. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34790. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  34791. v := m.addaccount_balance
  34792. if v == nil {
  34793. return
  34794. }
  34795. return *v, true
  34796. }
  34797. // ResetAccountBalance resets all changes to the "account_balance" field.
  34798. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  34799. m.account_balance = nil
  34800. m.addaccount_balance = nil
  34801. }
  34802. // SetConsumeToken sets the "consume_token" field.
  34803. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  34804. m.consume_token = &u
  34805. m.addconsume_token = nil
  34806. }
  34807. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34808. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  34809. v := m.consume_token
  34810. if v == nil {
  34811. return
  34812. }
  34813. return *v, true
  34814. }
  34815. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  34816. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34818. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34819. if !m.op.Is(OpUpdateOne) {
  34820. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34821. }
  34822. if m.id == nil || m.oldValue == nil {
  34823. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34824. }
  34825. oldValue, err := m.oldValue(ctx)
  34826. if err != nil {
  34827. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34828. }
  34829. return oldValue.ConsumeToken, nil
  34830. }
  34831. // AddConsumeToken adds u to the "consume_token" field.
  34832. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  34833. if m.addconsume_token != nil {
  34834. *m.addconsume_token += u
  34835. } else {
  34836. m.addconsume_token = &u
  34837. }
  34838. }
  34839. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34840. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  34841. v := m.addconsume_token
  34842. if v == nil {
  34843. return
  34844. }
  34845. return *v, true
  34846. }
  34847. // ResetConsumeToken resets all changes to the "consume_token" field.
  34848. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  34849. m.consume_token = nil
  34850. m.addconsume_token = nil
  34851. }
  34852. // SetActiveUser sets the "active_user" field.
  34853. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  34854. m.active_user = &u
  34855. m.addactive_user = nil
  34856. }
  34857. // ActiveUser returns the value of the "active_user" field in the mutation.
  34858. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  34859. v := m.active_user
  34860. if v == nil {
  34861. return
  34862. }
  34863. return *v, true
  34864. }
  34865. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  34866. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34868. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34869. if !m.op.Is(OpUpdateOne) {
  34870. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34871. }
  34872. if m.id == nil || m.oldValue == nil {
  34873. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34874. }
  34875. oldValue, err := m.oldValue(ctx)
  34876. if err != nil {
  34877. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34878. }
  34879. return oldValue.ActiveUser, nil
  34880. }
  34881. // AddActiveUser adds u to the "active_user" field.
  34882. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  34883. if m.addactive_user != nil {
  34884. *m.addactive_user += u
  34885. } else {
  34886. m.addactive_user = &u
  34887. }
  34888. }
  34889. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34890. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  34891. v := m.addactive_user
  34892. if v == nil {
  34893. return
  34894. }
  34895. return *v, true
  34896. }
  34897. // ResetActiveUser resets all changes to the "active_user" field.
  34898. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  34899. m.active_user = nil
  34900. m.addactive_user = nil
  34901. }
  34902. // SetNewUser sets the "new_user" field.
  34903. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  34904. m.new_user = &i
  34905. m.addnew_user = nil
  34906. }
  34907. // NewUser returns the value of the "new_user" field in the mutation.
  34908. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  34909. v := m.new_user
  34910. if v == nil {
  34911. return
  34912. }
  34913. return *v, true
  34914. }
  34915. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  34916. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34918. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34919. if !m.op.Is(OpUpdateOne) {
  34920. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34921. }
  34922. if m.id == nil || m.oldValue == nil {
  34923. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34924. }
  34925. oldValue, err := m.oldValue(ctx)
  34926. if err != nil {
  34927. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34928. }
  34929. return oldValue.NewUser, nil
  34930. }
  34931. // AddNewUser adds i to the "new_user" field.
  34932. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  34933. if m.addnew_user != nil {
  34934. *m.addnew_user += i
  34935. } else {
  34936. m.addnew_user = &i
  34937. }
  34938. }
  34939. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34940. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  34941. v := m.addnew_user
  34942. if v == nil {
  34943. return
  34944. }
  34945. return *v, true
  34946. }
  34947. // ResetNewUser resets all changes to the "new_user" field.
  34948. func (m *UsageStatisticHourMutation) ResetNewUser() {
  34949. m.new_user = nil
  34950. m.addnew_user = nil
  34951. }
  34952. // SetLabelDist sets the "label_dist" field.
  34953. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34954. m.label_dist = &ctd
  34955. m.appendlabel_dist = nil
  34956. }
  34957. // LabelDist returns the value of the "label_dist" field in the mutation.
  34958. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34959. v := m.label_dist
  34960. if v == nil {
  34961. return
  34962. }
  34963. return *v, true
  34964. }
  34965. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  34966. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  34967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34968. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34969. if !m.op.Is(OpUpdateOne) {
  34970. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34971. }
  34972. if m.id == nil || m.oldValue == nil {
  34973. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34974. }
  34975. oldValue, err := m.oldValue(ctx)
  34976. if err != nil {
  34977. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34978. }
  34979. return oldValue.LabelDist, nil
  34980. }
  34981. // AppendLabelDist adds ctd to the "label_dist" field.
  34982. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34983. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34984. }
  34985. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34986. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34987. if len(m.appendlabel_dist) == 0 {
  34988. return nil, false
  34989. }
  34990. return m.appendlabel_dist, true
  34991. }
  34992. // ResetLabelDist resets all changes to the "label_dist" field.
  34993. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  34994. m.label_dist = nil
  34995. m.appendlabel_dist = nil
  34996. }
  34997. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  34998. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  34999. m.predicates = append(m.predicates, ps...)
  35000. }
  35001. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  35002. // users can use type-assertion to append predicates that do not depend on any generated package.
  35003. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  35004. p := make([]predicate.UsageStatisticHour, len(ps))
  35005. for i := range ps {
  35006. p[i] = ps[i]
  35007. }
  35008. m.Where(p...)
  35009. }
  35010. // Op returns the operation name.
  35011. func (m *UsageStatisticHourMutation) Op() Op {
  35012. return m.op
  35013. }
  35014. // SetOp allows setting the mutation operation.
  35015. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  35016. m.op = op
  35017. }
  35018. // Type returns the node type of this mutation (UsageStatisticHour).
  35019. func (m *UsageStatisticHourMutation) Type() string {
  35020. return m.typ
  35021. }
  35022. // Fields returns all fields that were changed during this mutation. Note that in
  35023. // order to get all numeric fields that were incremented/decremented, call
  35024. // AddedFields().
  35025. func (m *UsageStatisticHourMutation) Fields() []string {
  35026. fields := make([]string, 0, 17)
  35027. if m.created_at != nil {
  35028. fields = append(fields, usagestatistichour.FieldCreatedAt)
  35029. }
  35030. if m.updated_at != nil {
  35031. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  35032. }
  35033. if m.status != nil {
  35034. fields = append(fields, usagestatistichour.FieldStatus)
  35035. }
  35036. if m.deleted_at != nil {
  35037. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35038. }
  35039. if m.addtime != nil {
  35040. fields = append(fields, usagestatistichour.FieldAddtime)
  35041. }
  35042. if m._type != nil {
  35043. fields = append(fields, usagestatistichour.FieldType)
  35044. }
  35045. if m.bot_id != nil {
  35046. fields = append(fields, usagestatistichour.FieldBotID)
  35047. }
  35048. if m.organization_id != nil {
  35049. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35050. }
  35051. if m.ai_response != nil {
  35052. fields = append(fields, usagestatistichour.FieldAiResponse)
  35053. }
  35054. if m.sop_run != nil {
  35055. fields = append(fields, usagestatistichour.FieldSopRun)
  35056. }
  35057. if m.total_friend != nil {
  35058. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35059. }
  35060. if m.total_group != nil {
  35061. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35062. }
  35063. if m.account_balance != nil {
  35064. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35065. }
  35066. if m.consume_token != nil {
  35067. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35068. }
  35069. if m.active_user != nil {
  35070. fields = append(fields, usagestatistichour.FieldActiveUser)
  35071. }
  35072. if m.new_user != nil {
  35073. fields = append(fields, usagestatistichour.FieldNewUser)
  35074. }
  35075. if m.label_dist != nil {
  35076. fields = append(fields, usagestatistichour.FieldLabelDist)
  35077. }
  35078. return fields
  35079. }
  35080. // Field returns the value of a field with the given name. The second boolean
  35081. // return value indicates that this field was not set, or was not defined in the
  35082. // schema.
  35083. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  35084. switch name {
  35085. case usagestatistichour.FieldCreatedAt:
  35086. return m.CreatedAt()
  35087. case usagestatistichour.FieldUpdatedAt:
  35088. return m.UpdatedAt()
  35089. case usagestatistichour.FieldStatus:
  35090. return m.Status()
  35091. case usagestatistichour.FieldDeletedAt:
  35092. return m.DeletedAt()
  35093. case usagestatistichour.FieldAddtime:
  35094. return m.Addtime()
  35095. case usagestatistichour.FieldType:
  35096. return m.GetType()
  35097. case usagestatistichour.FieldBotID:
  35098. return m.BotID()
  35099. case usagestatistichour.FieldOrganizationID:
  35100. return m.OrganizationID()
  35101. case usagestatistichour.FieldAiResponse:
  35102. return m.AiResponse()
  35103. case usagestatistichour.FieldSopRun:
  35104. return m.SopRun()
  35105. case usagestatistichour.FieldTotalFriend:
  35106. return m.TotalFriend()
  35107. case usagestatistichour.FieldTotalGroup:
  35108. return m.TotalGroup()
  35109. case usagestatistichour.FieldAccountBalance:
  35110. return m.AccountBalance()
  35111. case usagestatistichour.FieldConsumeToken:
  35112. return m.ConsumeToken()
  35113. case usagestatistichour.FieldActiveUser:
  35114. return m.ActiveUser()
  35115. case usagestatistichour.FieldNewUser:
  35116. return m.NewUser()
  35117. case usagestatistichour.FieldLabelDist:
  35118. return m.LabelDist()
  35119. }
  35120. return nil, false
  35121. }
  35122. // OldField returns the old value of the field from the database. An error is
  35123. // returned if the mutation operation is not UpdateOne, or the query to the
  35124. // database failed.
  35125. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35126. switch name {
  35127. case usagestatistichour.FieldCreatedAt:
  35128. return m.OldCreatedAt(ctx)
  35129. case usagestatistichour.FieldUpdatedAt:
  35130. return m.OldUpdatedAt(ctx)
  35131. case usagestatistichour.FieldStatus:
  35132. return m.OldStatus(ctx)
  35133. case usagestatistichour.FieldDeletedAt:
  35134. return m.OldDeletedAt(ctx)
  35135. case usagestatistichour.FieldAddtime:
  35136. return m.OldAddtime(ctx)
  35137. case usagestatistichour.FieldType:
  35138. return m.OldType(ctx)
  35139. case usagestatistichour.FieldBotID:
  35140. return m.OldBotID(ctx)
  35141. case usagestatistichour.FieldOrganizationID:
  35142. return m.OldOrganizationID(ctx)
  35143. case usagestatistichour.FieldAiResponse:
  35144. return m.OldAiResponse(ctx)
  35145. case usagestatistichour.FieldSopRun:
  35146. return m.OldSopRun(ctx)
  35147. case usagestatistichour.FieldTotalFriend:
  35148. return m.OldTotalFriend(ctx)
  35149. case usagestatistichour.FieldTotalGroup:
  35150. return m.OldTotalGroup(ctx)
  35151. case usagestatistichour.FieldAccountBalance:
  35152. return m.OldAccountBalance(ctx)
  35153. case usagestatistichour.FieldConsumeToken:
  35154. return m.OldConsumeToken(ctx)
  35155. case usagestatistichour.FieldActiveUser:
  35156. return m.OldActiveUser(ctx)
  35157. case usagestatistichour.FieldNewUser:
  35158. return m.OldNewUser(ctx)
  35159. case usagestatistichour.FieldLabelDist:
  35160. return m.OldLabelDist(ctx)
  35161. }
  35162. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35163. }
  35164. // SetField sets the value of a field with the given name. It returns an error if
  35165. // the field is not defined in the schema, or if the type mismatched the field
  35166. // type.
  35167. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  35168. switch name {
  35169. case usagestatistichour.FieldCreatedAt:
  35170. v, ok := value.(time.Time)
  35171. if !ok {
  35172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35173. }
  35174. m.SetCreatedAt(v)
  35175. return nil
  35176. case usagestatistichour.FieldUpdatedAt:
  35177. v, ok := value.(time.Time)
  35178. if !ok {
  35179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35180. }
  35181. m.SetUpdatedAt(v)
  35182. return nil
  35183. case usagestatistichour.FieldStatus:
  35184. v, ok := value.(uint8)
  35185. if !ok {
  35186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35187. }
  35188. m.SetStatus(v)
  35189. return nil
  35190. case usagestatistichour.FieldDeletedAt:
  35191. v, ok := value.(time.Time)
  35192. if !ok {
  35193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35194. }
  35195. m.SetDeletedAt(v)
  35196. return nil
  35197. case usagestatistichour.FieldAddtime:
  35198. v, ok := value.(uint64)
  35199. if !ok {
  35200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35201. }
  35202. m.SetAddtime(v)
  35203. return nil
  35204. case usagestatistichour.FieldType:
  35205. v, ok := value.(int)
  35206. if !ok {
  35207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35208. }
  35209. m.SetType(v)
  35210. return nil
  35211. case usagestatistichour.FieldBotID:
  35212. v, ok := value.(string)
  35213. if !ok {
  35214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35215. }
  35216. m.SetBotID(v)
  35217. return nil
  35218. case usagestatistichour.FieldOrganizationID:
  35219. v, ok := value.(uint64)
  35220. if !ok {
  35221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35222. }
  35223. m.SetOrganizationID(v)
  35224. return nil
  35225. case usagestatistichour.FieldAiResponse:
  35226. v, ok := value.(uint64)
  35227. if !ok {
  35228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35229. }
  35230. m.SetAiResponse(v)
  35231. return nil
  35232. case usagestatistichour.FieldSopRun:
  35233. v, ok := value.(uint64)
  35234. if !ok {
  35235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35236. }
  35237. m.SetSopRun(v)
  35238. return nil
  35239. case usagestatistichour.FieldTotalFriend:
  35240. v, ok := value.(uint64)
  35241. if !ok {
  35242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35243. }
  35244. m.SetTotalFriend(v)
  35245. return nil
  35246. case usagestatistichour.FieldTotalGroup:
  35247. v, ok := value.(uint64)
  35248. if !ok {
  35249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35250. }
  35251. m.SetTotalGroup(v)
  35252. return nil
  35253. case usagestatistichour.FieldAccountBalance:
  35254. v, ok := value.(uint64)
  35255. if !ok {
  35256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35257. }
  35258. m.SetAccountBalance(v)
  35259. return nil
  35260. case usagestatistichour.FieldConsumeToken:
  35261. v, ok := value.(uint64)
  35262. if !ok {
  35263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35264. }
  35265. m.SetConsumeToken(v)
  35266. return nil
  35267. case usagestatistichour.FieldActiveUser:
  35268. v, ok := value.(uint64)
  35269. if !ok {
  35270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35271. }
  35272. m.SetActiveUser(v)
  35273. return nil
  35274. case usagestatistichour.FieldNewUser:
  35275. v, ok := value.(int64)
  35276. if !ok {
  35277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35278. }
  35279. m.SetNewUser(v)
  35280. return nil
  35281. case usagestatistichour.FieldLabelDist:
  35282. v, ok := value.([]custom_types.LabelDist)
  35283. if !ok {
  35284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35285. }
  35286. m.SetLabelDist(v)
  35287. return nil
  35288. }
  35289. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35290. }
  35291. // AddedFields returns all numeric fields that were incremented/decremented during
  35292. // this mutation.
  35293. func (m *UsageStatisticHourMutation) AddedFields() []string {
  35294. var fields []string
  35295. if m.addstatus != nil {
  35296. fields = append(fields, usagestatistichour.FieldStatus)
  35297. }
  35298. if m.addaddtime != nil {
  35299. fields = append(fields, usagestatistichour.FieldAddtime)
  35300. }
  35301. if m.add_type != nil {
  35302. fields = append(fields, usagestatistichour.FieldType)
  35303. }
  35304. if m.addorganization_id != nil {
  35305. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35306. }
  35307. if m.addai_response != nil {
  35308. fields = append(fields, usagestatistichour.FieldAiResponse)
  35309. }
  35310. if m.addsop_run != nil {
  35311. fields = append(fields, usagestatistichour.FieldSopRun)
  35312. }
  35313. if m.addtotal_friend != nil {
  35314. fields = append(fields, usagestatistichour.FieldTotalFriend)
  35315. }
  35316. if m.addtotal_group != nil {
  35317. fields = append(fields, usagestatistichour.FieldTotalGroup)
  35318. }
  35319. if m.addaccount_balance != nil {
  35320. fields = append(fields, usagestatistichour.FieldAccountBalance)
  35321. }
  35322. if m.addconsume_token != nil {
  35323. fields = append(fields, usagestatistichour.FieldConsumeToken)
  35324. }
  35325. if m.addactive_user != nil {
  35326. fields = append(fields, usagestatistichour.FieldActiveUser)
  35327. }
  35328. if m.addnew_user != nil {
  35329. fields = append(fields, usagestatistichour.FieldNewUser)
  35330. }
  35331. return fields
  35332. }
  35333. // AddedField returns the numeric value that was incremented/decremented on a field
  35334. // with the given name. The second boolean return value indicates that this field
  35335. // was not set, or was not defined in the schema.
  35336. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  35337. switch name {
  35338. case usagestatistichour.FieldStatus:
  35339. return m.AddedStatus()
  35340. case usagestatistichour.FieldAddtime:
  35341. return m.AddedAddtime()
  35342. case usagestatistichour.FieldType:
  35343. return m.AddedType()
  35344. case usagestatistichour.FieldOrganizationID:
  35345. return m.AddedOrganizationID()
  35346. case usagestatistichour.FieldAiResponse:
  35347. return m.AddedAiResponse()
  35348. case usagestatistichour.FieldSopRun:
  35349. return m.AddedSopRun()
  35350. case usagestatistichour.FieldTotalFriend:
  35351. return m.AddedTotalFriend()
  35352. case usagestatistichour.FieldTotalGroup:
  35353. return m.AddedTotalGroup()
  35354. case usagestatistichour.FieldAccountBalance:
  35355. return m.AddedAccountBalance()
  35356. case usagestatistichour.FieldConsumeToken:
  35357. return m.AddedConsumeToken()
  35358. case usagestatistichour.FieldActiveUser:
  35359. return m.AddedActiveUser()
  35360. case usagestatistichour.FieldNewUser:
  35361. return m.AddedNewUser()
  35362. }
  35363. return nil, false
  35364. }
  35365. // AddField adds the value to the field with the given name. It returns an error if
  35366. // the field is not defined in the schema, or if the type mismatched the field
  35367. // type.
  35368. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  35369. switch name {
  35370. case usagestatistichour.FieldStatus:
  35371. v, ok := value.(int8)
  35372. if !ok {
  35373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35374. }
  35375. m.AddStatus(v)
  35376. return nil
  35377. case usagestatistichour.FieldAddtime:
  35378. v, ok := value.(int64)
  35379. if !ok {
  35380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35381. }
  35382. m.AddAddtime(v)
  35383. return nil
  35384. case usagestatistichour.FieldType:
  35385. v, ok := value.(int)
  35386. if !ok {
  35387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35388. }
  35389. m.AddType(v)
  35390. return nil
  35391. case usagestatistichour.FieldOrganizationID:
  35392. v, ok := value.(int64)
  35393. if !ok {
  35394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35395. }
  35396. m.AddOrganizationID(v)
  35397. return nil
  35398. case usagestatistichour.FieldAiResponse:
  35399. v, ok := value.(int64)
  35400. if !ok {
  35401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35402. }
  35403. m.AddAiResponse(v)
  35404. return nil
  35405. case usagestatistichour.FieldSopRun:
  35406. v, ok := value.(int64)
  35407. if !ok {
  35408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35409. }
  35410. m.AddSopRun(v)
  35411. return nil
  35412. case usagestatistichour.FieldTotalFriend:
  35413. v, ok := value.(int64)
  35414. if !ok {
  35415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35416. }
  35417. m.AddTotalFriend(v)
  35418. return nil
  35419. case usagestatistichour.FieldTotalGroup:
  35420. v, ok := value.(int64)
  35421. if !ok {
  35422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35423. }
  35424. m.AddTotalGroup(v)
  35425. return nil
  35426. case usagestatistichour.FieldAccountBalance:
  35427. v, ok := value.(int64)
  35428. if !ok {
  35429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35430. }
  35431. m.AddAccountBalance(v)
  35432. return nil
  35433. case usagestatistichour.FieldConsumeToken:
  35434. v, ok := value.(int64)
  35435. if !ok {
  35436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35437. }
  35438. m.AddConsumeToken(v)
  35439. return nil
  35440. case usagestatistichour.FieldActiveUser:
  35441. v, ok := value.(int64)
  35442. if !ok {
  35443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35444. }
  35445. m.AddActiveUser(v)
  35446. return nil
  35447. case usagestatistichour.FieldNewUser:
  35448. v, ok := value.(int64)
  35449. if !ok {
  35450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35451. }
  35452. m.AddNewUser(v)
  35453. return nil
  35454. }
  35455. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  35456. }
  35457. // ClearedFields returns all nullable fields that were cleared during this
  35458. // mutation.
  35459. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  35460. var fields []string
  35461. if m.FieldCleared(usagestatistichour.FieldStatus) {
  35462. fields = append(fields, usagestatistichour.FieldStatus)
  35463. }
  35464. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  35465. fields = append(fields, usagestatistichour.FieldDeletedAt)
  35466. }
  35467. if m.FieldCleared(usagestatistichour.FieldBotID) {
  35468. fields = append(fields, usagestatistichour.FieldBotID)
  35469. }
  35470. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  35471. fields = append(fields, usagestatistichour.FieldOrganizationID)
  35472. }
  35473. return fields
  35474. }
  35475. // FieldCleared returns a boolean indicating if a field with the given name was
  35476. // cleared in this mutation.
  35477. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  35478. _, ok := m.clearedFields[name]
  35479. return ok
  35480. }
  35481. // ClearField clears the value of the field with the given name. It returns an
  35482. // error if the field is not defined in the schema.
  35483. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  35484. switch name {
  35485. case usagestatistichour.FieldStatus:
  35486. m.ClearStatus()
  35487. return nil
  35488. case usagestatistichour.FieldDeletedAt:
  35489. m.ClearDeletedAt()
  35490. return nil
  35491. case usagestatistichour.FieldBotID:
  35492. m.ClearBotID()
  35493. return nil
  35494. case usagestatistichour.FieldOrganizationID:
  35495. m.ClearOrganizationID()
  35496. return nil
  35497. }
  35498. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  35499. }
  35500. // ResetField resets all changes in the mutation for the field with the given name.
  35501. // It returns an error if the field is not defined in the schema.
  35502. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  35503. switch name {
  35504. case usagestatistichour.FieldCreatedAt:
  35505. m.ResetCreatedAt()
  35506. return nil
  35507. case usagestatistichour.FieldUpdatedAt:
  35508. m.ResetUpdatedAt()
  35509. return nil
  35510. case usagestatistichour.FieldStatus:
  35511. m.ResetStatus()
  35512. return nil
  35513. case usagestatistichour.FieldDeletedAt:
  35514. m.ResetDeletedAt()
  35515. return nil
  35516. case usagestatistichour.FieldAddtime:
  35517. m.ResetAddtime()
  35518. return nil
  35519. case usagestatistichour.FieldType:
  35520. m.ResetType()
  35521. return nil
  35522. case usagestatistichour.FieldBotID:
  35523. m.ResetBotID()
  35524. return nil
  35525. case usagestatistichour.FieldOrganizationID:
  35526. m.ResetOrganizationID()
  35527. return nil
  35528. case usagestatistichour.FieldAiResponse:
  35529. m.ResetAiResponse()
  35530. return nil
  35531. case usagestatistichour.FieldSopRun:
  35532. m.ResetSopRun()
  35533. return nil
  35534. case usagestatistichour.FieldTotalFriend:
  35535. m.ResetTotalFriend()
  35536. return nil
  35537. case usagestatistichour.FieldTotalGroup:
  35538. m.ResetTotalGroup()
  35539. return nil
  35540. case usagestatistichour.FieldAccountBalance:
  35541. m.ResetAccountBalance()
  35542. return nil
  35543. case usagestatistichour.FieldConsumeToken:
  35544. m.ResetConsumeToken()
  35545. return nil
  35546. case usagestatistichour.FieldActiveUser:
  35547. m.ResetActiveUser()
  35548. return nil
  35549. case usagestatistichour.FieldNewUser:
  35550. m.ResetNewUser()
  35551. return nil
  35552. case usagestatistichour.FieldLabelDist:
  35553. m.ResetLabelDist()
  35554. return nil
  35555. }
  35556. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  35557. }
  35558. // AddedEdges returns all edge names that were set/added in this mutation.
  35559. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  35560. edges := make([]string, 0, 0)
  35561. return edges
  35562. }
  35563. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35564. // name in this mutation.
  35565. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  35566. return nil
  35567. }
  35568. // RemovedEdges returns all edge names that were removed in this mutation.
  35569. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  35570. edges := make([]string, 0, 0)
  35571. return edges
  35572. }
  35573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35574. // the given name in this mutation.
  35575. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  35576. return nil
  35577. }
  35578. // ClearedEdges returns all edge names that were cleared in this mutation.
  35579. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  35580. edges := make([]string, 0, 0)
  35581. return edges
  35582. }
  35583. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35584. // was cleared in this mutation.
  35585. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  35586. return false
  35587. }
  35588. // ClearEdge clears the value of the edge with the given name. It returns an error
  35589. // if that edge is not defined in the schema.
  35590. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  35591. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  35592. }
  35593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35594. // It returns an error if the edge is not defined in the schema.
  35595. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  35596. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  35597. }
  35598. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  35599. type UsageStatisticMonthMutation struct {
  35600. config
  35601. op Op
  35602. typ string
  35603. id *uint64
  35604. created_at *time.Time
  35605. updated_at *time.Time
  35606. status *uint8
  35607. addstatus *int8
  35608. deleted_at *time.Time
  35609. addtime *uint64
  35610. addaddtime *int64
  35611. _type *int
  35612. add_type *int
  35613. bot_id *string
  35614. organization_id *uint64
  35615. addorganization_id *int64
  35616. ai_response *uint64
  35617. addai_response *int64
  35618. sop_run *uint64
  35619. addsop_run *int64
  35620. total_friend *uint64
  35621. addtotal_friend *int64
  35622. total_group *uint64
  35623. addtotal_group *int64
  35624. account_balance *uint64
  35625. addaccount_balance *int64
  35626. consume_token *uint64
  35627. addconsume_token *int64
  35628. active_user *uint64
  35629. addactive_user *int64
  35630. new_user *int64
  35631. addnew_user *int64
  35632. label_dist *[]custom_types.LabelDist
  35633. appendlabel_dist []custom_types.LabelDist
  35634. clearedFields map[string]struct{}
  35635. done bool
  35636. oldValue func(context.Context) (*UsageStatisticMonth, error)
  35637. predicates []predicate.UsageStatisticMonth
  35638. }
  35639. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  35640. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  35641. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  35642. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  35643. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  35644. m := &UsageStatisticMonthMutation{
  35645. config: c,
  35646. op: op,
  35647. typ: TypeUsageStatisticMonth,
  35648. clearedFields: make(map[string]struct{}),
  35649. }
  35650. for _, opt := range opts {
  35651. opt(m)
  35652. }
  35653. return m
  35654. }
  35655. // withUsageStatisticMonthID sets the ID field of the mutation.
  35656. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  35657. return func(m *UsageStatisticMonthMutation) {
  35658. var (
  35659. err error
  35660. once sync.Once
  35661. value *UsageStatisticMonth
  35662. )
  35663. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  35664. once.Do(func() {
  35665. if m.done {
  35666. err = errors.New("querying old values post mutation is not allowed")
  35667. } else {
  35668. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  35669. }
  35670. })
  35671. return value, err
  35672. }
  35673. m.id = &id
  35674. }
  35675. }
  35676. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  35677. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  35678. return func(m *UsageStatisticMonthMutation) {
  35679. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  35680. return node, nil
  35681. }
  35682. m.id = &node.ID
  35683. }
  35684. }
  35685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35686. // executed in a transaction (ent.Tx), a transactional client is returned.
  35687. func (m UsageStatisticMonthMutation) Client() *Client {
  35688. client := &Client{config: m.config}
  35689. client.init()
  35690. return client
  35691. }
  35692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35693. // it returns an error otherwise.
  35694. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  35695. if _, ok := m.driver.(*txDriver); !ok {
  35696. return nil, errors.New("ent: mutation is not running in a transaction")
  35697. }
  35698. tx := &Tx{config: m.config}
  35699. tx.init()
  35700. return tx, nil
  35701. }
  35702. // SetID sets the value of the id field. Note that this
  35703. // operation is only accepted on creation of UsageStatisticMonth entities.
  35704. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  35705. m.id = &id
  35706. }
  35707. // ID returns the ID value in the mutation. Note that the ID is only available
  35708. // if it was provided to the builder or after it was returned from the database.
  35709. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  35710. if m.id == nil {
  35711. return
  35712. }
  35713. return *m.id, true
  35714. }
  35715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35716. // That means, if the mutation is applied within a transaction with an isolation level such
  35717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35718. // or updated by the mutation.
  35719. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  35720. switch {
  35721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35722. id, exists := m.ID()
  35723. if exists {
  35724. return []uint64{id}, nil
  35725. }
  35726. fallthrough
  35727. case m.op.Is(OpUpdate | OpDelete):
  35728. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  35729. default:
  35730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35731. }
  35732. }
  35733. // SetCreatedAt sets the "created_at" field.
  35734. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  35735. m.created_at = &t
  35736. }
  35737. // CreatedAt returns the value of the "created_at" field in the mutation.
  35738. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  35739. v := m.created_at
  35740. if v == nil {
  35741. return
  35742. }
  35743. return *v, true
  35744. }
  35745. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  35746. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35748. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35749. if !m.op.Is(OpUpdateOne) {
  35750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35751. }
  35752. if m.id == nil || m.oldValue == nil {
  35753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35754. }
  35755. oldValue, err := m.oldValue(ctx)
  35756. if err != nil {
  35757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35758. }
  35759. return oldValue.CreatedAt, nil
  35760. }
  35761. // ResetCreatedAt resets all changes to the "created_at" field.
  35762. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  35763. m.created_at = nil
  35764. }
  35765. // SetUpdatedAt sets the "updated_at" field.
  35766. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  35767. m.updated_at = &t
  35768. }
  35769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35770. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  35771. v := m.updated_at
  35772. if v == nil {
  35773. return
  35774. }
  35775. return *v, true
  35776. }
  35777. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  35778. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35780. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35781. if !m.op.Is(OpUpdateOne) {
  35782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35783. }
  35784. if m.id == nil || m.oldValue == nil {
  35785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35786. }
  35787. oldValue, err := m.oldValue(ctx)
  35788. if err != nil {
  35789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35790. }
  35791. return oldValue.UpdatedAt, nil
  35792. }
  35793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35794. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  35795. m.updated_at = nil
  35796. }
  35797. // SetStatus sets the "status" field.
  35798. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  35799. m.status = &u
  35800. m.addstatus = nil
  35801. }
  35802. // Status returns the value of the "status" field in the mutation.
  35803. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  35804. v := m.status
  35805. if v == nil {
  35806. return
  35807. }
  35808. return *v, true
  35809. }
  35810. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  35811. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35813. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35814. if !m.op.Is(OpUpdateOne) {
  35815. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35816. }
  35817. if m.id == nil || m.oldValue == nil {
  35818. return v, errors.New("OldStatus requires an ID field in the mutation")
  35819. }
  35820. oldValue, err := m.oldValue(ctx)
  35821. if err != nil {
  35822. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35823. }
  35824. return oldValue.Status, nil
  35825. }
  35826. // AddStatus adds u to the "status" field.
  35827. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  35828. if m.addstatus != nil {
  35829. *m.addstatus += u
  35830. } else {
  35831. m.addstatus = &u
  35832. }
  35833. }
  35834. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35835. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  35836. v := m.addstatus
  35837. if v == nil {
  35838. return
  35839. }
  35840. return *v, true
  35841. }
  35842. // ClearStatus clears the value of the "status" field.
  35843. func (m *UsageStatisticMonthMutation) ClearStatus() {
  35844. m.status = nil
  35845. m.addstatus = nil
  35846. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  35847. }
  35848. // StatusCleared returns if the "status" field was cleared in this mutation.
  35849. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  35850. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  35851. return ok
  35852. }
  35853. // ResetStatus resets all changes to the "status" field.
  35854. func (m *UsageStatisticMonthMutation) ResetStatus() {
  35855. m.status = nil
  35856. m.addstatus = nil
  35857. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  35858. }
  35859. // SetDeletedAt sets the "deleted_at" field.
  35860. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  35861. m.deleted_at = &t
  35862. }
  35863. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35864. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  35865. v := m.deleted_at
  35866. if v == nil {
  35867. return
  35868. }
  35869. return *v, true
  35870. }
  35871. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  35872. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35874. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35875. if !m.op.Is(OpUpdateOne) {
  35876. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35877. }
  35878. if m.id == nil || m.oldValue == nil {
  35879. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35880. }
  35881. oldValue, err := m.oldValue(ctx)
  35882. if err != nil {
  35883. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35884. }
  35885. return oldValue.DeletedAt, nil
  35886. }
  35887. // ClearDeletedAt clears the value of the "deleted_at" field.
  35888. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  35889. m.deleted_at = nil
  35890. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  35891. }
  35892. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35893. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  35894. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  35895. return ok
  35896. }
  35897. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35898. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  35899. m.deleted_at = nil
  35900. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  35901. }
  35902. // SetAddtime sets the "addtime" field.
  35903. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  35904. m.addtime = &u
  35905. m.addaddtime = nil
  35906. }
  35907. // Addtime returns the value of the "addtime" field in the mutation.
  35908. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  35909. v := m.addtime
  35910. if v == nil {
  35911. return
  35912. }
  35913. return *v, true
  35914. }
  35915. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  35916. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35918. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35919. if !m.op.Is(OpUpdateOne) {
  35920. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35921. }
  35922. if m.id == nil || m.oldValue == nil {
  35923. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35924. }
  35925. oldValue, err := m.oldValue(ctx)
  35926. if err != nil {
  35927. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35928. }
  35929. return oldValue.Addtime, nil
  35930. }
  35931. // AddAddtime adds u to the "addtime" field.
  35932. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  35933. if m.addaddtime != nil {
  35934. *m.addaddtime += u
  35935. } else {
  35936. m.addaddtime = &u
  35937. }
  35938. }
  35939. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35940. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  35941. v := m.addaddtime
  35942. if v == nil {
  35943. return
  35944. }
  35945. return *v, true
  35946. }
  35947. // ResetAddtime resets all changes to the "addtime" field.
  35948. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  35949. m.addtime = nil
  35950. m.addaddtime = nil
  35951. }
  35952. // SetType sets the "type" field.
  35953. func (m *UsageStatisticMonthMutation) SetType(i int) {
  35954. m._type = &i
  35955. m.add_type = nil
  35956. }
  35957. // GetType returns the value of the "type" field in the mutation.
  35958. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  35959. v := m._type
  35960. if v == nil {
  35961. return
  35962. }
  35963. return *v, true
  35964. }
  35965. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  35966. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35968. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  35969. if !m.op.Is(OpUpdateOne) {
  35970. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35971. }
  35972. if m.id == nil || m.oldValue == nil {
  35973. return v, errors.New("OldType requires an ID field in the mutation")
  35974. }
  35975. oldValue, err := m.oldValue(ctx)
  35976. if err != nil {
  35977. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35978. }
  35979. return oldValue.Type, nil
  35980. }
  35981. // AddType adds i to the "type" field.
  35982. func (m *UsageStatisticMonthMutation) AddType(i int) {
  35983. if m.add_type != nil {
  35984. *m.add_type += i
  35985. } else {
  35986. m.add_type = &i
  35987. }
  35988. }
  35989. // AddedType returns the value that was added to the "type" field in this mutation.
  35990. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  35991. v := m.add_type
  35992. if v == nil {
  35993. return
  35994. }
  35995. return *v, true
  35996. }
  35997. // ResetType resets all changes to the "type" field.
  35998. func (m *UsageStatisticMonthMutation) ResetType() {
  35999. m._type = nil
  36000. m.add_type = nil
  36001. }
  36002. // SetBotID sets the "bot_id" field.
  36003. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  36004. m.bot_id = &s
  36005. }
  36006. // BotID returns the value of the "bot_id" field in the mutation.
  36007. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  36008. v := m.bot_id
  36009. if v == nil {
  36010. return
  36011. }
  36012. return *v, true
  36013. }
  36014. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  36015. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36017. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  36018. if !m.op.Is(OpUpdateOne) {
  36019. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36020. }
  36021. if m.id == nil || m.oldValue == nil {
  36022. return v, errors.New("OldBotID requires an ID field in the mutation")
  36023. }
  36024. oldValue, err := m.oldValue(ctx)
  36025. if err != nil {
  36026. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36027. }
  36028. return oldValue.BotID, nil
  36029. }
  36030. // ClearBotID clears the value of the "bot_id" field.
  36031. func (m *UsageStatisticMonthMutation) ClearBotID() {
  36032. m.bot_id = nil
  36033. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  36034. }
  36035. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36036. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  36037. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  36038. return ok
  36039. }
  36040. // ResetBotID resets all changes to the "bot_id" field.
  36041. func (m *UsageStatisticMonthMutation) ResetBotID() {
  36042. m.bot_id = nil
  36043. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  36044. }
  36045. // SetOrganizationID sets the "organization_id" field.
  36046. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  36047. m.organization_id = &u
  36048. m.addorganization_id = nil
  36049. }
  36050. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36051. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  36052. v := m.organization_id
  36053. if v == nil {
  36054. return
  36055. }
  36056. return *v, true
  36057. }
  36058. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  36059. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36061. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36062. if !m.op.Is(OpUpdateOne) {
  36063. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36064. }
  36065. if m.id == nil || m.oldValue == nil {
  36066. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36067. }
  36068. oldValue, err := m.oldValue(ctx)
  36069. if err != nil {
  36070. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36071. }
  36072. return oldValue.OrganizationID, nil
  36073. }
  36074. // AddOrganizationID adds u to the "organization_id" field.
  36075. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  36076. if m.addorganization_id != nil {
  36077. *m.addorganization_id += u
  36078. } else {
  36079. m.addorganization_id = &u
  36080. }
  36081. }
  36082. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36083. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  36084. v := m.addorganization_id
  36085. if v == nil {
  36086. return
  36087. }
  36088. return *v, true
  36089. }
  36090. // ClearOrganizationID clears the value of the "organization_id" field.
  36091. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  36092. m.organization_id = nil
  36093. m.addorganization_id = nil
  36094. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  36095. }
  36096. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36097. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  36098. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  36099. return ok
  36100. }
  36101. // ResetOrganizationID resets all changes to the "organization_id" field.
  36102. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  36103. m.organization_id = nil
  36104. m.addorganization_id = nil
  36105. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  36106. }
  36107. // SetAiResponse sets the "ai_response" field.
  36108. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  36109. m.ai_response = &u
  36110. m.addai_response = nil
  36111. }
  36112. // AiResponse returns the value of the "ai_response" field in the mutation.
  36113. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  36114. v := m.ai_response
  36115. if v == nil {
  36116. return
  36117. }
  36118. return *v, true
  36119. }
  36120. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  36121. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36123. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36124. if !m.op.Is(OpUpdateOne) {
  36125. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36126. }
  36127. if m.id == nil || m.oldValue == nil {
  36128. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36129. }
  36130. oldValue, err := m.oldValue(ctx)
  36131. if err != nil {
  36132. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36133. }
  36134. return oldValue.AiResponse, nil
  36135. }
  36136. // AddAiResponse adds u to the "ai_response" field.
  36137. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  36138. if m.addai_response != nil {
  36139. *m.addai_response += u
  36140. } else {
  36141. m.addai_response = &u
  36142. }
  36143. }
  36144. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36145. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  36146. v := m.addai_response
  36147. if v == nil {
  36148. return
  36149. }
  36150. return *v, true
  36151. }
  36152. // ResetAiResponse resets all changes to the "ai_response" field.
  36153. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  36154. m.ai_response = nil
  36155. m.addai_response = nil
  36156. }
  36157. // SetSopRun sets the "sop_run" field.
  36158. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  36159. m.sop_run = &u
  36160. m.addsop_run = nil
  36161. }
  36162. // SopRun returns the value of the "sop_run" field in the mutation.
  36163. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  36164. v := m.sop_run
  36165. if v == nil {
  36166. return
  36167. }
  36168. return *v, true
  36169. }
  36170. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  36171. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36173. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36174. if !m.op.Is(OpUpdateOne) {
  36175. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36176. }
  36177. if m.id == nil || m.oldValue == nil {
  36178. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36179. }
  36180. oldValue, err := m.oldValue(ctx)
  36181. if err != nil {
  36182. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36183. }
  36184. return oldValue.SopRun, nil
  36185. }
  36186. // AddSopRun adds u to the "sop_run" field.
  36187. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  36188. if m.addsop_run != nil {
  36189. *m.addsop_run += u
  36190. } else {
  36191. m.addsop_run = &u
  36192. }
  36193. }
  36194. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36195. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  36196. v := m.addsop_run
  36197. if v == nil {
  36198. return
  36199. }
  36200. return *v, true
  36201. }
  36202. // ResetSopRun resets all changes to the "sop_run" field.
  36203. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  36204. m.sop_run = nil
  36205. m.addsop_run = nil
  36206. }
  36207. // SetTotalFriend sets the "total_friend" field.
  36208. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  36209. m.total_friend = &u
  36210. m.addtotal_friend = nil
  36211. }
  36212. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36213. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  36214. v := m.total_friend
  36215. if v == nil {
  36216. return
  36217. }
  36218. return *v, true
  36219. }
  36220. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  36221. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36223. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36224. if !m.op.Is(OpUpdateOne) {
  36225. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36226. }
  36227. if m.id == nil || m.oldValue == nil {
  36228. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36229. }
  36230. oldValue, err := m.oldValue(ctx)
  36231. if err != nil {
  36232. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36233. }
  36234. return oldValue.TotalFriend, nil
  36235. }
  36236. // AddTotalFriend adds u to the "total_friend" field.
  36237. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  36238. if m.addtotal_friend != nil {
  36239. *m.addtotal_friend += u
  36240. } else {
  36241. m.addtotal_friend = &u
  36242. }
  36243. }
  36244. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36245. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  36246. v := m.addtotal_friend
  36247. if v == nil {
  36248. return
  36249. }
  36250. return *v, true
  36251. }
  36252. // ResetTotalFriend resets all changes to the "total_friend" field.
  36253. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  36254. m.total_friend = nil
  36255. m.addtotal_friend = nil
  36256. }
  36257. // SetTotalGroup sets the "total_group" field.
  36258. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  36259. m.total_group = &u
  36260. m.addtotal_group = nil
  36261. }
  36262. // TotalGroup returns the value of the "total_group" field in the mutation.
  36263. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  36264. v := m.total_group
  36265. if v == nil {
  36266. return
  36267. }
  36268. return *v, true
  36269. }
  36270. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  36271. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36273. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36274. if !m.op.Is(OpUpdateOne) {
  36275. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36276. }
  36277. if m.id == nil || m.oldValue == nil {
  36278. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36279. }
  36280. oldValue, err := m.oldValue(ctx)
  36281. if err != nil {
  36282. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36283. }
  36284. return oldValue.TotalGroup, nil
  36285. }
  36286. // AddTotalGroup adds u to the "total_group" field.
  36287. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  36288. if m.addtotal_group != nil {
  36289. *m.addtotal_group += u
  36290. } else {
  36291. m.addtotal_group = &u
  36292. }
  36293. }
  36294. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36295. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  36296. v := m.addtotal_group
  36297. if v == nil {
  36298. return
  36299. }
  36300. return *v, true
  36301. }
  36302. // ResetTotalGroup resets all changes to the "total_group" field.
  36303. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  36304. m.total_group = nil
  36305. m.addtotal_group = nil
  36306. }
  36307. // SetAccountBalance sets the "account_balance" field.
  36308. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  36309. m.account_balance = &u
  36310. m.addaccount_balance = nil
  36311. }
  36312. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36313. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  36314. v := m.account_balance
  36315. if v == nil {
  36316. return
  36317. }
  36318. return *v, true
  36319. }
  36320. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  36321. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36323. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36324. if !m.op.Is(OpUpdateOne) {
  36325. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36326. }
  36327. if m.id == nil || m.oldValue == nil {
  36328. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36329. }
  36330. oldValue, err := m.oldValue(ctx)
  36331. if err != nil {
  36332. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36333. }
  36334. return oldValue.AccountBalance, nil
  36335. }
  36336. // AddAccountBalance adds u to the "account_balance" field.
  36337. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  36338. if m.addaccount_balance != nil {
  36339. *m.addaccount_balance += u
  36340. } else {
  36341. m.addaccount_balance = &u
  36342. }
  36343. }
  36344. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36345. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  36346. v := m.addaccount_balance
  36347. if v == nil {
  36348. return
  36349. }
  36350. return *v, true
  36351. }
  36352. // ResetAccountBalance resets all changes to the "account_balance" field.
  36353. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  36354. m.account_balance = nil
  36355. m.addaccount_balance = nil
  36356. }
  36357. // SetConsumeToken sets the "consume_token" field.
  36358. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  36359. m.consume_token = &u
  36360. m.addconsume_token = nil
  36361. }
  36362. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36363. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  36364. v := m.consume_token
  36365. if v == nil {
  36366. return
  36367. }
  36368. return *v, true
  36369. }
  36370. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  36371. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36373. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36374. if !m.op.Is(OpUpdateOne) {
  36375. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36376. }
  36377. if m.id == nil || m.oldValue == nil {
  36378. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36379. }
  36380. oldValue, err := m.oldValue(ctx)
  36381. if err != nil {
  36382. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36383. }
  36384. return oldValue.ConsumeToken, nil
  36385. }
  36386. // AddConsumeToken adds u to the "consume_token" field.
  36387. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  36388. if m.addconsume_token != nil {
  36389. *m.addconsume_token += u
  36390. } else {
  36391. m.addconsume_token = &u
  36392. }
  36393. }
  36394. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36395. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  36396. v := m.addconsume_token
  36397. if v == nil {
  36398. return
  36399. }
  36400. return *v, true
  36401. }
  36402. // ResetConsumeToken resets all changes to the "consume_token" field.
  36403. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  36404. m.consume_token = nil
  36405. m.addconsume_token = nil
  36406. }
  36407. // SetActiveUser sets the "active_user" field.
  36408. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  36409. m.active_user = &u
  36410. m.addactive_user = nil
  36411. }
  36412. // ActiveUser returns the value of the "active_user" field in the mutation.
  36413. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  36414. v := m.active_user
  36415. if v == nil {
  36416. return
  36417. }
  36418. return *v, true
  36419. }
  36420. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  36421. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36423. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36424. if !m.op.Is(OpUpdateOne) {
  36425. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36426. }
  36427. if m.id == nil || m.oldValue == nil {
  36428. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36429. }
  36430. oldValue, err := m.oldValue(ctx)
  36431. if err != nil {
  36432. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36433. }
  36434. return oldValue.ActiveUser, nil
  36435. }
  36436. // AddActiveUser adds u to the "active_user" field.
  36437. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  36438. if m.addactive_user != nil {
  36439. *m.addactive_user += u
  36440. } else {
  36441. m.addactive_user = &u
  36442. }
  36443. }
  36444. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36445. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  36446. v := m.addactive_user
  36447. if v == nil {
  36448. return
  36449. }
  36450. return *v, true
  36451. }
  36452. // ResetActiveUser resets all changes to the "active_user" field.
  36453. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  36454. m.active_user = nil
  36455. m.addactive_user = nil
  36456. }
  36457. // SetNewUser sets the "new_user" field.
  36458. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  36459. m.new_user = &i
  36460. m.addnew_user = nil
  36461. }
  36462. // NewUser returns the value of the "new_user" field in the mutation.
  36463. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  36464. v := m.new_user
  36465. if v == nil {
  36466. return
  36467. }
  36468. return *v, true
  36469. }
  36470. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  36471. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36473. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36474. if !m.op.Is(OpUpdateOne) {
  36475. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36476. }
  36477. if m.id == nil || m.oldValue == nil {
  36478. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36479. }
  36480. oldValue, err := m.oldValue(ctx)
  36481. if err != nil {
  36482. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36483. }
  36484. return oldValue.NewUser, nil
  36485. }
  36486. // AddNewUser adds i to the "new_user" field.
  36487. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  36488. if m.addnew_user != nil {
  36489. *m.addnew_user += i
  36490. } else {
  36491. m.addnew_user = &i
  36492. }
  36493. }
  36494. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36495. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  36496. v := m.addnew_user
  36497. if v == nil {
  36498. return
  36499. }
  36500. return *v, true
  36501. }
  36502. // ResetNewUser resets all changes to the "new_user" field.
  36503. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  36504. m.new_user = nil
  36505. m.addnew_user = nil
  36506. }
  36507. // SetLabelDist sets the "label_dist" field.
  36508. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36509. m.label_dist = &ctd
  36510. m.appendlabel_dist = nil
  36511. }
  36512. // LabelDist returns the value of the "label_dist" field in the mutation.
  36513. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36514. v := m.label_dist
  36515. if v == nil {
  36516. return
  36517. }
  36518. return *v, true
  36519. }
  36520. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  36521. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  36522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36523. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36524. if !m.op.Is(OpUpdateOne) {
  36525. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36526. }
  36527. if m.id == nil || m.oldValue == nil {
  36528. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36529. }
  36530. oldValue, err := m.oldValue(ctx)
  36531. if err != nil {
  36532. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36533. }
  36534. return oldValue.LabelDist, nil
  36535. }
  36536. // AppendLabelDist adds ctd to the "label_dist" field.
  36537. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36538. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36539. }
  36540. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36541. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36542. if len(m.appendlabel_dist) == 0 {
  36543. return nil, false
  36544. }
  36545. return m.appendlabel_dist, true
  36546. }
  36547. // ResetLabelDist resets all changes to the "label_dist" field.
  36548. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  36549. m.label_dist = nil
  36550. m.appendlabel_dist = nil
  36551. }
  36552. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  36553. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  36554. m.predicates = append(m.predicates, ps...)
  36555. }
  36556. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  36557. // users can use type-assertion to append predicates that do not depend on any generated package.
  36558. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  36559. p := make([]predicate.UsageStatisticMonth, len(ps))
  36560. for i := range ps {
  36561. p[i] = ps[i]
  36562. }
  36563. m.Where(p...)
  36564. }
  36565. // Op returns the operation name.
  36566. func (m *UsageStatisticMonthMutation) Op() Op {
  36567. return m.op
  36568. }
  36569. // SetOp allows setting the mutation operation.
  36570. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  36571. m.op = op
  36572. }
  36573. // Type returns the node type of this mutation (UsageStatisticMonth).
  36574. func (m *UsageStatisticMonthMutation) Type() string {
  36575. return m.typ
  36576. }
  36577. // Fields returns all fields that were changed during this mutation. Note that in
  36578. // order to get all numeric fields that were incremented/decremented, call
  36579. // AddedFields().
  36580. func (m *UsageStatisticMonthMutation) Fields() []string {
  36581. fields := make([]string, 0, 17)
  36582. if m.created_at != nil {
  36583. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  36584. }
  36585. if m.updated_at != nil {
  36586. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  36587. }
  36588. if m.status != nil {
  36589. fields = append(fields, usagestatisticmonth.FieldStatus)
  36590. }
  36591. if m.deleted_at != nil {
  36592. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  36593. }
  36594. if m.addtime != nil {
  36595. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36596. }
  36597. if m._type != nil {
  36598. fields = append(fields, usagestatisticmonth.FieldType)
  36599. }
  36600. if m.bot_id != nil {
  36601. fields = append(fields, usagestatisticmonth.FieldBotID)
  36602. }
  36603. if m.organization_id != nil {
  36604. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36605. }
  36606. if m.ai_response != nil {
  36607. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36608. }
  36609. if m.sop_run != nil {
  36610. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36611. }
  36612. if m.total_friend != nil {
  36613. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36614. }
  36615. if m.total_group != nil {
  36616. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36617. }
  36618. if m.account_balance != nil {
  36619. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36620. }
  36621. if m.consume_token != nil {
  36622. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36623. }
  36624. if m.active_user != nil {
  36625. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36626. }
  36627. if m.new_user != nil {
  36628. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36629. }
  36630. if m.label_dist != nil {
  36631. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  36632. }
  36633. return fields
  36634. }
  36635. // Field returns the value of a field with the given name. The second boolean
  36636. // return value indicates that this field was not set, or was not defined in the
  36637. // schema.
  36638. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  36639. switch name {
  36640. case usagestatisticmonth.FieldCreatedAt:
  36641. return m.CreatedAt()
  36642. case usagestatisticmonth.FieldUpdatedAt:
  36643. return m.UpdatedAt()
  36644. case usagestatisticmonth.FieldStatus:
  36645. return m.Status()
  36646. case usagestatisticmonth.FieldDeletedAt:
  36647. return m.DeletedAt()
  36648. case usagestatisticmonth.FieldAddtime:
  36649. return m.Addtime()
  36650. case usagestatisticmonth.FieldType:
  36651. return m.GetType()
  36652. case usagestatisticmonth.FieldBotID:
  36653. return m.BotID()
  36654. case usagestatisticmonth.FieldOrganizationID:
  36655. return m.OrganizationID()
  36656. case usagestatisticmonth.FieldAiResponse:
  36657. return m.AiResponse()
  36658. case usagestatisticmonth.FieldSopRun:
  36659. return m.SopRun()
  36660. case usagestatisticmonth.FieldTotalFriend:
  36661. return m.TotalFriend()
  36662. case usagestatisticmonth.FieldTotalGroup:
  36663. return m.TotalGroup()
  36664. case usagestatisticmonth.FieldAccountBalance:
  36665. return m.AccountBalance()
  36666. case usagestatisticmonth.FieldConsumeToken:
  36667. return m.ConsumeToken()
  36668. case usagestatisticmonth.FieldActiveUser:
  36669. return m.ActiveUser()
  36670. case usagestatisticmonth.FieldNewUser:
  36671. return m.NewUser()
  36672. case usagestatisticmonth.FieldLabelDist:
  36673. return m.LabelDist()
  36674. }
  36675. return nil, false
  36676. }
  36677. // OldField returns the old value of the field from the database. An error is
  36678. // returned if the mutation operation is not UpdateOne, or the query to the
  36679. // database failed.
  36680. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36681. switch name {
  36682. case usagestatisticmonth.FieldCreatedAt:
  36683. return m.OldCreatedAt(ctx)
  36684. case usagestatisticmonth.FieldUpdatedAt:
  36685. return m.OldUpdatedAt(ctx)
  36686. case usagestatisticmonth.FieldStatus:
  36687. return m.OldStatus(ctx)
  36688. case usagestatisticmonth.FieldDeletedAt:
  36689. return m.OldDeletedAt(ctx)
  36690. case usagestatisticmonth.FieldAddtime:
  36691. return m.OldAddtime(ctx)
  36692. case usagestatisticmonth.FieldType:
  36693. return m.OldType(ctx)
  36694. case usagestatisticmonth.FieldBotID:
  36695. return m.OldBotID(ctx)
  36696. case usagestatisticmonth.FieldOrganizationID:
  36697. return m.OldOrganizationID(ctx)
  36698. case usagestatisticmonth.FieldAiResponse:
  36699. return m.OldAiResponse(ctx)
  36700. case usagestatisticmonth.FieldSopRun:
  36701. return m.OldSopRun(ctx)
  36702. case usagestatisticmonth.FieldTotalFriend:
  36703. return m.OldTotalFriend(ctx)
  36704. case usagestatisticmonth.FieldTotalGroup:
  36705. return m.OldTotalGroup(ctx)
  36706. case usagestatisticmonth.FieldAccountBalance:
  36707. return m.OldAccountBalance(ctx)
  36708. case usagestatisticmonth.FieldConsumeToken:
  36709. return m.OldConsumeToken(ctx)
  36710. case usagestatisticmonth.FieldActiveUser:
  36711. return m.OldActiveUser(ctx)
  36712. case usagestatisticmonth.FieldNewUser:
  36713. return m.OldNewUser(ctx)
  36714. case usagestatisticmonth.FieldLabelDist:
  36715. return m.OldLabelDist(ctx)
  36716. }
  36717. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36718. }
  36719. // SetField sets the value of a field with the given name. It returns an error if
  36720. // the field is not defined in the schema, or if the type mismatched the field
  36721. // type.
  36722. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  36723. switch name {
  36724. case usagestatisticmonth.FieldCreatedAt:
  36725. v, ok := value.(time.Time)
  36726. if !ok {
  36727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36728. }
  36729. m.SetCreatedAt(v)
  36730. return nil
  36731. case usagestatisticmonth.FieldUpdatedAt:
  36732. v, ok := value.(time.Time)
  36733. if !ok {
  36734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36735. }
  36736. m.SetUpdatedAt(v)
  36737. return nil
  36738. case usagestatisticmonth.FieldStatus:
  36739. v, ok := value.(uint8)
  36740. if !ok {
  36741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36742. }
  36743. m.SetStatus(v)
  36744. return nil
  36745. case usagestatisticmonth.FieldDeletedAt:
  36746. v, ok := value.(time.Time)
  36747. if !ok {
  36748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36749. }
  36750. m.SetDeletedAt(v)
  36751. return nil
  36752. case usagestatisticmonth.FieldAddtime:
  36753. v, ok := value.(uint64)
  36754. if !ok {
  36755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36756. }
  36757. m.SetAddtime(v)
  36758. return nil
  36759. case usagestatisticmonth.FieldType:
  36760. v, ok := value.(int)
  36761. if !ok {
  36762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36763. }
  36764. m.SetType(v)
  36765. return nil
  36766. case usagestatisticmonth.FieldBotID:
  36767. v, ok := value.(string)
  36768. if !ok {
  36769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36770. }
  36771. m.SetBotID(v)
  36772. return nil
  36773. case usagestatisticmonth.FieldOrganizationID:
  36774. v, ok := value.(uint64)
  36775. if !ok {
  36776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36777. }
  36778. m.SetOrganizationID(v)
  36779. return nil
  36780. case usagestatisticmonth.FieldAiResponse:
  36781. v, ok := value.(uint64)
  36782. if !ok {
  36783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36784. }
  36785. m.SetAiResponse(v)
  36786. return nil
  36787. case usagestatisticmonth.FieldSopRun:
  36788. v, ok := value.(uint64)
  36789. if !ok {
  36790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36791. }
  36792. m.SetSopRun(v)
  36793. return nil
  36794. case usagestatisticmonth.FieldTotalFriend:
  36795. v, ok := value.(uint64)
  36796. if !ok {
  36797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36798. }
  36799. m.SetTotalFriend(v)
  36800. return nil
  36801. case usagestatisticmonth.FieldTotalGroup:
  36802. v, ok := value.(uint64)
  36803. if !ok {
  36804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36805. }
  36806. m.SetTotalGroup(v)
  36807. return nil
  36808. case usagestatisticmonth.FieldAccountBalance:
  36809. v, ok := value.(uint64)
  36810. if !ok {
  36811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36812. }
  36813. m.SetAccountBalance(v)
  36814. return nil
  36815. case usagestatisticmonth.FieldConsumeToken:
  36816. v, ok := value.(uint64)
  36817. if !ok {
  36818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36819. }
  36820. m.SetConsumeToken(v)
  36821. return nil
  36822. case usagestatisticmonth.FieldActiveUser:
  36823. v, ok := value.(uint64)
  36824. if !ok {
  36825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36826. }
  36827. m.SetActiveUser(v)
  36828. return nil
  36829. case usagestatisticmonth.FieldNewUser:
  36830. v, ok := value.(int64)
  36831. if !ok {
  36832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36833. }
  36834. m.SetNewUser(v)
  36835. return nil
  36836. case usagestatisticmonth.FieldLabelDist:
  36837. v, ok := value.([]custom_types.LabelDist)
  36838. if !ok {
  36839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36840. }
  36841. m.SetLabelDist(v)
  36842. return nil
  36843. }
  36844. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36845. }
  36846. // AddedFields returns all numeric fields that were incremented/decremented during
  36847. // this mutation.
  36848. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  36849. var fields []string
  36850. if m.addstatus != nil {
  36851. fields = append(fields, usagestatisticmonth.FieldStatus)
  36852. }
  36853. if m.addaddtime != nil {
  36854. fields = append(fields, usagestatisticmonth.FieldAddtime)
  36855. }
  36856. if m.add_type != nil {
  36857. fields = append(fields, usagestatisticmonth.FieldType)
  36858. }
  36859. if m.addorganization_id != nil {
  36860. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  36861. }
  36862. if m.addai_response != nil {
  36863. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  36864. }
  36865. if m.addsop_run != nil {
  36866. fields = append(fields, usagestatisticmonth.FieldSopRun)
  36867. }
  36868. if m.addtotal_friend != nil {
  36869. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  36870. }
  36871. if m.addtotal_group != nil {
  36872. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  36873. }
  36874. if m.addaccount_balance != nil {
  36875. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  36876. }
  36877. if m.addconsume_token != nil {
  36878. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  36879. }
  36880. if m.addactive_user != nil {
  36881. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  36882. }
  36883. if m.addnew_user != nil {
  36884. fields = append(fields, usagestatisticmonth.FieldNewUser)
  36885. }
  36886. return fields
  36887. }
  36888. // AddedField returns the numeric value that was incremented/decremented on a field
  36889. // with the given name. The second boolean return value indicates that this field
  36890. // was not set, or was not defined in the schema.
  36891. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  36892. switch name {
  36893. case usagestatisticmonth.FieldStatus:
  36894. return m.AddedStatus()
  36895. case usagestatisticmonth.FieldAddtime:
  36896. return m.AddedAddtime()
  36897. case usagestatisticmonth.FieldType:
  36898. return m.AddedType()
  36899. case usagestatisticmonth.FieldOrganizationID:
  36900. return m.AddedOrganizationID()
  36901. case usagestatisticmonth.FieldAiResponse:
  36902. return m.AddedAiResponse()
  36903. case usagestatisticmonth.FieldSopRun:
  36904. return m.AddedSopRun()
  36905. case usagestatisticmonth.FieldTotalFriend:
  36906. return m.AddedTotalFriend()
  36907. case usagestatisticmonth.FieldTotalGroup:
  36908. return m.AddedTotalGroup()
  36909. case usagestatisticmonth.FieldAccountBalance:
  36910. return m.AddedAccountBalance()
  36911. case usagestatisticmonth.FieldConsumeToken:
  36912. return m.AddedConsumeToken()
  36913. case usagestatisticmonth.FieldActiveUser:
  36914. return m.AddedActiveUser()
  36915. case usagestatisticmonth.FieldNewUser:
  36916. return m.AddedNewUser()
  36917. }
  36918. return nil, false
  36919. }
  36920. // AddField adds the value to the field with the given name. It returns an error if
  36921. // the field is not defined in the schema, or if the type mismatched the field
  36922. // type.
  36923. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  36924. switch name {
  36925. case usagestatisticmonth.FieldStatus:
  36926. v, ok := value.(int8)
  36927. if !ok {
  36928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36929. }
  36930. m.AddStatus(v)
  36931. return nil
  36932. case usagestatisticmonth.FieldAddtime:
  36933. v, ok := value.(int64)
  36934. if !ok {
  36935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36936. }
  36937. m.AddAddtime(v)
  36938. return nil
  36939. case usagestatisticmonth.FieldType:
  36940. v, ok := value.(int)
  36941. if !ok {
  36942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36943. }
  36944. m.AddType(v)
  36945. return nil
  36946. case usagestatisticmonth.FieldOrganizationID:
  36947. v, ok := value.(int64)
  36948. if !ok {
  36949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36950. }
  36951. m.AddOrganizationID(v)
  36952. return nil
  36953. case usagestatisticmonth.FieldAiResponse:
  36954. v, ok := value.(int64)
  36955. if !ok {
  36956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36957. }
  36958. m.AddAiResponse(v)
  36959. return nil
  36960. case usagestatisticmonth.FieldSopRun:
  36961. v, ok := value.(int64)
  36962. if !ok {
  36963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36964. }
  36965. m.AddSopRun(v)
  36966. return nil
  36967. case usagestatisticmonth.FieldTotalFriend:
  36968. v, ok := value.(int64)
  36969. if !ok {
  36970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36971. }
  36972. m.AddTotalFriend(v)
  36973. return nil
  36974. case usagestatisticmonth.FieldTotalGroup:
  36975. v, ok := value.(int64)
  36976. if !ok {
  36977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36978. }
  36979. m.AddTotalGroup(v)
  36980. return nil
  36981. case usagestatisticmonth.FieldAccountBalance:
  36982. v, ok := value.(int64)
  36983. if !ok {
  36984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36985. }
  36986. m.AddAccountBalance(v)
  36987. return nil
  36988. case usagestatisticmonth.FieldConsumeToken:
  36989. v, ok := value.(int64)
  36990. if !ok {
  36991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36992. }
  36993. m.AddConsumeToken(v)
  36994. return nil
  36995. case usagestatisticmonth.FieldActiveUser:
  36996. v, ok := value.(int64)
  36997. if !ok {
  36998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36999. }
  37000. m.AddActiveUser(v)
  37001. return nil
  37002. case usagestatisticmonth.FieldNewUser:
  37003. v, ok := value.(int64)
  37004. if !ok {
  37005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37006. }
  37007. m.AddNewUser(v)
  37008. return nil
  37009. }
  37010. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  37011. }
  37012. // ClearedFields returns all nullable fields that were cleared during this
  37013. // mutation.
  37014. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  37015. var fields []string
  37016. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  37017. fields = append(fields, usagestatisticmonth.FieldStatus)
  37018. }
  37019. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  37020. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  37021. }
  37022. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  37023. fields = append(fields, usagestatisticmonth.FieldBotID)
  37024. }
  37025. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  37026. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37027. }
  37028. return fields
  37029. }
  37030. // FieldCleared returns a boolean indicating if a field with the given name was
  37031. // cleared in this mutation.
  37032. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  37033. _, ok := m.clearedFields[name]
  37034. return ok
  37035. }
  37036. // ClearField clears the value of the field with the given name. It returns an
  37037. // error if the field is not defined in the schema.
  37038. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  37039. switch name {
  37040. case usagestatisticmonth.FieldStatus:
  37041. m.ClearStatus()
  37042. return nil
  37043. case usagestatisticmonth.FieldDeletedAt:
  37044. m.ClearDeletedAt()
  37045. return nil
  37046. case usagestatisticmonth.FieldBotID:
  37047. m.ClearBotID()
  37048. return nil
  37049. case usagestatisticmonth.FieldOrganizationID:
  37050. m.ClearOrganizationID()
  37051. return nil
  37052. }
  37053. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  37054. }
  37055. // ResetField resets all changes in the mutation for the field with the given name.
  37056. // It returns an error if the field is not defined in the schema.
  37057. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  37058. switch name {
  37059. case usagestatisticmonth.FieldCreatedAt:
  37060. m.ResetCreatedAt()
  37061. return nil
  37062. case usagestatisticmonth.FieldUpdatedAt:
  37063. m.ResetUpdatedAt()
  37064. return nil
  37065. case usagestatisticmonth.FieldStatus:
  37066. m.ResetStatus()
  37067. return nil
  37068. case usagestatisticmonth.FieldDeletedAt:
  37069. m.ResetDeletedAt()
  37070. return nil
  37071. case usagestatisticmonth.FieldAddtime:
  37072. m.ResetAddtime()
  37073. return nil
  37074. case usagestatisticmonth.FieldType:
  37075. m.ResetType()
  37076. return nil
  37077. case usagestatisticmonth.FieldBotID:
  37078. m.ResetBotID()
  37079. return nil
  37080. case usagestatisticmonth.FieldOrganizationID:
  37081. m.ResetOrganizationID()
  37082. return nil
  37083. case usagestatisticmonth.FieldAiResponse:
  37084. m.ResetAiResponse()
  37085. return nil
  37086. case usagestatisticmonth.FieldSopRun:
  37087. m.ResetSopRun()
  37088. return nil
  37089. case usagestatisticmonth.FieldTotalFriend:
  37090. m.ResetTotalFriend()
  37091. return nil
  37092. case usagestatisticmonth.FieldTotalGroup:
  37093. m.ResetTotalGroup()
  37094. return nil
  37095. case usagestatisticmonth.FieldAccountBalance:
  37096. m.ResetAccountBalance()
  37097. return nil
  37098. case usagestatisticmonth.FieldConsumeToken:
  37099. m.ResetConsumeToken()
  37100. return nil
  37101. case usagestatisticmonth.FieldActiveUser:
  37102. m.ResetActiveUser()
  37103. return nil
  37104. case usagestatisticmonth.FieldNewUser:
  37105. m.ResetNewUser()
  37106. return nil
  37107. case usagestatisticmonth.FieldLabelDist:
  37108. m.ResetLabelDist()
  37109. return nil
  37110. }
  37111. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  37112. }
  37113. // AddedEdges returns all edge names that were set/added in this mutation.
  37114. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  37115. edges := make([]string, 0, 0)
  37116. return edges
  37117. }
  37118. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37119. // name in this mutation.
  37120. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  37121. return nil
  37122. }
  37123. // RemovedEdges returns all edge names that were removed in this mutation.
  37124. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  37125. edges := make([]string, 0, 0)
  37126. return edges
  37127. }
  37128. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37129. // the given name in this mutation.
  37130. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  37131. return nil
  37132. }
  37133. // ClearedEdges returns all edge names that were cleared in this mutation.
  37134. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  37135. edges := make([]string, 0, 0)
  37136. return edges
  37137. }
  37138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37139. // was cleared in this mutation.
  37140. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  37141. return false
  37142. }
  37143. // ClearEdge clears the value of the edge with the given name. It returns an error
  37144. // if that edge is not defined in the schema.
  37145. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  37146. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  37147. }
  37148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37149. // It returns an error if the edge is not defined in the schema.
  37150. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  37151. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  37152. }
  37153. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  37154. type UsageTotalMutation struct {
  37155. config
  37156. op Op
  37157. typ string
  37158. id *uint64
  37159. created_at *time.Time
  37160. updated_at *time.Time
  37161. status *uint8
  37162. addstatus *int8
  37163. _type *int
  37164. add_type *int
  37165. bot_id *string
  37166. total_tokens *uint64
  37167. addtotal_tokens *int64
  37168. start_index *uint64
  37169. addstart_index *int64
  37170. end_index *uint64
  37171. addend_index *int64
  37172. organization_id *uint64
  37173. addorganization_id *int64
  37174. clearedFields map[string]struct{}
  37175. done bool
  37176. oldValue func(context.Context) (*UsageTotal, error)
  37177. predicates []predicate.UsageTotal
  37178. }
  37179. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  37180. // usagetotalOption allows management of the mutation configuration using functional options.
  37181. type usagetotalOption func(*UsageTotalMutation)
  37182. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  37183. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  37184. m := &UsageTotalMutation{
  37185. config: c,
  37186. op: op,
  37187. typ: TypeUsageTotal,
  37188. clearedFields: make(map[string]struct{}),
  37189. }
  37190. for _, opt := range opts {
  37191. opt(m)
  37192. }
  37193. return m
  37194. }
  37195. // withUsageTotalID sets the ID field of the mutation.
  37196. func withUsageTotalID(id uint64) usagetotalOption {
  37197. return func(m *UsageTotalMutation) {
  37198. var (
  37199. err error
  37200. once sync.Once
  37201. value *UsageTotal
  37202. )
  37203. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  37204. once.Do(func() {
  37205. if m.done {
  37206. err = errors.New("querying old values post mutation is not allowed")
  37207. } else {
  37208. value, err = m.Client().UsageTotal.Get(ctx, id)
  37209. }
  37210. })
  37211. return value, err
  37212. }
  37213. m.id = &id
  37214. }
  37215. }
  37216. // withUsageTotal sets the old UsageTotal of the mutation.
  37217. func withUsageTotal(node *UsageTotal) usagetotalOption {
  37218. return func(m *UsageTotalMutation) {
  37219. m.oldValue = func(context.Context) (*UsageTotal, error) {
  37220. return node, nil
  37221. }
  37222. m.id = &node.ID
  37223. }
  37224. }
  37225. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37226. // executed in a transaction (ent.Tx), a transactional client is returned.
  37227. func (m UsageTotalMutation) Client() *Client {
  37228. client := &Client{config: m.config}
  37229. client.init()
  37230. return client
  37231. }
  37232. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37233. // it returns an error otherwise.
  37234. func (m UsageTotalMutation) Tx() (*Tx, error) {
  37235. if _, ok := m.driver.(*txDriver); !ok {
  37236. return nil, errors.New("ent: mutation is not running in a transaction")
  37237. }
  37238. tx := &Tx{config: m.config}
  37239. tx.init()
  37240. return tx, nil
  37241. }
  37242. // SetID sets the value of the id field. Note that this
  37243. // operation is only accepted on creation of UsageTotal entities.
  37244. func (m *UsageTotalMutation) SetID(id uint64) {
  37245. m.id = &id
  37246. }
  37247. // ID returns the ID value in the mutation. Note that the ID is only available
  37248. // if it was provided to the builder or after it was returned from the database.
  37249. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  37250. if m.id == nil {
  37251. return
  37252. }
  37253. return *m.id, true
  37254. }
  37255. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37256. // That means, if the mutation is applied within a transaction with an isolation level such
  37257. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37258. // or updated by the mutation.
  37259. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  37260. switch {
  37261. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37262. id, exists := m.ID()
  37263. if exists {
  37264. return []uint64{id}, nil
  37265. }
  37266. fallthrough
  37267. case m.op.Is(OpUpdate | OpDelete):
  37268. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  37269. default:
  37270. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37271. }
  37272. }
  37273. // SetCreatedAt sets the "created_at" field.
  37274. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  37275. m.created_at = &t
  37276. }
  37277. // CreatedAt returns the value of the "created_at" field in the mutation.
  37278. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  37279. v := m.created_at
  37280. if v == nil {
  37281. return
  37282. }
  37283. return *v, true
  37284. }
  37285. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  37286. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37288. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37289. if !m.op.Is(OpUpdateOne) {
  37290. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37291. }
  37292. if m.id == nil || m.oldValue == nil {
  37293. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37294. }
  37295. oldValue, err := m.oldValue(ctx)
  37296. if err != nil {
  37297. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37298. }
  37299. return oldValue.CreatedAt, nil
  37300. }
  37301. // ResetCreatedAt resets all changes to the "created_at" field.
  37302. func (m *UsageTotalMutation) ResetCreatedAt() {
  37303. m.created_at = nil
  37304. }
  37305. // SetUpdatedAt sets the "updated_at" field.
  37306. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  37307. m.updated_at = &t
  37308. }
  37309. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37310. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  37311. v := m.updated_at
  37312. if v == nil {
  37313. return
  37314. }
  37315. return *v, true
  37316. }
  37317. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  37318. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37320. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37321. if !m.op.Is(OpUpdateOne) {
  37322. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37323. }
  37324. if m.id == nil || m.oldValue == nil {
  37325. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37326. }
  37327. oldValue, err := m.oldValue(ctx)
  37328. if err != nil {
  37329. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37330. }
  37331. return oldValue.UpdatedAt, nil
  37332. }
  37333. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37334. func (m *UsageTotalMutation) ResetUpdatedAt() {
  37335. m.updated_at = nil
  37336. }
  37337. // SetStatus sets the "status" field.
  37338. func (m *UsageTotalMutation) SetStatus(u uint8) {
  37339. m.status = &u
  37340. m.addstatus = nil
  37341. }
  37342. // Status returns the value of the "status" field in the mutation.
  37343. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  37344. v := m.status
  37345. if v == nil {
  37346. return
  37347. }
  37348. return *v, true
  37349. }
  37350. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  37351. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37353. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37354. if !m.op.Is(OpUpdateOne) {
  37355. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37356. }
  37357. if m.id == nil || m.oldValue == nil {
  37358. return v, errors.New("OldStatus requires an ID field in the mutation")
  37359. }
  37360. oldValue, err := m.oldValue(ctx)
  37361. if err != nil {
  37362. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37363. }
  37364. return oldValue.Status, nil
  37365. }
  37366. // AddStatus adds u to the "status" field.
  37367. func (m *UsageTotalMutation) AddStatus(u int8) {
  37368. if m.addstatus != nil {
  37369. *m.addstatus += u
  37370. } else {
  37371. m.addstatus = &u
  37372. }
  37373. }
  37374. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37375. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  37376. v := m.addstatus
  37377. if v == nil {
  37378. return
  37379. }
  37380. return *v, true
  37381. }
  37382. // ClearStatus clears the value of the "status" field.
  37383. func (m *UsageTotalMutation) ClearStatus() {
  37384. m.status = nil
  37385. m.addstatus = nil
  37386. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  37387. }
  37388. // StatusCleared returns if the "status" field was cleared in this mutation.
  37389. func (m *UsageTotalMutation) StatusCleared() bool {
  37390. _, ok := m.clearedFields[usagetotal.FieldStatus]
  37391. return ok
  37392. }
  37393. // ResetStatus resets all changes to the "status" field.
  37394. func (m *UsageTotalMutation) ResetStatus() {
  37395. m.status = nil
  37396. m.addstatus = nil
  37397. delete(m.clearedFields, usagetotal.FieldStatus)
  37398. }
  37399. // SetType sets the "type" field.
  37400. func (m *UsageTotalMutation) SetType(i int) {
  37401. m._type = &i
  37402. m.add_type = nil
  37403. }
  37404. // GetType returns the value of the "type" field in the mutation.
  37405. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  37406. v := m._type
  37407. if v == nil {
  37408. return
  37409. }
  37410. return *v, true
  37411. }
  37412. // OldType returns the old "type" field's value of the UsageTotal entity.
  37413. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37415. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  37416. if !m.op.Is(OpUpdateOne) {
  37417. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37418. }
  37419. if m.id == nil || m.oldValue == nil {
  37420. return v, errors.New("OldType requires an ID field in the mutation")
  37421. }
  37422. oldValue, err := m.oldValue(ctx)
  37423. if err != nil {
  37424. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37425. }
  37426. return oldValue.Type, nil
  37427. }
  37428. // AddType adds i to the "type" field.
  37429. func (m *UsageTotalMutation) AddType(i int) {
  37430. if m.add_type != nil {
  37431. *m.add_type += i
  37432. } else {
  37433. m.add_type = &i
  37434. }
  37435. }
  37436. // AddedType returns the value that was added to the "type" field in this mutation.
  37437. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  37438. v := m.add_type
  37439. if v == nil {
  37440. return
  37441. }
  37442. return *v, true
  37443. }
  37444. // ClearType clears the value of the "type" field.
  37445. func (m *UsageTotalMutation) ClearType() {
  37446. m._type = nil
  37447. m.add_type = nil
  37448. m.clearedFields[usagetotal.FieldType] = struct{}{}
  37449. }
  37450. // TypeCleared returns if the "type" field was cleared in this mutation.
  37451. func (m *UsageTotalMutation) TypeCleared() bool {
  37452. _, ok := m.clearedFields[usagetotal.FieldType]
  37453. return ok
  37454. }
  37455. // ResetType resets all changes to the "type" field.
  37456. func (m *UsageTotalMutation) ResetType() {
  37457. m._type = nil
  37458. m.add_type = nil
  37459. delete(m.clearedFields, usagetotal.FieldType)
  37460. }
  37461. // SetBotID sets the "bot_id" field.
  37462. func (m *UsageTotalMutation) SetBotID(s string) {
  37463. m.bot_id = &s
  37464. }
  37465. // BotID returns the value of the "bot_id" field in the mutation.
  37466. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  37467. v := m.bot_id
  37468. if v == nil {
  37469. return
  37470. }
  37471. return *v, true
  37472. }
  37473. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  37474. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37476. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  37477. if !m.op.Is(OpUpdateOne) {
  37478. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37479. }
  37480. if m.id == nil || m.oldValue == nil {
  37481. return v, errors.New("OldBotID requires an ID field in the mutation")
  37482. }
  37483. oldValue, err := m.oldValue(ctx)
  37484. if err != nil {
  37485. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37486. }
  37487. return oldValue.BotID, nil
  37488. }
  37489. // ResetBotID resets all changes to the "bot_id" field.
  37490. func (m *UsageTotalMutation) ResetBotID() {
  37491. m.bot_id = nil
  37492. }
  37493. // SetTotalTokens sets the "total_tokens" field.
  37494. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  37495. m.total_tokens = &u
  37496. m.addtotal_tokens = nil
  37497. }
  37498. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  37499. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  37500. v := m.total_tokens
  37501. if v == nil {
  37502. return
  37503. }
  37504. return *v, true
  37505. }
  37506. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  37507. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37509. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  37510. if !m.op.Is(OpUpdateOne) {
  37511. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  37512. }
  37513. if m.id == nil || m.oldValue == nil {
  37514. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  37515. }
  37516. oldValue, err := m.oldValue(ctx)
  37517. if err != nil {
  37518. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  37519. }
  37520. return oldValue.TotalTokens, nil
  37521. }
  37522. // AddTotalTokens adds u to the "total_tokens" field.
  37523. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  37524. if m.addtotal_tokens != nil {
  37525. *m.addtotal_tokens += u
  37526. } else {
  37527. m.addtotal_tokens = &u
  37528. }
  37529. }
  37530. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  37531. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  37532. v := m.addtotal_tokens
  37533. if v == nil {
  37534. return
  37535. }
  37536. return *v, true
  37537. }
  37538. // ClearTotalTokens clears the value of the "total_tokens" field.
  37539. func (m *UsageTotalMutation) ClearTotalTokens() {
  37540. m.total_tokens = nil
  37541. m.addtotal_tokens = nil
  37542. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  37543. }
  37544. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  37545. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  37546. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  37547. return ok
  37548. }
  37549. // ResetTotalTokens resets all changes to the "total_tokens" field.
  37550. func (m *UsageTotalMutation) ResetTotalTokens() {
  37551. m.total_tokens = nil
  37552. m.addtotal_tokens = nil
  37553. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  37554. }
  37555. // SetStartIndex sets the "start_index" field.
  37556. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  37557. m.start_index = &u
  37558. m.addstart_index = nil
  37559. }
  37560. // StartIndex returns the value of the "start_index" field in the mutation.
  37561. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  37562. v := m.start_index
  37563. if v == nil {
  37564. return
  37565. }
  37566. return *v, true
  37567. }
  37568. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  37569. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37571. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  37572. if !m.op.Is(OpUpdateOne) {
  37573. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  37574. }
  37575. if m.id == nil || m.oldValue == nil {
  37576. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  37577. }
  37578. oldValue, err := m.oldValue(ctx)
  37579. if err != nil {
  37580. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  37581. }
  37582. return oldValue.StartIndex, nil
  37583. }
  37584. // AddStartIndex adds u to the "start_index" field.
  37585. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  37586. if m.addstart_index != nil {
  37587. *m.addstart_index += u
  37588. } else {
  37589. m.addstart_index = &u
  37590. }
  37591. }
  37592. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  37593. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  37594. v := m.addstart_index
  37595. if v == nil {
  37596. return
  37597. }
  37598. return *v, true
  37599. }
  37600. // ClearStartIndex clears the value of the "start_index" field.
  37601. func (m *UsageTotalMutation) ClearStartIndex() {
  37602. m.start_index = nil
  37603. m.addstart_index = nil
  37604. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  37605. }
  37606. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  37607. func (m *UsageTotalMutation) StartIndexCleared() bool {
  37608. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  37609. return ok
  37610. }
  37611. // ResetStartIndex resets all changes to the "start_index" field.
  37612. func (m *UsageTotalMutation) ResetStartIndex() {
  37613. m.start_index = nil
  37614. m.addstart_index = nil
  37615. delete(m.clearedFields, usagetotal.FieldStartIndex)
  37616. }
  37617. // SetEndIndex sets the "end_index" field.
  37618. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  37619. m.end_index = &u
  37620. m.addend_index = nil
  37621. }
  37622. // EndIndex returns the value of the "end_index" field in the mutation.
  37623. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  37624. v := m.end_index
  37625. if v == nil {
  37626. return
  37627. }
  37628. return *v, true
  37629. }
  37630. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  37631. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37633. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  37634. if !m.op.Is(OpUpdateOne) {
  37635. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  37636. }
  37637. if m.id == nil || m.oldValue == nil {
  37638. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  37639. }
  37640. oldValue, err := m.oldValue(ctx)
  37641. if err != nil {
  37642. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  37643. }
  37644. return oldValue.EndIndex, nil
  37645. }
  37646. // AddEndIndex adds u to the "end_index" field.
  37647. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  37648. if m.addend_index != nil {
  37649. *m.addend_index += u
  37650. } else {
  37651. m.addend_index = &u
  37652. }
  37653. }
  37654. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  37655. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  37656. v := m.addend_index
  37657. if v == nil {
  37658. return
  37659. }
  37660. return *v, true
  37661. }
  37662. // ClearEndIndex clears the value of the "end_index" field.
  37663. func (m *UsageTotalMutation) ClearEndIndex() {
  37664. m.end_index = nil
  37665. m.addend_index = nil
  37666. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  37667. }
  37668. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  37669. func (m *UsageTotalMutation) EndIndexCleared() bool {
  37670. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  37671. return ok
  37672. }
  37673. // ResetEndIndex resets all changes to the "end_index" field.
  37674. func (m *UsageTotalMutation) ResetEndIndex() {
  37675. m.end_index = nil
  37676. m.addend_index = nil
  37677. delete(m.clearedFields, usagetotal.FieldEndIndex)
  37678. }
  37679. // SetOrganizationID sets the "organization_id" field.
  37680. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  37681. m.organization_id = &u
  37682. m.addorganization_id = nil
  37683. }
  37684. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37685. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  37686. v := m.organization_id
  37687. if v == nil {
  37688. return
  37689. }
  37690. return *v, true
  37691. }
  37692. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  37693. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  37694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37695. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37696. if !m.op.Is(OpUpdateOne) {
  37697. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37698. }
  37699. if m.id == nil || m.oldValue == nil {
  37700. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37701. }
  37702. oldValue, err := m.oldValue(ctx)
  37703. if err != nil {
  37704. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37705. }
  37706. return oldValue.OrganizationID, nil
  37707. }
  37708. // AddOrganizationID adds u to the "organization_id" field.
  37709. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  37710. if m.addorganization_id != nil {
  37711. *m.addorganization_id += u
  37712. } else {
  37713. m.addorganization_id = &u
  37714. }
  37715. }
  37716. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37717. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  37718. v := m.addorganization_id
  37719. if v == nil {
  37720. return
  37721. }
  37722. return *v, true
  37723. }
  37724. // ClearOrganizationID clears the value of the "organization_id" field.
  37725. func (m *UsageTotalMutation) ClearOrganizationID() {
  37726. m.organization_id = nil
  37727. m.addorganization_id = nil
  37728. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  37729. }
  37730. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37731. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  37732. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  37733. return ok
  37734. }
  37735. // ResetOrganizationID resets all changes to the "organization_id" field.
  37736. func (m *UsageTotalMutation) ResetOrganizationID() {
  37737. m.organization_id = nil
  37738. m.addorganization_id = nil
  37739. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  37740. }
  37741. // Where appends a list predicates to the UsageTotalMutation builder.
  37742. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  37743. m.predicates = append(m.predicates, ps...)
  37744. }
  37745. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  37746. // users can use type-assertion to append predicates that do not depend on any generated package.
  37747. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  37748. p := make([]predicate.UsageTotal, len(ps))
  37749. for i := range ps {
  37750. p[i] = ps[i]
  37751. }
  37752. m.Where(p...)
  37753. }
  37754. // Op returns the operation name.
  37755. func (m *UsageTotalMutation) Op() Op {
  37756. return m.op
  37757. }
  37758. // SetOp allows setting the mutation operation.
  37759. func (m *UsageTotalMutation) SetOp(op Op) {
  37760. m.op = op
  37761. }
  37762. // Type returns the node type of this mutation (UsageTotal).
  37763. func (m *UsageTotalMutation) Type() string {
  37764. return m.typ
  37765. }
  37766. // Fields returns all fields that were changed during this mutation. Note that in
  37767. // order to get all numeric fields that were incremented/decremented, call
  37768. // AddedFields().
  37769. func (m *UsageTotalMutation) Fields() []string {
  37770. fields := make([]string, 0, 9)
  37771. if m.created_at != nil {
  37772. fields = append(fields, usagetotal.FieldCreatedAt)
  37773. }
  37774. if m.updated_at != nil {
  37775. fields = append(fields, usagetotal.FieldUpdatedAt)
  37776. }
  37777. if m.status != nil {
  37778. fields = append(fields, usagetotal.FieldStatus)
  37779. }
  37780. if m._type != nil {
  37781. fields = append(fields, usagetotal.FieldType)
  37782. }
  37783. if m.bot_id != nil {
  37784. fields = append(fields, usagetotal.FieldBotID)
  37785. }
  37786. if m.total_tokens != nil {
  37787. fields = append(fields, usagetotal.FieldTotalTokens)
  37788. }
  37789. if m.start_index != nil {
  37790. fields = append(fields, usagetotal.FieldStartIndex)
  37791. }
  37792. if m.end_index != nil {
  37793. fields = append(fields, usagetotal.FieldEndIndex)
  37794. }
  37795. if m.organization_id != nil {
  37796. fields = append(fields, usagetotal.FieldOrganizationID)
  37797. }
  37798. return fields
  37799. }
  37800. // Field returns the value of a field with the given name. The second boolean
  37801. // return value indicates that this field was not set, or was not defined in the
  37802. // schema.
  37803. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  37804. switch name {
  37805. case usagetotal.FieldCreatedAt:
  37806. return m.CreatedAt()
  37807. case usagetotal.FieldUpdatedAt:
  37808. return m.UpdatedAt()
  37809. case usagetotal.FieldStatus:
  37810. return m.Status()
  37811. case usagetotal.FieldType:
  37812. return m.GetType()
  37813. case usagetotal.FieldBotID:
  37814. return m.BotID()
  37815. case usagetotal.FieldTotalTokens:
  37816. return m.TotalTokens()
  37817. case usagetotal.FieldStartIndex:
  37818. return m.StartIndex()
  37819. case usagetotal.FieldEndIndex:
  37820. return m.EndIndex()
  37821. case usagetotal.FieldOrganizationID:
  37822. return m.OrganizationID()
  37823. }
  37824. return nil, false
  37825. }
  37826. // OldField returns the old value of the field from the database. An error is
  37827. // returned if the mutation operation is not UpdateOne, or the query to the
  37828. // database failed.
  37829. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37830. switch name {
  37831. case usagetotal.FieldCreatedAt:
  37832. return m.OldCreatedAt(ctx)
  37833. case usagetotal.FieldUpdatedAt:
  37834. return m.OldUpdatedAt(ctx)
  37835. case usagetotal.FieldStatus:
  37836. return m.OldStatus(ctx)
  37837. case usagetotal.FieldType:
  37838. return m.OldType(ctx)
  37839. case usagetotal.FieldBotID:
  37840. return m.OldBotID(ctx)
  37841. case usagetotal.FieldTotalTokens:
  37842. return m.OldTotalTokens(ctx)
  37843. case usagetotal.FieldStartIndex:
  37844. return m.OldStartIndex(ctx)
  37845. case usagetotal.FieldEndIndex:
  37846. return m.OldEndIndex(ctx)
  37847. case usagetotal.FieldOrganizationID:
  37848. return m.OldOrganizationID(ctx)
  37849. }
  37850. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  37851. }
  37852. // SetField sets the value of a field with the given name. It returns an error if
  37853. // the field is not defined in the schema, or if the type mismatched the field
  37854. // type.
  37855. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  37856. switch name {
  37857. case usagetotal.FieldCreatedAt:
  37858. v, ok := value.(time.Time)
  37859. if !ok {
  37860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37861. }
  37862. m.SetCreatedAt(v)
  37863. return nil
  37864. case usagetotal.FieldUpdatedAt:
  37865. v, ok := value.(time.Time)
  37866. if !ok {
  37867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37868. }
  37869. m.SetUpdatedAt(v)
  37870. return nil
  37871. case usagetotal.FieldStatus:
  37872. v, ok := value.(uint8)
  37873. if !ok {
  37874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37875. }
  37876. m.SetStatus(v)
  37877. return nil
  37878. case usagetotal.FieldType:
  37879. v, ok := value.(int)
  37880. if !ok {
  37881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37882. }
  37883. m.SetType(v)
  37884. return nil
  37885. case usagetotal.FieldBotID:
  37886. v, ok := value.(string)
  37887. if !ok {
  37888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37889. }
  37890. m.SetBotID(v)
  37891. return nil
  37892. case usagetotal.FieldTotalTokens:
  37893. v, ok := value.(uint64)
  37894. if !ok {
  37895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37896. }
  37897. m.SetTotalTokens(v)
  37898. return nil
  37899. case usagetotal.FieldStartIndex:
  37900. v, ok := value.(uint64)
  37901. if !ok {
  37902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37903. }
  37904. m.SetStartIndex(v)
  37905. return nil
  37906. case usagetotal.FieldEndIndex:
  37907. v, ok := value.(uint64)
  37908. if !ok {
  37909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37910. }
  37911. m.SetEndIndex(v)
  37912. return nil
  37913. case usagetotal.FieldOrganizationID:
  37914. v, ok := value.(uint64)
  37915. if !ok {
  37916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37917. }
  37918. m.SetOrganizationID(v)
  37919. return nil
  37920. }
  37921. return fmt.Errorf("unknown UsageTotal field %s", name)
  37922. }
  37923. // AddedFields returns all numeric fields that were incremented/decremented during
  37924. // this mutation.
  37925. func (m *UsageTotalMutation) AddedFields() []string {
  37926. var fields []string
  37927. if m.addstatus != nil {
  37928. fields = append(fields, usagetotal.FieldStatus)
  37929. }
  37930. if m.add_type != nil {
  37931. fields = append(fields, usagetotal.FieldType)
  37932. }
  37933. if m.addtotal_tokens != nil {
  37934. fields = append(fields, usagetotal.FieldTotalTokens)
  37935. }
  37936. if m.addstart_index != nil {
  37937. fields = append(fields, usagetotal.FieldStartIndex)
  37938. }
  37939. if m.addend_index != nil {
  37940. fields = append(fields, usagetotal.FieldEndIndex)
  37941. }
  37942. if m.addorganization_id != nil {
  37943. fields = append(fields, usagetotal.FieldOrganizationID)
  37944. }
  37945. return fields
  37946. }
  37947. // AddedField returns the numeric value that was incremented/decremented on a field
  37948. // with the given name. The second boolean return value indicates that this field
  37949. // was not set, or was not defined in the schema.
  37950. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  37951. switch name {
  37952. case usagetotal.FieldStatus:
  37953. return m.AddedStatus()
  37954. case usagetotal.FieldType:
  37955. return m.AddedType()
  37956. case usagetotal.FieldTotalTokens:
  37957. return m.AddedTotalTokens()
  37958. case usagetotal.FieldStartIndex:
  37959. return m.AddedStartIndex()
  37960. case usagetotal.FieldEndIndex:
  37961. return m.AddedEndIndex()
  37962. case usagetotal.FieldOrganizationID:
  37963. return m.AddedOrganizationID()
  37964. }
  37965. return nil, false
  37966. }
  37967. // AddField adds the value to the field with the given name. It returns an error if
  37968. // the field is not defined in the schema, or if the type mismatched the field
  37969. // type.
  37970. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  37971. switch name {
  37972. case usagetotal.FieldStatus:
  37973. v, ok := value.(int8)
  37974. if !ok {
  37975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37976. }
  37977. m.AddStatus(v)
  37978. return nil
  37979. case usagetotal.FieldType:
  37980. v, ok := value.(int)
  37981. if !ok {
  37982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37983. }
  37984. m.AddType(v)
  37985. return nil
  37986. case usagetotal.FieldTotalTokens:
  37987. v, ok := value.(int64)
  37988. if !ok {
  37989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37990. }
  37991. m.AddTotalTokens(v)
  37992. return nil
  37993. case usagetotal.FieldStartIndex:
  37994. v, ok := value.(int64)
  37995. if !ok {
  37996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37997. }
  37998. m.AddStartIndex(v)
  37999. return nil
  38000. case usagetotal.FieldEndIndex:
  38001. v, ok := value.(int64)
  38002. if !ok {
  38003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38004. }
  38005. m.AddEndIndex(v)
  38006. return nil
  38007. case usagetotal.FieldOrganizationID:
  38008. v, ok := value.(int64)
  38009. if !ok {
  38010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38011. }
  38012. m.AddOrganizationID(v)
  38013. return nil
  38014. }
  38015. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  38016. }
  38017. // ClearedFields returns all nullable fields that were cleared during this
  38018. // mutation.
  38019. func (m *UsageTotalMutation) ClearedFields() []string {
  38020. var fields []string
  38021. if m.FieldCleared(usagetotal.FieldStatus) {
  38022. fields = append(fields, usagetotal.FieldStatus)
  38023. }
  38024. if m.FieldCleared(usagetotal.FieldType) {
  38025. fields = append(fields, usagetotal.FieldType)
  38026. }
  38027. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  38028. fields = append(fields, usagetotal.FieldTotalTokens)
  38029. }
  38030. if m.FieldCleared(usagetotal.FieldStartIndex) {
  38031. fields = append(fields, usagetotal.FieldStartIndex)
  38032. }
  38033. if m.FieldCleared(usagetotal.FieldEndIndex) {
  38034. fields = append(fields, usagetotal.FieldEndIndex)
  38035. }
  38036. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  38037. fields = append(fields, usagetotal.FieldOrganizationID)
  38038. }
  38039. return fields
  38040. }
  38041. // FieldCleared returns a boolean indicating if a field with the given name was
  38042. // cleared in this mutation.
  38043. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  38044. _, ok := m.clearedFields[name]
  38045. return ok
  38046. }
  38047. // ClearField clears the value of the field with the given name. It returns an
  38048. // error if the field is not defined in the schema.
  38049. func (m *UsageTotalMutation) ClearField(name string) error {
  38050. switch name {
  38051. case usagetotal.FieldStatus:
  38052. m.ClearStatus()
  38053. return nil
  38054. case usagetotal.FieldType:
  38055. m.ClearType()
  38056. return nil
  38057. case usagetotal.FieldTotalTokens:
  38058. m.ClearTotalTokens()
  38059. return nil
  38060. case usagetotal.FieldStartIndex:
  38061. m.ClearStartIndex()
  38062. return nil
  38063. case usagetotal.FieldEndIndex:
  38064. m.ClearEndIndex()
  38065. return nil
  38066. case usagetotal.FieldOrganizationID:
  38067. m.ClearOrganizationID()
  38068. return nil
  38069. }
  38070. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  38071. }
  38072. // ResetField resets all changes in the mutation for the field with the given name.
  38073. // It returns an error if the field is not defined in the schema.
  38074. func (m *UsageTotalMutation) ResetField(name string) error {
  38075. switch name {
  38076. case usagetotal.FieldCreatedAt:
  38077. m.ResetCreatedAt()
  38078. return nil
  38079. case usagetotal.FieldUpdatedAt:
  38080. m.ResetUpdatedAt()
  38081. return nil
  38082. case usagetotal.FieldStatus:
  38083. m.ResetStatus()
  38084. return nil
  38085. case usagetotal.FieldType:
  38086. m.ResetType()
  38087. return nil
  38088. case usagetotal.FieldBotID:
  38089. m.ResetBotID()
  38090. return nil
  38091. case usagetotal.FieldTotalTokens:
  38092. m.ResetTotalTokens()
  38093. return nil
  38094. case usagetotal.FieldStartIndex:
  38095. m.ResetStartIndex()
  38096. return nil
  38097. case usagetotal.FieldEndIndex:
  38098. m.ResetEndIndex()
  38099. return nil
  38100. case usagetotal.FieldOrganizationID:
  38101. m.ResetOrganizationID()
  38102. return nil
  38103. }
  38104. return fmt.Errorf("unknown UsageTotal field %s", name)
  38105. }
  38106. // AddedEdges returns all edge names that were set/added in this mutation.
  38107. func (m *UsageTotalMutation) AddedEdges() []string {
  38108. edges := make([]string, 0, 0)
  38109. return edges
  38110. }
  38111. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38112. // name in this mutation.
  38113. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  38114. return nil
  38115. }
  38116. // RemovedEdges returns all edge names that were removed in this mutation.
  38117. func (m *UsageTotalMutation) RemovedEdges() []string {
  38118. edges := make([]string, 0, 0)
  38119. return edges
  38120. }
  38121. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38122. // the given name in this mutation.
  38123. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  38124. return nil
  38125. }
  38126. // ClearedEdges returns all edge names that were cleared in this mutation.
  38127. func (m *UsageTotalMutation) ClearedEdges() []string {
  38128. edges := make([]string, 0, 0)
  38129. return edges
  38130. }
  38131. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38132. // was cleared in this mutation.
  38133. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  38134. return false
  38135. }
  38136. // ClearEdge clears the value of the edge with the given name. It returns an error
  38137. // if that edge is not defined in the schema.
  38138. func (m *UsageTotalMutation) ClearEdge(name string) error {
  38139. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  38140. }
  38141. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38142. // It returns an error if the edge is not defined in the schema.
  38143. func (m *UsageTotalMutation) ResetEdge(name string) error {
  38144. return fmt.Errorf("unknown UsageTotal edge %s", name)
  38145. }
  38146. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  38147. type WhatsappMutation struct {
  38148. config
  38149. op Op
  38150. typ string
  38151. id *uint64
  38152. created_at *time.Time
  38153. updated_at *time.Time
  38154. status *uint8
  38155. addstatus *int8
  38156. deleted_at *time.Time
  38157. wa_id *string
  38158. wa_name *string
  38159. callback *string
  38160. account *string
  38161. cc *string
  38162. phone *string
  38163. cc_phone *string
  38164. phone_name *string
  38165. phone_status *int8
  38166. addphone_status *int8
  38167. organization_id *uint64
  38168. addorganization_id *int64
  38169. api_base *string
  38170. api_key *string
  38171. allow_list *[]string
  38172. appendallow_list []string
  38173. group_allow_list *[]string
  38174. appendgroup_allow_list []string
  38175. block_list *[]string
  38176. appendblock_list []string
  38177. group_block_list *[]string
  38178. appendgroup_block_list []string
  38179. clearedFields map[string]struct{}
  38180. agent *uint64
  38181. clearedagent bool
  38182. done bool
  38183. oldValue func(context.Context) (*Whatsapp, error)
  38184. predicates []predicate.Whatsapp
  38185. }
  38186. var _ ent.Mutation = (*WhatsappMutation)(nil)
  38187. // whatsappOption allows management of the mutation configuration using functional options.
  38188. type whatsappOption func(*WhatsappMutation)
  38189. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  38190. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  38191. m := &WhatsappMutation{
  38192. config: c,
  38193. op: op,
  38194. typ: TypeWhatsapp,
  38195. clearedFields: make(map[string]struct{}),
  38196. }
  38197. for _, opt := range opts {
  38198. opt(m)
  38199. }
  38200. return m
  38201. }
  38202. // withWhatsappID sets the ID field of the mutation.
  38203. func withWhatsappID(id uint64) whatsappOption {
  38204. return func(m *WhatsappMutation) {
  38205. var (
  38206. err error
  38207. once sync.Once
  38208. value *Whatsapp
  38209. )
  38210. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  38211. once.Do(func() {
  38212. if m.done {
  38213. err = errors.New("querying old values post mutation is not allowed")
  38214. } else {
  38215. value, err = m.Client().Whatsapp.Get(ctx, id)
  38216. }
  38217. })
  38218. return value, err
  38219. }
  38220. m.id = &id
  38221. }
  38222. }
  38223. // withWhatsapp sets the old Whatsapp of the mutation.
  38224. func withWhatsapp(node *Whatsapp) whatsappOption {
  38225. return func(m *WhatsappMutation) {
  38226. m.oldValue = func(context.Context) (*Whatsapp, error) {
  38227. return node, nil
  38228. }
  38229. m.id = &node.ID
  38230. }
  38231. }
  38232. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38233. // executed in a transaction (ent.Tx), a transactional client is returned.
  38234. func (m WhatsappMutation) Client() *Client {
  38235. client := &Client{config: m.config}
  38236. client.init()
  38237. return client
  38238. }
  38239. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38240. // it returns an error otherwise.
  38241. func (m WhatsappMutation) Tx() (*Tx, error) {
  38242. if _, ok := m.driver.(*txDriver); !ok {
  38243. return nil, errors.New("ent: mutation is not running in a transaction")
  38244. }
  38245. tx := &Tx{config: m.config}
  38246. tx.init()
  38247. return tx, nil
  38248. }
  38249. // SetID sets the value of the id field. Note that this
  38250. // operation is only accepted on creation of Whatsapp entities.
  38251. func (m *WhatsappMutation) SetID(id uint64) {
  38252. m.id = &id
  38253. }
  38254. // ID returns the ID value in the mutation. Note that the ID is only available
  38255. // if it was provided to the builder or after it was returned from the database.
  38256. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  38257. if m.id == nil {
  38258. return
  38259. }
  38260. return *m.id, true
  38261. }
  38262. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38263. // That means, if the mutation is applied within a transaction with an isolation level such
  38264. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38265. // or updated by the mutation.
  38266. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  38267. switch {
  38268. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38269. id, exists := m.ID()
  38270. if exists {
  38271. return []uint64{id}, nil
  38272. }
  38273. fallthrough
  38274. case m.op.Is(OpUpdate | OpDelete):
  38275. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  38276. default:
  38277. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38278. }
  38279. }
  38280. // SetCreatedAt sets the "created_at" field.
  38281. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  38282. m.created_at = &t
  38283. }
  38284. // CreatedAt returns the value of the "created_at" field in the mutation.
  38285. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  38286. v := m.created_at
  38287. if v == nil {
  38288. return
  38289. }
  38290. return *v, true
  38291. }
  38292. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  38293. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38295. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38296. if !m.op.Is(OpUpdateOne) {
  38297. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38298. }
  38299. if m.id == nil || m.oldValue == nil {
  38300. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38301. }
  38302. oldValue, err := m.oldValue(ctx)
  38303. if err != nil {
  38304. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38305. }
  38306. return oldValue.CreatedAt, nil
  38307. }
  38308. // ResetCreatedAt resets all changes to the "created_at" field.
  38309. func (m *WhatsappMutation) ResetCreatedAt() {
  38310. m.created_at = nil
  38311. }
  38312. // SetUpdatedAt sets the "updated_at" field.
  38313. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  38314. m.updated_at = &t
  38315. }
  38316. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38317. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  38318. v := m.updated_at
  38319. if v == nil {
  38320. return
  38321. }
  38322. return *v, true
  38323. }
  38324. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  38325. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38327. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38328. if !m.op.Is(OpUpdateOne) {
  38329. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38330. }
  38331. if m.id == nil || m.oldValue == nil {
  38332. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38333. }
  38334. oldValue, err := m.oldValue(ctx)
  38335. if err != nil {
  38336. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38337. }
  38338. return oldValue.UpdatedAt, nil
  38339. }
  38340. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38341. func (m *WhatsappMutation) ResetUpdatedAt() {
  38342. m.updated_at = nil
  38343. }
  38344. // SetStatus sets the "status" field.
  38345. func (m *WhatsappMutation) SetStatus(u uint8) {
  38346. m.status = &u
  38347. m.addstatus = nil
  38348. }
  38349. // Status returns the value of the "status" field in the mutation.
  38350. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  38351. v := m.status
  38352. if v == nil {
  38353. return
  38354. }
  38355. return *v, true
  38356. }
  38357. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  38358. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38360. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38361. if !m.op.Is(OpUpdateOne) {
  38362. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38363. }
  38364. if m.id == nil || m.oldValue == nil {
  38365. return v, errors.New("OldStatus requires an ID field in the mutation")
  38366. }
  38367. oldValue, err := m.oldValue(ctx)
  38368. if err != nil {
  38369. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38370. }
  38371. return oldValue.Status, nil
  38372. }
  38373. // AddStatus adds u to the "status" field.
  38374. func (m *WhatsappMutation) AddStatus(u int8) {
  38375. if m.addstatus != nil {
  38376. *m.addstatus += u
  38377. } else {
  38378. m.addstatus = &u
  38379. }
  38380. }
  38381. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38382. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  38383. v := m.addstatus
  38384. if v == nil {
  38385. return
  38386. }
  38387. return *v, true
  38388. }
  38389. // ClearStatus clears the value of the "status" field.
  38390. func (m *WhatsappMutation) ClearStatus() {
  38391. m.status = nil
  38392. m.addstatus = nil
  38393. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  38394. }
  38395. // StatusCleared returns if the "status" field was cleared in this mutation.
  38396. func (m *WhatsappMutation) StatusCleared() bool {
  38397. _, ok := m.clearedFields[whatsapp.FieldStatus]
  38398. return ok
  38399. }
  38400. // ResetStatus resets all changes to the "status" field.
  38401. func (m *WhatsappMutation) ResetStatus() {
  38402. m.status = nil
  38403. m.addstatus = nil
  38404. delete(m.clearedFields, whatsapp.FieldStatus)
  38405. }
  38406. // SetDeletedAt sets the "deleted_at" field.
  38407. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  38408. m.deleted_at = &t
  38409. }
  38410. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38411. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  38412. v := m.deleted_at
  38413. if v == nil {
  38414. return
  38415. }
  38416. return *v, true
  38417. }
  38418. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  38419. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38421. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38422. if !m.op.Is(OpUpdateOne) {
  38423. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38424. }
  38425. if m.id == nil || m.oldValue == nil {
  38426. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38427. }
  38428. oldValue, err := m.oldValue(ctx)
  38429. if err != nil {
  38430. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38431. }
  38432. return oldValue.DeletedAt, nil
  38433. }
  38434. // ClearDeletedAt clears the value of the "deleted_at" field.
  38435. func (m *WhatsappMutation) ClearDeletedAt() {
  38436. m.deleted_at = nil
  38437. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  38438. }
  38439. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38440. func (m *WhatsappMutation) DeletedAtCleared() bool {
  38441. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  38442. return ok
  38443. }
  38444. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38445. func (m *WhatsappMutation) ResetDeletedAt() {
  38446. m.deleted_at = nil
  38447. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  38448. }
  38449. // SetWaID sets the "wa_id" field.
  38450. func (m *WhatsappMutation) SetWaID(s string) {
  38451. m.wa_id = &s
  38452. }
  38453. // WaID returns the value of the "wa_id" field in the mutation.
  38454. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  38455. v := m.wa_id
  38456. if v == nil {
  38457. return
  38458. }
  38459. return *v, true
  38460. }
  38461. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  38462. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38464. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  38465. if !m.op.Is(OpUpdateOne) {
  38466. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38467. }
  38468. if m.id == nil || m.oldValue == nil {
  38469. return v, errors.New("OldWaID requires an ID field in the mutation")
  38470. }
  38471. oldValue, err := m.oldValue(ctx)
  38472. if err != nil {
  38473. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38474. }
  38475. return oldValue.WaID, nil
  38476. }
  38477. // ClearWaID clears the value of the "wa_id" field.
  38478. func (m *WhatsappMutation) ClearWaID() {
  38479. m.wa_id = nil
  38480. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  38481. }
  38482. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38483. func (m *WhatsappMutation) WaIDCleared() bool {
  38484. _, ok := m.clearedFields[whatsapp.FieldWaID]
  38485. return ok
  38486. }
  38487. // ResetWaID resets all changes to the "wa_id" field.
  38488. func (m *WhatsappMutation) ResetWaID() {
  38489. m.wa_id = nil
  38490. delete(m.clearedFields, whatsapp.FieldWaID)
  38491. }
  38492. // SetWaName sets the "wa_name" field.
  38493. func (m *WhatsappMutation) SetWaName(s string) {
  38494. m.wa_name = &s
  38495. }
  38496. // WaName returns the value of the "wa_name" field in the mutation.
  38497. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  38498. v := m.wa_name
  38499. if v == nil {
  38500. return
  38501. }
  38502. return *v, true
  38503. }
  38504. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  38505. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38507. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  38508. if !m.op.Is(OpUpdateOne) {
  38509. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38510. }
  38511. if m.id == nil || m.oldValue == nil {
  38512. return v, errors.New("OldWaName requires an ID field in the mutation")
  38513. }
  38514. oldValue, err := m.oldValue(ctx)
  38515. if err != nil {
  38516. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38517. }
  38518. return oldValue.WaName, nil
  38519. }
  38520. // ClearWaName clears the value of the "wa_name" field.
  38521. func (m *WhatsappMutation) ClearWaName() {
  38522. m.wa_name = nil
  38523. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  38524. }
  38525. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38526. func (m *WhatsappMutation) WaNameCleared() bool {
  38527. _, ok := m.clearedFields[whatsapp.FieldWaName]
  38528. return ok
  38529. }
  38530. // ResetWaName resets all changes to the "wa_name" field.
  38531. func (m *WhatsappMutation) ResetWaName() {
  38532. m.wa_name = nil
  38533. delete(m.clearedFields, whatsapp.FieldWaName)
  38534. }
  38535. // SetCallback sets the "callback" field.
  38536. func (m *WhatsappMutation) SetCallback(s string) {
  38537. m.callback = &s
  38538. }
  38539. // Callback returns the value of the "callback" field in the mutation.
  38540. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  38541. v := m.callback
  38542. if v == nil {
  38543. return
  38544. }
  38545. return *v, true
  38546. }
  38547. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  38548. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38550. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  38551. if !m.op.Is(OpUpdateOne) {
  38552. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  38553. }
  38554. if m.id == nil || m.oldValue == nil {
  38555. return v, errors.New("OldCallback requires an ID field in the mutation")
  38556. }
  38557. oldValue, err := m.oldValue(ctx)
  38558. if err != nil {
  38559. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  38560. }
  38561. return oldValue.Callback, nil
  38562. }
  38563. // ClearCallback clears the value of the "callback" field.
  38564. func (m *WhatsappMutation) ClearCallback() {
  38565. m.callback = nil
  38566. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  38567. }
  38568. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  38569. func (m *WhatsappMutation) CallbackCleared() bool {
  38570. _, ok := m.clearedFields[whatsapp.FieldCallback]
  38571. return ok
  38572. }
  38573. // ResetCallback resets all changes to the "callback" field.
  38574. func (m *WhatsappMutation) ResetCallback() {
  38575. m.callback = nil
  38576. delete(m.clearedFields, whatsapp.FieldCallback)
  38577. }
  38578. // SetAgentID sets the "agent_id" field.
  38579. func (m *WhatsappMutation) SetAgentID(u uint64) {
  38580. m.agent = &u
  38581. }
  38582. // AgentID returns the value of the "agent_id" field in the mutation.
  38583. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  38584. v := m.agent
  38585. if v == nil {
  38586. return
  38587. }
  38588. return *v, true
  38589. }
  38590. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  38591. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38593. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38594. if !m.op.Is(OpUpdateOne) {
  38595. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38596. }
  38597. if m.id == nil || m.oldValue == nil {
  38598. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38599. }
  38600. oldValue, err := m.oldValue(ctx)
  38601. if err != nil {
  38602. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38603. }
  38604. return oldValue.AgentID, nil
  38605. }
  38606. // ResetAgentID resets all changes to the "agent_id" field.
  38607. func (m *WhatsappMutation) ResetAgentID() {
  38608. m.agent = nil
  38609. }
  38610. // SetAccount sets the "account" field.
  38611. func (m *WhatsappMutation) SetAccount(s string) {
  38612. m.account = &s
  38613. }
  38614. // Account returns the value of the "account" field in the mutation.
  38615. func (m *WhatsappMutation) Account() (r string, exists bool) {
  38616. v := m.account
  38617. if v == nil {
  38618. return
  38619. }
  38620. return *v, true
  38621. }
  38622. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  38623. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38625. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  38626. if !m.op.Is(OpUpdateOne) {
  38627. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38628. }
  38629. if m.id == nil || m.oldValue == nil {
  38630. return v, errors.New("OldAccount requires an ID field in the mutation")
  38631. }
  38632. oldValue, err := m.oldValue(ctx)
  38633. if err != nil {
  38634. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  38635. }
  38636. return oldValue.Account, nil
  38637. }
  38638. // ClearAccount clears the value of the "account" field.
  38639. func (m *WhatsappMutation) ClearAccount() {
  38640. m.account = nil
  38641. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  38642. }
  38643. // AccountCleared returns if the "account" field was cleared in this mutation.
  38644. func (m *WhatsappMutation) AccountCleared() bool {
  38645. _, ok := m.clearedFields[whatsapp.FieldAccount]
  38646. return ok
  38647. }
  38648. // ResetAccount resets all changes to the "account" field.
  38649. func (m *WhatsappMutation) ResetAccount() {
  38650. m.account = nil
  38651. delete(m.clearedFields, whatsapp.FieldAccount)
  38652. }
  38653. // SetCc sets the "cc" field.
  38654. func (m *WhatsappMutation) SetCc(s string) {
  38655. m.cc = &s
  38656. }
  38657. // Cc returns the value of the "cc" field in the mutation.
  38658. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  38659. v := m.cc
  38660. if v == nil {
  38661. return
  38662. }
  38663. return *v, true
  38664. }
  38665. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  38666. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38668. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  38669. if !m.op.Is(OpUpdateOne) {
  38670. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  38671. }
  38672. if m.id == nil || m.oldValue == nil {
  38673. return v, errors.New("OldCc requires an ID field in the mutation")
  38674. }
  38675. oldValue, err := m.oldValue(ctx)
  38676. if err != nil {
  38677. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  38678. }
  38679. return oldValue.Cc, nil
  38680. }
  38681. // ResetCc resets all changes to the "cc" field.
  38682. func (m *WhatsappMutation) ResetCc() {
  38683. m.cc = nil
  38684. }
  38685. // SetPhone sets the "phone" field.
  38686. func (m *WhatsappMutation) SetPhone(s string) {
  38687. m.phone = &s
  38688. }
  38689. // Phone returns the value of the "phone" field in the mutation.
  38690. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  38691. v := m.phone
  38692. if v == nil {
  38693. return
  38694. }
  38695. return *v, true
  38696. }
  38697. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  38698. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38700. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  38701. if !m.op.Is(OpUpdateOne) {
  38702. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38703. }
  38704. if m.id == nil || m.oldValue == nil {
  38705. return v, errors.New("OldPhone requires an ID field in the mutation")
  38706. }
  38707. oldValue, err := m.oldValue(ctx)
  38708. if err != nil {
  38709. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38710. }
  38711. return oldValue.Phone, nil
  38712. }
  38713. // ResetPhone resets all changes to the "phone" field.
  38714. func (m *WhatsappMutation) ResetPhone() {
  38715. m.phone = nil
  38716. }
  38717. // SetCcPhone sets the "cc_phone" field.
  38718. func (m *WhatsappMutation) SetCcPhone(s string) {
  38719. m.cc_phone = &s
  38720. }
  38721. // CcPhone returns the value of the "cc_phone" field in the mutation.
  38722. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  38723. v := m.cc_phone
  38724. if v == nil {
  38725. return
  38726. }
  38727. return *v, true
  38728. }
  38729. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  38730. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38732. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  38733. if !m.op.Is(OpUpdateOne) {
  38734. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  38735. }
  38736. if m.id == nil || m.oldValue == nil {
  38737. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  38738. }
  38739. oldValue, err := m.oldValue(ctx)
  38740. if err != nil {
  38741. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  38742. }
  38743. return oldValue.CcPhone, nil
  38744. }
  38745. // ResetCcPhone resets all changes to the "cc_phone" field.
  38746. func (m *WhatsappMutation) ResetCcPhone() {
  38747. m.cc_phone = nil
  38748. }
  38749. // SetPhoneName sets the "phone_name" field.
  38750. func (m *WhatsappMutation) SetPhoneName(s string) {
  38751. m.phone_name = &s
  38752. }
  38753. // PhoneName returns the value of the "phone_name" field in the mutation.
  38754. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  38755. v := m.phone_name
  38756. if v == nil {
  38757. return
  38758. }
  38759. return *v, true
  38760. }
  38761. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  38762. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38764. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  38765. if !m.op.Is(OpUpdateOne) {
  38766. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  38767. }
  38768. if m.id == nil || m.oldValue == nil {
  38769. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  38770. }
  38771. oldValue, err := m.oldValue(ctx)
  38772. if err != nil {
  38773. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  38774. }
  38775. return oldValue.PhoneName, nil
  38776. }
  38777. // ResetPhoneName resets all changes to the "phone_name" field.
  38778. func (m *WhatsappMutation) ResetPhoneName() {
  38779. m.phone_name = nil
  38780. }
  38781. // SetPhoneStatus sets the "phone_status" field.
  38782. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  38783. m.phone_status = &i
  38784. m.addphone_status = nil
  38785. }
  38786. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  38787. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  38788. v := m.phone_status
  38789. if v == nil {
  38790. return
  38791. }
  38792. return *v, true
  38793. }
  38794. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  38795. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38797. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  38798. if !m.op.Is(OpUpdateOne) {
  38799. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  38800. }
  38801. if m.id == nil || m.oldValue == nil {
  38802. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  38803. }
  38804. oldValue, err := m.oldValue(ctx)
  38805. if err != nil {
  38806. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  38807. }
  38808. return oldValue.PhoneStatus, nil
  38809. }
  38810. // AddPhoneStatus adds i to the "phone_status" field.
  38811. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  38812. if m.addphone_status != nil {
  38813. *m.addphone_status += i
  38814. } else {
  38815. m.addphone_status = &i
  38816. }
  38817. }
  38818. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  38819. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  38820. v := m.addphone_status
  38821. if v == nil {
  38822. return
  38823. }
  38824. return *v, true
  38825. }
  38826. // ResetPhoneStatus resets all changes to the "phone_status" field.
  38827. func (m *WhatsappMutation) ResetPhoneStatus() {
  38828. m.phone_status = nil
  38829. m.addphone_status = nil
  38830. }
  38831. // SetOrganizationID sets the "organization_id" field.
  38832. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  38833. m.organization_id = &u
  38834. m.addorganization_id = nil
  38835. }
  38836. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38837. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  38838. v := m.organization_id
  38839. if v == nil {
  38840. return
  38841. }
  38842. return *v, true
  38843. }
  38844. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  38845. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38847. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38848. if !m.op.Is(OpUpdateOne) {
  38849. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38850. }
  38851. if m.id == nil || m.oldValue == nil {
  38852. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38853. }
  38854. oldValue, err := m.oldValue(ctx)
  38855. if err != nil {
  38856. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38857. }
  38858. return oldValue.OrganizationID, nil
  38859. }
  38860. // AddOrganizationID adds u to the "organization_id" field.
  38861. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  38862. if m.addorganization_id != nil {
  38863. *m.addorganization_id += u
  38864. } else {
  38865. m.addorganization_id = &u
  38866. }
  38867. }
  38868. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38869. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  38870. v := m.addorganization_id
  38871. if v == nil {
  38872. return
  38873. }
  38874. return *v, true
  38875. }
  38876. // ClearOrganizationID clears the value of the "organization_id" field.
  38877. func (m *WhatsappMutation) ClearOrganizationID() {
  38878. m.organization_id = nil
  38879. m.addorganization_id = nil
  38880. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  38881. }
  38882. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38883. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  38884. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  38885. return ok
  38886. }
  38887. // ResetOrganizationID resets all changes to the "organization_id" field.
  38888. func (m *WhatsappMutation) ResetOrganizationID() {
  38889. m.organization_id = nil
  38890. m.addorganization_id = nil
  38891. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  38892. }
  38893. // SetAPIBase sets the "api_base" field.
  38894. func (m *WhatsappMutation) SetAPIBase(s string) {
  38895. m.api_base = &s
  38896. }
  38897. // APIBase returns the value of the "api_base" field in the mutation.
  38898. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  38899. v := m.api_base
  38900. if v == nil {
  38901. return
  38902. }
  38903. return *v, true
  38904. }
  38905. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  38906. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38908. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38909. if !m.op.Is(OpUpdateOne) {
  38910. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38911. }
  38912. if m.id == nil || m.oldValue == nil {
  38913. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38914. }
  38915. oldValue, err := m.oldValue(ctx)
  38916. if err != nil {
  38917. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38918. }
  38919. return oldValue.APIBase, nil
  38920. }
  38921. // ClearAPIBase clears the value of the "api_base" field.
  38922. func (m *WhatsappMutation) ClearAPIBase() {
  38923. m.api_base = nil
  38924. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  38925. }
  38926. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38927. func (m *WhatsappMutation) APIBaseCleared() bool {
  38928. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  38929. return ok
  38930. }
  38931. // ResetAPIBase resets all changes to the "api_base" field.
  38932. func (m *WhatsappMutation) ResetAPIBase() {
  38933. m.api_base = nil
  38934. delete(m.clearedFields, whatsapp.FieldAPIBase)
  38935. }
  38936. // SetAPIKey sets the "api_key" field.
  38937. func (m *WhatsappMutation) SetAPIKey(s string) {
  38938. m.api_key = &s
  38939. }
  38940. // APIKey returns the value of the "api_key" field in the mutation.
  38941. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  38942. v := m.api_key
  38943. if v == nil {
  38944. return
  38945. }
  38946. return *v, true
  38947. }
  38948. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  38949. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38951. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38952. if !m.op.Is(OpUpdateOne) {
  38953. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38954. }
  38955. if m.id == nil || m.oldValue == nil {
  38956. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38957. }
  38958. oldValue, err := m.oldValue(ctx)
  38959. if err != nil {
  38960. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38961. }
  38962. return oldValue.APIKey, nil
  38963. }
  38964. // ClearAPIKey clears the value of the "api_key" field.
  38965. func (m *WhatsappMutation) ClearAPIKey() {
  38966. m.api_key = nil
  38967. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  38968. }
  38969. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38970. func (m *WhatsappMutation) APIKeyCleared() bool {
  38971. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  38972. return ok
  38973. }
  38974. // ResetAPIKey resets all changes to the "api_key" field.
  38975. func (m *WhatsappMutation) ResetAPIKey() {
  38976. m.api_key = nil
  38977. delete(m.clearedFields, whatsapp.FieldAPIKey)
  38978. }
  38979. // SetAllowList sets the "allow_list" field.
  38980. func (m *WhatsappMutation) SetAllowList(s []string) {
  38981. m.allow_list = &s
  38982. m.appendallow_list = nil
  38983. }
  38984. // AllowList returns the value of the "allow_list" field in the mutation.
  38985. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  38986. v := m.allow_list
  38987. if v == nil {
  38988. return
  38989. }
  38990. return *v, true
  38991. }
  38992. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  38993. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38995. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38996. if !m.op.Is(OpUpdateOne) {
  38997. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38998. }
  38999. if m.id == nil || m.oldValue == nil {
  39000. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39001. }
  39002. oldValue, err := m.oldValue(ctx)
  39003. if err != nil {
  39004. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39005. }
  39006. return oldValue.AllowList, nil
  39007. }
  39008. // AppendAllowList adds s to the "allow_list" field.
  39009. func (m *WhatsappMutation) AppendAllowList(s []string) {
  39010. m.appendallow_list = append(m.appendallow_list, s...)
  39011. }
  39012. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39013. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  39014. if len(m.appendallow_list) == 0 {
  39015. return nil, false
  39016. }
  39017. return m.appendallow_list, true
  39018. }
  39019. // ClearAllowList clears the value of the "allow_list" field.
  39020. func (m *WhatsappMutation) ClearAllowList() {
  39021. m.allow_list = nil
  39022. m.appendallow_list = nil
  39023. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  39024. }
  39025. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  39026. func (m *WhatsappMutation) AllowListCleared() bool {
  39027. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  39028. return ok
  39029. }
  39030. // ResetAllowList resets all changes to the "allow_list" field.
  39031. func (m *WhatsappMutation) ResetAllowList() {
  39032. m.allow_list = nil
  39033. m.appendallow_list = nil
  39034. delete(m.clearedFields, whatsapp.FieldAllowList)
  39035. }
  39036. // SetGroupAllowList sets the "group_allow_list" field.
  39037. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  39038. m.group_allow_list = &s
  39039. m.appendgroup_allow_list = nil
  39040. }
  39041. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39042. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  39043. v := m.group_allow_list
  39044. if v == nil {
  39045. return
  39046. }
  39047. return *v, true
  39048. }
  39049. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  39050. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39052. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39053. if !m.op.Is(OpUpdateOne) {
  39054. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39055. }
  39056. if m.id == nil || m.oldValue == nil {
  39057. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39058. }
  39059. oldValue, err := m.oldValue(ctx)
  39060. if err != nil {
  39061. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39062. }
  39063. return oldValue.GroupAllowList, nil
  39064. }
  39065. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39066. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  39067. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39068. }
  39069. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39070. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  39071. if len(m.appendgroup_allow_list) == 0 {
  39072. return nil, false
  39073. }
  39074. return m.appendgroup_allow_list, true
  39075. }
  39076. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  39077. func (m *WhatsappMutation) ClearGroupAllowList() {
  39078. m.group_allow_list = nil
  39079. m.appendgroup_allow_list = nil
  39080. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  39081. }
  39082. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  39083. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  39084. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  39085. return ok
  39086. }
  39087. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39088. func (m *WhatsappMutation) ResetGroupAllowList() {
  39089. m.group_allow_list = nil
  39090. m.appendgroup_allow_list = nil
  39091. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  39092. }
  39093. // SetBlockList sets the "block_list" field.
  39094. func (m *WhatsappMutation) SetBlockList(s []string) {
  39095. m.block_list = &s
  39096. m.appendblock_list = nil
  39097. }
  39098. // BlockList returns the value of the "block_list" field in the mutation.
  39099. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  39100. v := m.block_list
  39101. if v == nil {
  39102. return
  39103. }
  39104. return *v, true
  39105. }
  39106. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  39107. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39109. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39110. if !m.op.Is(OpUpdateOne) {
  39111. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39112. }
  39113. if m.id == nil || m.oldValue == nil {
  39114. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39115. }
  39116. oldValue, err := m.oldValue(ctx)
  39117. if err != nil {
  39118. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39119. }
  39120. return oldValue.BlockList, nil
  39121. }
  39122. // AppendBlockList adds s to the "block_list" field.
  39123. func (m *WhatsappMutation) AppendBlockList(s []string) {
  39124. m.appendblock_list = append(m.appendblock_list, s...)
  39125. }
  39126. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39127. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  39128. if len(m.appendblock_list) == 0 {
  39129. return nil, false
  39130. }
  39131. return m.appendblock_list, true
  39132. }
  39133. // ClearBlockList clears the value of the "block_list" field.
  39134. func (m *WhatsappMutation) ClearBlockList() {
  39135. m.block_list = nil
  39136. m.appendblock_list = nil
  39137. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  39138. }
  39139. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  39140. func (m *WhatsappMutation) BlockListCleared() bool {
  39141. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  39142. return ok
  39143. }
  39144. // ResetBlockList resets all changes to the "block_list" field.
  39145. func (m *WhatsappMutation) ResetBlockList() {
  39146. m.block_list = nil
  39147. m.appendblock_list = nil
  39148. delete(m.clearedFields, whatsapp.FieldBlockList)
  39149. }
  39150. // SetGroupBlockList sets the "group_block_list" field.
  39151. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  39152. m.group_block_list = &s
  39153. m.appendgroup_block_list = nil
  39154. }
  39155. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39156. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  39157. v := m.group_block_list
  39158. if v == nil {
  39159. return
  39160. }
  39161. return *v, true
  39162. }
  39163. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  39164. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39166. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39167. if !m.op.Is(OpUpdateOne) {
  39168. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39169. }
  39170. if m.id == nil || m.oldValue == nil {
  39171. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39172. }
  39173. oldValue, err := m.oldValue(ctx)
  39174. if err != nil {
  39175. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39176. }
  39177. return oldValue.GroupBlockList, nil
  39178. }
  39179. // AppendGroupBlockList adds s to the "group_block_list" field.
  39180. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  39181. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39182. }
  39183. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39184. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  39185. if len(m.appendgroup_block_list) == 0 {
  39186. return nil, false
  39187. }
  39188. return m.appendgroup_block_list, true
  39189. }
  39190. // ClearGroupBlockList clears the value of the "group_block_list" field.
  39191. func (m *WhatsappMutation) ClearGroupBlockList() {
  39192. m.group_block_list = nil
  39193. m.appendgroup_block_list = nil
  39194. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  39195. }
  39196. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  39197. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  39198. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  39199. return ok
  39200. }
  39201. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39202. func (m *WhatsappMutation) ResetGroupBlockList() {
  39203. m.group_block_list = nil
  39204. m.appendgroup_block_list = nil
  39205. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  39206. }
  39207. // ClearAgent clears the "agent" edge to the Agent entity.
  39208. func (m *WhatsappMutation) ClearAgent() {
  39209. m.clearedagent = true
  39210. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  39211. }
  39212. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39213. func (m *WhatsappMutation) AgentCleared() bool {
  39214. return m.clearedagent
  39215. }
  39216. // AgentIDs returns the "agent" edge IDs in the mutation.
  39217. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39218. // AgentID instead. It exists only for internal usage by the builders.
  39219. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  39220. if id := m.agent; id != nil {
  39221. ids = append(ids, *id)
  39222. }
  39223. return
  39224. }
  39225. // ResetAgent resets all changes to the "agent" edge.
  39226. func (m *WhatsappMutation) ResetAgent() {
  39227. m.agent = nil
  39228. m.clearedagent = false
  39229. }
  39230. // Where appends a list predicates to the WhatsappMutation builder.
  39231. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  39232. m.predicates = append(m.predicates, ps...)
  39233. }
  39234. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  39235. // users can use type-assertion to append predicates that do not depend on any generated package.
  39236. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  39237. p := make([]predicate.Whatsapp, len(ps))
  39238. for i := range ps {
  39239. p[i] = ps[i]
  39240. }
  39241. m.Where(p...)
  39242. }
  39243. // Op returns the operation name.
  39244. func (m *WhatsappMutation) Op() Op {
  39245. return m.op
  39246. }
  39247. // SetOp allows setting the mutation operation.
  39248. func (m *WhatsappMutation) SetOp(op Op) {
  39249. m.op = op
  39250. }
  39251. // Type returns the node type of this mutation (Whatsapp).
  39252. func (m *WhatsappMutation) Type() string {
  39253. return m.typ
  39254. }
  39255. // Fields returns all fields that were changed during this mutation. Note that in
  39256. // order to get all numeric fields that were incremented/decremented, call
  39257. // AddedFields().
  39258. func (m *WhatsappMutation) Fields() []string {
  39259. fields := make([]string, 0, 21)
  39260. if m.created_at != nil {
  39261. fields = append(fields, whatsapp.FieldCreatedAt)
  39262. }
  39263. if m.updated_at != nil {
  39264. fields = append(fields, whatsapp.FieldUpdatedAt)
  39265. }
  39266. if m.status != nil {
  39267. fields = append(fields, whatsapp.FieldStatus)
  39268. }
  39269. if m.deleted_at != nil {
  39270. fields = append(fields, whatsapp.FieldDeletedAt)
  39271. }
  39272. if m.wa_id != nil {
  39273. fields = append(fields, whatsapp.FieldWaID)
  39274. }
  39275. if m.wa_name != nil {
  39276. fields = append(fields, whatsapp.FieldWaName)
  39277. }
  39278. if m.callback != nil {
  39279. fields = append(fields, whatsapp.FieldCallback)
  39280. }
  39281. if m.agent != nil {
  39282. fields = append(fields, whatsapp.FieldAgentID)
  39283. }
  39284. if m.account != nil {
  39285. fields = append(fields, whatsapp.FieldAccount)
  39286. }
  39287. if m.cc != nil {
  39288. fields = append(fields, whatsapp.FieldCc)
  39289. }
  39290. if m.phone != nil {
  39291. fields = append(fields, whatsapp.FieldPhone)
  39292. }
  39293. if m.cc_phone != nil {
  39294. fields = append(fields, whatsapp.FieldCcPhone)
  39295. }
  39296. if m.phone_name != nil {
  39297. fields = append(fields, whatsapp.FieldPhoneName)
  39298. }
  39299. if m.phone_status != nil {
  39300. fields = append(fields, whatsapp.FieldPhoneStatus)
  39301. }
  39302. if m.organization_id != nil {
  39303. fields = append(fields, whatsapp.FieldOrganizationID)
  39304. }
  39305. if m.api_base != nil {
  39306. fields = append(fields, whatsapp.FieldAPIBase)
  39307. }
  39308. if m.api_key != nil {
  39309. fields = append(fields, whatsapp.FieldAPIKey)
  39310. }
  39311. if m.allow_list != nil {
  39312. fields = append(fields, whatsapp.FieldAllowList)
  39313. }
  39314. if m.group_allow_list != nil {
  39315. fields = append(fields, whatsapp.FieldGroupAllowList)
  39316. }
  39317. if m.block_list != nil {
  39318. fields = append(fields, whatsapp.FieldBlockList)
  39319. }
  39320. if m.group_block_list != nil {
  39321. fields = append(fields, whatsapp.FieldGroupBlockList)
  39322. }
  39323. return fields
  39324. }
  39325. // Field returns the value of a field with the given name. The second boolean
  39326. // return value indicates that this field was not set, or was not defined in the
  39327. // schema.
  39328. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  39329. switch name {
  39330. case whatsapp.FieldCreatedAt:
  39331. return m.CreatedAt()
  39332. case whatsapp.FieldUpdatedAt:
  39333. return m.UpdatedAt()
  39334. case whatsapp.FieldStatus:
  39335. return m.Status()
  39336. case whatsapp.FieldDeletedAt:
  39337. return m.DeletedAt()
  39338. case whatsapp.FieldWaID:
  39339. return m.WaID()
  39340. case whatsapp.FieldWaName:
  39341. return m.WaName()
  39342. case whatsapp.FieldCallback:
  39343. return m.Callback()
  39344. case whatsapp.FieldAgentID:
  39345. return m.AgentID()
  39346. case whatsapp.FieldAccount:
  39347. return m.Account()
  39348. case whatsapp.FieldCc:
  39349. return m.Cc()
  39350. case whatsapp.FieldPhone:
  39351. return m.Phone()
  39352. case whatsapp.FieldCcPhone:
  39353. return m.CcPhone()
  39354. case whatsapp.FieldPhoneName:
  39355. return m.PhoneName()
  39356. case whatsapp.FieldPhoneStatus:
  39357. return m.PhoneStatus()
  39358. case whatsapp.FieldOrganizationID:
  39359. return m.OrganizationID()
  39360. case whatsapp.FieldAPIBase:
  39361. return m.APIBase()
  39362. case whatsapp.FieldAPIKey:
  39363. return m.APIKey()
  39364. case whatsapp.FieldAllowList:
  39365. return m.AllowList()
  39366. case whatsapp.FieldGroupAllowList:
  39367. return m.GroupAllowList()
  39368. case whatsapp.FieldBlockList:
  39369. return m.BlockList()
  39370. case whatsapp.FieldGroupBlockList:
  39371. return m.GroupBlockList()
  39372. }
  39373. return nil, false
  39374. }
  39375. // OldField returns the old value of the field from the database. An error is
  39376. // returned if the mutation operation is not UpdateOne, or the query to the
  39377. // database failed.
  39378. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39379. switch name {
  39380. case whatsapp.FieldCreatedAt:
  39381. return m.OldCreatedAt(ctx)
  39382. case whatsapp.FieldUpdatedAt:
  39383. return m.OldUpdatedAt(ctx)
  39384. case whatsapp.FieldStatus:
  39385. return m.OldStatus(ctx)
  39386. case whatsapp.FieldDeletedAt:
  39387. return m.OldDeletedAt(ctx)
  39388. case whatsapp.FieldWaID:
  39389. return m.OldWaID(ctx)
  39390. case whatsapp.FieldWaName:
  39391. return m.OldWaName(ctx)
  39392. case whatsapp.FieldCallback:
  39393. return m.OldCallback(ctx)
  39394. case whatsapp.FieldAgentID:
  39395. return m.OldAgentID(ctx)
  39396. case whatsapp.FieldAccount:
  39397. return m.OldAccount(ctx)
  39398. case whatsapp.FieldCc:
  39399. return m.OldCc(ctx)
  39400. case whatsapp.FieldPhone:
  39401. return m.OldPhone(ctx)
  39402. case whatsapp.FieldCcPhone:
  39403. return m.OldCcPhone(ctx)
  39404. case whatsapp.FieldPhoneName:
  39405. return m.OldPhoneName(ctx)
  39406. case whatsapp.FieldPhoneStatus:
  39407. return m.OldPhoneStatus(ctx)
  39408. case whatsapp.FieldOrganizationID:
  39409. return m.OldOrganizationID(ctx)
  39410. case whatsapp.FieldAPIBase:
  39411. return m.OldAPIBase(ctx)
  39412. case whatsapp.FieldAPIKey:
  39413. return m.OldAPIKey(ctx)
  39414. case whatsapp.FieldAllowList:
  39415. return m.OldAllowList(ctx)
  39416. case whatsapp.FieldGroupAllowList:
  39417. return m.OldGroupAllowList(ctx)
  39418. case whatsapp.FieldBlockList:
  39419. return m.OldBlockList(ctx)
  39420. case whatsapp.FieldGroupBlockList:
  39421. return m.OldGroupBlockList(ctx)
  39422. }
  39423. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  39424. }
  39425. // SetField sets the value of a field with the given name. It returns an error if
  39426. // the field is not defined in the schema, or if the type mismatched the field
  39427. // type.
  39428. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  39429. switch name {
  39430. case whatsapp.FieldCreatedAt:
  39431. v, ok := value.(time.Time)
  39432. if !ok {
  39433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39434. }
  39435. m.SetCreatedAt(v)
  39436. return nil
  39437. case whatsapp.FieldUpdatedAt:
  39438. v, ok := value.(time.Time)
  39439. if !ok {
  39440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39441. }
  39442. m.SetUpdatedAt(v)
  39443. return nil
  39444. case whatsapp.FieldStatus:
  39445. v, ok := value.(uint8)
  39446. if !ok {
  39447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39448. }
  39449. m.SetStatus(v)
  39450. return nil
  39451. case whatsapp.FieldDeletedAt:
  39452. v, ok := value.(time.Time)
  39453. if !ok {
  39454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39455. }
  39456. m.SetDeletedAt(v)
  39457. return nil
  39458. case whatsapp.FieldWaID:
  39459. v, ok := value.(string)
  39460. if !ok {
  39461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39462. }
  39463. m.SetWaID(v)
  39464. return nil
  39465. case whatsapp.FieldWaName:
  39466. v, ok := value.(string)
  39467. if !ok {
  39468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39469. }
  39470. m.SetWaName(v)
  39471. return nil
  39472. case whatsapp.FieldCallback:
  39473. v, ok := value.(string)
  39474. if !ok {
  39475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39476. }
  39477. m.SetCallback(v)
  39478. return nil
  39479. case whatsapp.FieldAgentID:
  39480. v, ok := value.(uint64)
  39481. if !ok {
  39482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39483. }
  39484. m.SetAgentID(v)
  39485. return nil
  39486. case whatsapp.FieldAccount:
  39487. v, ok := value.(string)
  39488. if !ok {
  39489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39490. }
  39491. m.SetAccount(v)
  39492. return nil
  39493. case whatsapp.FieldCc:
  39494. v, ok := value.(string)
  39495. if !ok {
  39496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39497. }
  39498. m.SetCc(v)
  39499. return nil
  39500. case whatsapp.FieldPhone:
  39501. v, ok := value.(string)
  39502. if !ok {
  39503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39504. }
  39505. m.SetPhone(v)
  39506. return nil
  39507. case whatsapp.FieldCcPhone:
  39508. v, ok := value.(string)
  39509. if !ok {
  39510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39511. }
  39512. m.SetCcPhone(v)
  39513. return nil
  39514. case whatsapp.FieldPhoneName:
  39515. v, ok := value.(string)
  39516. if !ok {
  39517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39518. }
  39519. m.SetPhoneName(v)
  39520. return nil
  39521. case whatsapp.FieldPhoneStatus:
  39522. v, ok := value.(int8)
  39523. if !ok {
  39524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39525. }
  39526. m.SetPhoneStatus(v)
  39527. return nil
  39528. case whatsapp.FieldOrganizationID:
  39529. v, ok := value.(uint64)
  39530. if !ok {
  39531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39532. }
  39533. m.SetOrganizationID(v)
  39534. return nil
  39535. case whatsapp.FieldAPIBase:
  39536. v, ok := value.(string)
  39537. if !ok {
  39538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39539. }
  39540. m.SetAPIBase(v)
  39541. return nil
  39542. case whatsapp.FieldAPIKey:
  39543. v, ok := value.(string)
  39544. if !ok {
  39545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39546. }
  39547. m.SetAPIKey(v)
  39548. return nil
  39549. case whatsapp.FieldAllowList:
  39550. v, ok := value.([]string)
  39551. if !ok {
  39552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39553. }
  39554. m.SetAllowList(v)
  39555. return nil
  39556. case whatsapp.FieldGroupAllowList:
  39557. v, ok := value.([]string)
  39558. if !ok {
  39559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39560. }
  39561. m.SetGroupAllowList(v)
  39562. return nil
  39563. case whatsapp.FieldBlockList:
  39564. v, ok := value.([]string)
  39565. if !ok {
  39566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39567. }
  39568. m.SetBlockList(v)
  39569. return nil
  39570. case whatsapp.FieldGroupBlockList:
  39571. v, ok := value.([]string)
  39572. if !ok {
  39573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39574. }
  39575. m.SetGroupBlockList(v)
  39576. return nil
  39577. }
  39578. return fmt.Errorf("unknown Whatsapp field %s", name)
  39579. }
  39580. // AddedFields returns all numeric fields that were incremented/decremented during
  39581. // this mutation.
  39582. func (m *WhatsappMutation) AddedFields() []string {
  39583. var fields []string
  39584. if m.addstatus != nil {
  39585. fields = append(fields, whatsapp.FieldStatus)
  39586. }
  39587. if m.addphone_status != nil {
  39588. fields = append(fields, whatsapp.FieldPhoneStatus)
  39589. }
  39590. if m.addorganization_id != nil {
  39591. fields = append(fields, whatsapp.FieldOrganizationID)
  39592. }
  39593. return fields
  39594. }
  39595. // AddedField returns the numeric value that was incremented/decremented on a field
  39596. // with the given name. The second boolean return value indicates that this field
  39597. // was not set, or was not defined in the schema.
  39598. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  39599. switch name {
  39600. case whatsapp.FieldStatus:
  39601. return m.AddedStatus()
  39602. case whatsapp.FieldPhoneStatus:
  39603. return m.AddedPhoneStatus()
  39604. case whatsapp.FieldOrganizationID:
  39605. return m.AddedOrganizationID()
  39606. }
  39607. return nil, false
  39608. }
  39609. // AddField adds the value to the field with the given name. It returns an error if
  39610. // the field is not defined in the schema, or if the type mismatched the field
  39611. // type.
  39612. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  39613. switch name {
  39614. case whatsapp.FieldStatus:
  39615. v, ok := value.(int8)
  39616. if !ok {
  39617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39618. }
  39619. m.AddStatus(v)
  39620. return nil
  39621. case whatsapp.FieldPhoneStatus:
  39622. v, ok := value.(int8)
  39623. if !ok {
  39624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39625. }
  39626. m.AddPhoneStatus(v)
  39627. return nil
  39628. case whatsapp.FieldOrganizationID:
  39629. v, ok := value.(int64)
  39630. if !ok {
  39631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39632. }
  39633. m.AddOrganizationID(v)
  39634. return nil
  39635. }
  39636. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  39637. }
  39638. // ClearedFields returns all nullable fields that were cleared during this
  39639. // mutation.
  39640. func (m *WhatsappMutation) ClearedFields() []string {
  39641. var fields []string
  39642. if m.FieldCleared(whatsapp.FieldStatus) {
  39643. fields = append(fields, whatsapp.FieldStatus)
  39644. }
  39645. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  39646. fields = append(fields, whatsapp.FieldDeletedAt)
  39647. }
  39648. if m.FieldCleared(whatsapp.FieldWaID) {
  39649. fields = append(fields, whatsapp.FieldWaID)
  39650. }
  39651. if m.FieldCleared(whatsapp.FieldWaName) {
  39652. fields = append(fields, whatsapp.FieldWaName)
  39653. }
  39654. if m.FieldCleared(whatsapp.FieldCallback) {
  39655. fields = append(fields, whatsapp.FieldCallback)
  39656. }
  39657. if m.FieldCleared(whatsapp.FieldAccount) {
  39658. fields = append(fields, whatsapp.FieldAccount)
  39659. }
  39660. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  39661. fields = append(fields, whatsapp.FieldOrganizationID)
  39662. }
  39663. if m.FieldCleared(whatsapp.FieldAPIBase) {
  39664. fields = append(fields, whatsapp.FieldAPIBase)
  39665. }
  39666. if m.FieldCleared(whatsapp.FieldAPIKey) {
  39667. fields = append(fields, whatsapp.FieldAPIKey)
  39668. }
  39669. if m.FieldCleared(whatsapp.FieldAllowList) {
  39670. fields = append(fields, whatsapp.FieldAllowList)
  39671. }
  39672. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  39673. fields = append(fields, whatsapp.FieldGroupAllowList)
  39674. }
  39675. if m.FieldCleared(whatsapp.FieldBlockList) {
  39676. fields = append(fields, whatsapp.FieldBlockList)
  39677. }
  39678. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  39679. fields = append(fields, whatsapp.FieldGroupBlockList)
  39680. }
  39681. return fields
  39682. }
  39683. // FieldCleared returns a boolean indicating if a field with the given name was
  39684. // cleared in this mutation.
  39685. func (m *WhatsappMutation) FieldCleared(name string) bool {
  39686. _, ok := m.clearedFields[name]
  39687. return ok
  39688. }
  39689. // ClearField clears the value of the field with the given name. It returns an
  39690. // error if the field is not defined in the schema.
  39691. func (m *WhatsappMutation) ClearField(name string) error {
  39692. switch name {
  39693. case whatsapp.FieldStatus:
  39694. m.ClearStatus()
  39695. return nil
  39696. case whatsapp.FieldDeletedAt:
  39697. m.ClearDeletedAt()
  39698. return nil
  39699. case whatsapp.FieldWaID:
  39700. m.ClearWaID()
  39701. return nil
  39702. case whatsapp.FieldWaName:
  39703. m.ClearWaName()
  39704. return nil
  39705. case whatsapp.FieldCallback:
  39706. m.ClearCallback()
  39707. return nil
  39708. case whatsapp.FieldAccount:
  39709. m.ClearAccount()
  39710. return nil
  39711. case whatsapp.FieldOrganizationID:
  39712. m.ClearOrganizationID()
  39713. return nil
  39714. case whatsapp.FieldAPIBase:
  39715. m.ClearAPIBase()
  39716. return nil
  39717. case whatsapp.FieldAPIKey:
  39718. m.ClearAPIKey()
  39719. return nil
  39720. case whatsapp.FieldAllowList:
  39721. m.ClearAllowList()
  39722. return nil
  39723. case whatsapp.FieldGroupAllowList:
  39724. m.ClearGroupAllowList()
  39725. return nil
  39726. case whatsapp.FieldBlockList:
  39727. m.ClearBlockList()
  39728. return nil
  39729. case whatsapp.FieldGroupBlockList:
  39730. m.ClearGroupBlockList()
  39731. return nil
  39732. }
  39733. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  39734. }
  39735. // ResetField resets all changes in the mutation for the field with the given name.
  39736. // It returns an error if the field is not defined in the schema.
  39737. func (m *WhatsappMutation) ResetField(name string) error {
  39738. switch name {
  39739. case whatsapp.FieldCreatedAt:
  39740. m.ResetCreatedAt()
  39741. return nil
  39742. case whatsapp.FieldUpdatedAt:
  39743. m.ResetUpdatedAt()
  39744. return nil
  39745. case whatsapp.FieldStatus:
  39746. m.ResetStatus()
  39747. return nil
  39748. case whatsapp.FieldDeletedAt:
  39749. m.ResetDeletedAt()
  39750. return nil
  39751. case whatsapp.FieldWaID:
  39752. m.ResetWaID()
  39753. return nil
  39754. case whatsapp.FieldWaName:
  39755. m.ResetWaName()
  39756. return nil
  39757. case whatsapp.FieldCallback:
  39758. m.ResetCallback()
  39759. return nil
  39760. case whatsapp.FieldAgentID:
  39761. m.ResetAgentID()
  39762. return nil
  39763. case whatsapp.FieldAccount:
  39764. m.ResetAccount()
  39765. return nil
  39766. case whatsapp.FieldCc:
  39767. m.ResetCc()
  39768. return nil
  39769. case whatsapp.FieldPhone:
  39770. m.ResetPhone()
  39771. return nil
  39772. case whatsapp.FieldCcPhone:
  39773. m.ResetCcPhone()
  39774. return nil
  39775. case whatsapp.FieldPhoneName:
  39776. m.ResetPhoneName()
  39777. return nil
  39778. case whatsapp.FieldPhoneStatus:
  39779. m.ResetPhoneStatus()
  39780. return nil
  39781. case whatsapp.FieldOrganizationID:
  39782. m.ResetOrganizationID()
  39783. return nil
  39784. case whatsapp.FieldAPIBase:
  39785. m.ResetAPIBase()
  39786. return nil
  39787. case whatsapp.FieldAPIKey:
  39788. m.ResetAPIKey()
  39789. return nil
  39790. case whatsapp.FieldAllowList:
  39791. m.ResetAllowList()
  39792. return nil
  39793. case whatsapp.FieldGroupAllowList:
  39794. m.ResetGroupAllowList()
  39795. return nil
  39796. case whatsapp.FieldBlockList:
  39797. m.ResetBlockList()
  39798. return nil
  39799. case whatsapp.FieldGroupBlockList:
  39800. m.ResetGroupBlockList()
  39801. return nil
  39802. }
  39803. return fmt.Errorf("unknown Whatsapp field %s", name)
  39804. }
  39805. // AddedEdges returns all edge names that were set/added in this mutation.
  39806. func (m *WhatsappMutation) AddedEdges() []string {
  39807. edges := make([]string, 0, 1)
  39808. if m.agent != nil {
  39809. edges = append(edges, whatsapp.EdgeAgent)
  39810. }
  39811. return edges
  39812. }
  39813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39814. // name in this mutation.
  39815. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  39816. switch name {
  39817. case whatsapp.EdgeAgent:
  39818. if id := m.agent; id != nil {
  39819. return []ent.Value{*id}
  39820. }
  39821. }
  39822. return nil
  39823. }
  39824. // RemovedEdges returns all edge names that were removed in this mutation.
  39825. func (m *WhatsappMutation) RemovedEdges() []string {
  39826. edges := make([]string, 0, 1)
  39827. return edges
  39828. }
  39829. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39830. // the given name in this mutation.
  39831. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  39832. return nil
  39833. }
  39834. // ClearedEdges returns all edge names that were cleared in this mutation.
  39835. func (m *WhatsappMutation) ClearedEdges() []string {
  39836. edges := make([]string, 0, 1)
  39837. if m.clearedagent {
  39838. edges = append(edges, whatsapp.EdgeAgent)
  39839. }
  39840. return edges
  39841. }
  39842. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39843. // was cleared in this mutation.
  39844. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  39845. switch name {
  39846. case whatsapp.EdgeAgent:
  39847. return m.clearedagent
  39848. }
  39849. return false
  39850. }
  39851. // ClearEdge clears the value of the edge with the given name. It returns an error
  39852. // if that edge is not defined in the schema.
  39853. func (m *WhatsappMutation) ClearEdge(name string) error {
  39854. switch name {
  39855. case whatsapp.EdgeAgent:
  39856. m.ClearAgent()
  39857. return nil
  39858. }
  39859. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  39860. }
  39861. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39862. // It returns an error if the edge is not defined in the schema.
  39863. func (m *WhatsappMutation) ResetEdge(name string) error {
  39864. switch name {
  39865. case whatsapp.EdgeAgent:
  39866. m.ResetAgent()
  39867. return nil
  39868. }
  39869. return fmt.Errorf("unknown Whatsapp edge %s", name)
  39870. }
  39871. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  39872. type WhatsappChannelMutation struct {
  39873. config
  39874. op Op
  39875. typ string
  39876. id *uint64
  39877. created_at *time.Time
  39878. updated_at *time.Time
  39879. status *uint8
  39880. addstatus *int8
  39881. deleted_at *time.Time
  39882. ak *string
  39883. sk *string
  39884. wa_id *string
  39885. wa_name *string
  39886. waba_id *uint64
  39887. addwaba_id *int64
  39888. business_id *uint64
  39889. addbusiness_id *int64
  39890. organization_id *uint64
  39891. addorganization_id *int64
  39892. verify_account *string
  39893. clearedFields map[string]struct{}
  39894. done bool
  39895. oldValue func(context.Context) (*WhatsappChannel, error)
  39896. predicates []predicate.WhatsappChannel
  39897. }
  39898. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  39899. // whatsappchannelOption allows management of the mutation configuration using functional options.
  39900. type whatsappchannelOption func(*WhatsappChannelMutation)
  39901. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  39902. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  39903. m := &WhatsappChannelMutation{
  39904. config: c,
  39905. op: op,
  39906. typ: TypeWhatsappChannel,
  39907. clearedFields: make(map[string]struct{}),
  39908. }
  39909. for _, opt := range opts {
  39910. opt(m)
  39911. }
  39912. return m
  39913. }
  39914. // withWhatsappChannelID sets the ID field of the mutation.
  39915. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  39916. return func(m *WhatsappChannelMutation) {
  39917. var (
  39918. err error
  39919. once sync.Once
  39920. value *WhatsappChannel
  39921. )
  39922. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  39923. once.Do(func() {
  39924. if m.done {
  39925. err = errors.New("querying old values post mutation is not allowed")
  39926. } else {
  39927. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  39928. }
  39929. })
  39930. return value, err
  39931. }
  39932. m.id = &id
  39933. }
  39934. }
  39935. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  39936. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  39937. return func(m *WhatsappChannelMutation) {
  39938. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  39939. return node, nil
  39940. }
  39941. m.id = &node.ID
  39942. }
  39943. }
  39944. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39945. // executed in a transaction (ent.Tx), a transactional client is returned.
  39946. func (m WhatsappChannelMutation) Client() *Client {
  39947. client := &Client{config: m.config}
  39948. client.init()
  39949. return client
  39950. }
  39951. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39952. // it returns an error otherwise.
  39953. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  39954. if _, ok := m.driver.(*txDriver); !ok {
  39955. return nil, errors.New("ent: mutation is not running in a transaction")
  39956. }
  39957. tx := &Tx{config: m.config}
  39958. tx.init()
  39959. return tx, nil
  39960. }
  39961. // SetID sets the value of the id field. Note that this
  39962. // operation is only accepted on creation of WhatsappChannel entities.
  39963. func (m *WhatsappChannelMutation) SetID(id uint64) {
  39964. m.id = &id
  39965. }
  39966. // ID returns the ID value in the mutation. Note that the ID is only available
  39967. // if it was provided to the builder or after it was returned from the database.
  39968. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  39969. if m.id == nil {
  39970. return
  39971. }
  39972. return *m.id, true
  39973. }
  39974. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39975. // That means, if the mutation is applied within a transaction with an isolation level such
  39976. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39977. // or updated by the mutation.
  39978. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  39979. switch {
  39980. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39981. id, exists := m.ID()
  39982. if exists {
  39983. return []uint64{id}, nil
  39984. }
  39985. fallthrough
  39986. case m.op.Is(OpUpdate | OpDelete):
  39987. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  39988. default:
  39989. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39990. }
  39991. }
  39992. // SetCreatedAt sets the "created_at" field.
  39993. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  39994. m.created_at = &t
  39995. }
  39996. // CreatedAt returns the value of the "created_at" field in the mutation.
  39997. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  39998. v := m.created_at
  39999. if v == nil {
  40000. return
  40001. }
  40002. return *v, true
  40003. }
  40004. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  40005. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40007. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40008. if !m.op.Is(OpUpdateOne) {
  40009. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40010. }
  40011. if m.id == nil || m.oldValue == nil {
  40012. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40013. }
  40014. oldValue, err := m.oldValue(ctx)
  40015. if err != nil {
  40016. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40017. }
  40018. return oldValue.CreatedAt, nil
  40019. }
  40020. // ResetCreatedAt resets all changes to the "created_at" field.
  40021. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  40022. m.created_at = nil
  40023. }
  40024. // SetUpdatedAt sets the "updated_at" field.
  40025. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  40026. m.updated_at = &t
  40027. }
  40028. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40029. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  40030. v := m.updated_at
  40031. if v == nil {
  40032. return
  40033. }
  40034. return *v, true
  40035. }
  40036. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  40037. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40039. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40040. if !m.op.Is(OpUpdateOne) {
  40041. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40042. }
  40043. if m.id == nil || m.oldValue == nil {
  40044. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40045. }
  40046. oldValue, err := m.oldValue(ctx)
  40047. if err != nil {
  40048. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40049. }
  40050. return oldValue.UpdatedAt, nil
  40051. }
  40052. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40053. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  40054. m.updated_at = nil
  40055. }
  40056. // SetStatus sets the "status" field.
  40057. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  40058. m.status = &u
  40059. m.addstatus = nil
  40060. }
  40061. // Status returns the value of the "status" field in the mutation.
  40062. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  40063. v := m.status
  40064. if v == nil {
  40065. return
  40066. }
  40067. return *v, true
  40068. }
  40069. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  40070. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40072. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40073. if !m.op.Is(OpUpdateOne) {
  40074. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40075. }
  40076. if m.id == nil || m.oldValue == nil {
  40077. return v, errors.New("OldStatus requires an ID field in the mutation")
  40078. }
  40079. oldValue, err := m.oldValue(ctx)
  40080. if err != nil {
  40081. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40082. }
  40083. return oldValue.Status, nil
  40084. }
  40085. // AddStatus adds u to the "status" field.
  40086. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  40087. if m.addstatus != nil {
  40088. *m.addstatus += u
  40089. } else {
  40090. m.addstatus = &u
  40091. }
  40092. }
  40093. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40094. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  40095. v := m.addstatus
  40096. if v == nil {
  40097. return
  40098. }
  40099. return *v, true
  40100. }
  40101. // ClearStatus clears the value of the "status" field.
  40102. func (m *WhatsappChannelMutation) ClearStatus() {
  40103. m.status = nil
  40104. m.addstatus = nil
  40105. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  40106. }
  40107. // StatusCleared returns if the "status" field was cleared in this mutation.
  40108. func (m *WhatsappChannelMutation) StatusCleared() bool {
  40109. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  40110. return ok
  40111. }
  40112. // ResetStatus resets all changes to the "status" field.
  40113. func (m *WhatsappChannelMutation) ResetStatus() {
  40114. m.status = nil
  40115. m.addstatus = nil
  40116. delete(m.clearedFields, whatsappchannel.FieldStatus)
  40117. }
  40118. // SetDeletedAt sets the "deleted_at" field.
  40119. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  40120. m.deleted_at = &t
  40121. }
  40122. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40123. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  40124. v := m.deleted_at
  40125. if v == nil {
  40126. return
  40127. }
  40128. return *v, true
  40129. }
  40130. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  40131. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40133. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40134. if !m.op.Is(OpUpdateOne) {
  40135. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40136. }
  40137. if m.id == nil || m.oldValue == nil {
  40138. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40139. }
  40140. oldValue, err := m.oldValue(ctx)
  40141. if err != nil {
  40142. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40143. }
  40144. return oldValue.DeletedAt, nil
  40145. }
  40146. // ClearDeletedAt clears the value of the "deleted_at" field.
  40147. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  40148. m.deleted_at = nil
  40149. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  40150. }
  40151. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40152. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  40153. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  40154. return ok
  40155. }
  40156. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40157. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  40158. m.deleted_at = nil
  40159. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  40160. }
  40161. // SetAk sets the "ak" field.
  40162. func (m *WhatsappChannelMutation) SetAk(s string) {
  40163. m.ak = &s
  40164. }
  40165. // Ak returns the value of the "ak" field in the mutation.
  40166. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  40167. v := m.ak
  40168. if v == nil {
  40169. return
  40170. }
  40171. return *v, true
  40172. }
  40173. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  40174. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40176. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  40177. if !m.op.Is(OpUpdateOne) {
  40178. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  40179. }
  40180. if m.id == nil || m.oldValue == nil {
  40181. return v, errors.New("OldAk requires an ID field in the mutation")
  40182. }
  40183. oldValue, err := m.oldValue(ctx)
  40184. if err != nil {
  40185. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  40186. }
  40187. return oldValue.Ak, nil
  40188. }
  40189. // ClearAk clears the value of the "ak" field.
  40190. func (m *WhatsappChannelMutation) ClearAk() {
  40191. m.ak = nil
  40192. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  40193. }
  40194. // AkCleared returns if the "ak" field was cleared in this mutation.
  40195. func (m *WhatsappChannelMutation) AkCleared() bool {
  40196. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  40197. return ok
  40198. }
  40199. // ResetAk resets all changes to the "ak" field.
  40200. func (m *WhatsappChannelMutation) ResetAk() {
  40201. m.ak = nil
  40202. delete(m.clearedFields, whatsappchannel.FieldAk)
  40203. }
  40204. // SetSk sets the "sk" field.
  40205. func (m *WhatsappChannelMutation) SetSk(s string) {
  40206. m.sk = &s
  40207. }
  40208. // Sk returns the value of the "sk" field in the mutation.
  40209. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  40210. v := m.sk
  40211. if v == nil {
  40212. return
  40213. }
  40214. return *v, true
  40215. }
  40216. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  40217. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40219. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  40220. if !m.op.Is(OpUpdateOne) {
  40221. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  40222. }
  40223. if m.id == nil || m.oldValue == nil {
  40224. return v, errors.New("OldSk requires an ID field in the mutation")
  40225. }
  40226. oldValue, err := m.oldValue(ctx)
  40227. if err != nil {
  40228. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  40229. }
  40230. return oldValue.Sk, nil
  40231. }
  40232. // ResetSk resets all changes to the "sk" field.
  40233. func (m *WhatsappChannelMutation) ResetSk() {
  40234. m.sk = nil
  40235. }
  40236. // SetWaID sets the "wa_id" field.
  40237. func (m *WhatsappChannelMutation) SetWaID(s string) {
  40238. m.wa_id = &s
  40239. }
  40240. // WaID returns the value of the "wa_id" field in the mutation.
  40241. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  40242. v := m.wa_id
  40243. if v == nil {
  40244. return
  40245. }
  40246. return *v, true
  40247. }
  40248. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  40249. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40251. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  40252. if !m.op.Is(OpUpdateOne) {
  40253. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  40254. }
  40255. if m.id == nil || m.oldValue == nil {
  40256. return v, errors.New("OldWaID requires an ID field in the mutation")
  40257. }
  40258. oldValue, err := m.oldValue(ctx)
  40259. if err != nil {
  40260. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  40261. }
  40262. return oldValue.WaID, nil
  40263. }
  40264. // ClearWaID clears the value of the "wa_id" field.
  40265. func (m *WhatsappChannelMutation) ClearWaID() {
  40266. m.wa_id = nil
  40267. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  40268. }
  40269. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  40270. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  40271. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  40272. return ok
  40273. }
  40274. // ResetWaID resets all changes to the "wa_id" field.
  40275. func (m *WhatsappChannelMutation) ResetWaID() {
  40276. m.wa_id = nil
  40277. delete(m.clearedFields, whatsappchannel.FieldWaID)
  40278. }
  40279. // SetWaName sets the "wa_name" field.
  40280. func (m *WhatsappChannelMutation) SetWaName(s string) {
  40281. m.wa_name = &s
  40282. }
  40283. // WaName returns the value of the "wa_name" field in the mutation.
  40284. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  40285. v := m.wa_name
  40286. if v == nil {
  40287. return
  40288. }
  40289. return *v, true
  40290. }
  40291. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  40292. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40294. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  40295. if !m.op.Is(OpUpdateOne) {
  40296. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40297. }
  40298. if m.id == nil || m.oldValue == nil {
  40299. return v, errors.New("OldWaName requires an ID field in the mutation")
  40300. }
  40301. oldValue, err := m.oldValue(ctx)
  40302. if err != nil {
  40303. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40304. }
  40305. return oldValue.WaName, nil
  40306. }
  40307. // ClearWaName clears the value of the "wa_name" field.
  40308. func (m *WhatsappChannelMutation) ClearWaName() {
  40309. m.wa_name = nil
  40310. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  40311. }
  40312. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40313. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  40314. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  40315. return ok
  40316. }
  40317. // ResetWaName resets all changes to the "wa_name" field.
  40318. func (m *WhatsappChannelMutation) ResetWaName() {
  40319. m.wa_name = nil
  40320. delete(m.clearedFields, whatsappchannel.FieldWaName)
  40321. }
  40322. // SetWabaID sets the "waba_id" field.
  40323. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  40324. m.waba_id = &u
  40325. m.addwaba_id = nil
  40326. }
  40327. // WabaID returns the value of the "waba_id" field in the mutation.
  40328. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  40329. v := m.waba_id
  40330. if v == nil {
  40331. return
  40332. }
  40333. return *v, true
  40334. }
  40335. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  40336. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40338. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  40339. if !m.op.Is(OpUpdateOne) {
  40340. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  40341. }
  40342. if m.id == nil || m.oldValue == nil {
  40343. return v, errors.New("OldWabaID requires an ID field in the mutation")
  40344. }
  40345. oldValue, err := m.oldValue(ctx)
  40346. if err != nil {
  40347. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  40348. }
  40349. return oldValue.WabaID, nil
  40350. }
  40351. // AddWabaID adds u to the "waba_id" field.
  40352. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  40353. if m.addwaba_id != nil {
  40354. *m.addwaba_id += u
  40355. } else {
  40356. m.addwaba_id = &u
  40357. }
  40358. }
  40359. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  40360. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  40361. v := m.addwaba_id
  40362. if v == nil {
  40363. return
  40364. }
  40365. return *v, true
  40366. }
  40367. // ResetWabaID resets all changes to the "waba_id" field.
  40368. func (m *WhatsappChannelMutation) ResetWabaID() {
  40369. m.waba_id = nil
  40370. m.addwaba_id = nil
  40371. }
  40372. // SetBusinessID sets the "business_id" field.
  40373. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  40374. m.business_id = &u
  40375. m.addbusiness_id = nil
  40376. }
  40377. // BusinessID returns the value of the "business_id" field in the mutation.
  40378. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  40379. v := m.business_id
  40380. if v == nil {
  40381. return
  40382. }
  40383. return *v, true
  40384. }
  40385. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  40386. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40388. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  40389. if !m.op.Is(OpUpdateOne) {
  40390. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  40391. }
  40392. if m.id == nil || m.oldValue == nil {
  40393. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  40394. }
  40395. oldValue, err := m.oldValue(ctx)
  40396. if err != nil {
  40397. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  40398. }
  40399. return oldValue.BusinessID, nil
  40400. }
  40401. // AddBusinessID adds u to the "business_id" field.
  40402. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  40403. if m.addbusiness_id != nil {
  40404. *m.addbusiness_id += u
  40405. } else {
  40406. m.addbusiness_id = &u
  40407. }
  40408. }
  40409. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  40410. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  40411. v := m.addbusiness_id
  40412. if v == nil {
  40413. return
  40414. }
  40415. return *v, true
  40416. }
  40417. // ResetBusinessID resets all changes to the "business_id" field.
  40418. func (m *WhatsappChannelMutation) ResetBusinessID() {
  40419. m.business_id = nil
  40420. m.addbusiness_id = nil
  40421. }
  40422. // SetOrganizationID sets the "organization_id" field.
  40423. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  40424. m.organization_id = &u
  40425. m.addorganization_id = nil
  40426. }
  40427. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40428. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  40429. v := m.organization_id
  40430. if v == nil {
  40431. return
  40432. }
  40433. return *v, true
  40434. }
  40435. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  40436. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40438. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40439. if !m.op.Is(OpUpdateOne) {
  40440. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40441. }
  40442. if m.id == nil || m.oldValue == nil {
  40443. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40444. }
  40445. oldValue, err := m.oldValue(ctx)
  40446. if err != nil {
  40447. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40448. }
  40449. return oldValue.OrganizationID, nil
  40450. }
  40451. // AddOrganizationID adds u to the "organization_id" field.
  40452. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  40453. if m.addorganization_id != nil {
  40454. *m.addorganization_id += u
  40455. } else {
  40456. m.addorganization_id = &u
  40457. }
  40458. }
  40459. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40460. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  40461. v := m.addorganization_id
  40462. if v == nil {
  40463. return
  40464. }
  40465. return *v, true
  40466. }
  40467. // ClearOrganizationID clears the value of the "organization_id" field.
  40468. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  40469. m.organization_id = nil
  40470. m.addorganization_id = nil
  40471. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  40472. }
  40473. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40474. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  40475. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  40476. return ok
  40477. }
  40478. // ResetOrganizationID resets all changes to the "organization_id" field.
  40479. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  40480. m.organization_id = nil
  40481. m.addorganization_id = nil
  40482. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  40483. }
  40484. // SetVerifyAccount sets the "verify_account" field.
  40485. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  40486. m.verify_account = &s
  40487. }
  40488. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  40489. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  40490. v := m.verify_account
  40491. if v == nil {
  40492. return
  40493. }
  40494. return *v, true
  40495. }
  40496. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  40497. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  40498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40499. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  40500. if !m.op.Is(OpUpdateOne) {
  40501. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  40502. }
  40503. if m.id == nil || m.oldValue == nil {
  40504. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  40505. }
  40506. oldValue, err := m.oldValue(ctx)
  40507. if err != nil {
  40508. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  40509. }
  40510. return oldValue.VerifyAccount, nil
  40511. }
  40512. // ResetVerifyAccount resets all changes to the "verify_account" field.
  40513. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  40514. m.verify_account = nil
  40515. }
  40516. // Where appends a list predicates to the WhatsappChannelMutation builder.
  40517. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  40518. m.predicates = append(m.predicates, ps...)
  40519. }
  40520. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  40521. // users can use type-assertion to append predicates that do not depend on any generated package.
  40522. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  40523. p := make([]predicate.WhatsappChannel, len(ps))
  40524. for i := range ps {
  40525. p[i] = ps[i]
  40526. }
  40527. m.Where(p...)
  40528. }
  40529. // Op returns the operation name.
  40530. func (m *WhatsappChannelMutation) Op() Op {
  40531. return m.op
  40532. }
  40533. // SetOp allows setting the mutation operation.
  40534. func (m *WhatsappChannelMutation) SetOp(op Op) {
  40535. m.op = op
  40536. }
  40537. // Type returns the node type of this mutation (WhatsappChannel).
  40538. func (m *WhatsappChannelMutation) Type() string {
  40539. return m.typ
  40540. }
  40541. // Fields returns all fields that were changed during this mutation. Note that in
  40542. // order to get all numeric fields that were incremented/decremented, call
  40543. // AddedFields().
  40544. func (m *WhatsappChannelMutation) Fields() []string {
  40545. fields := make([]string, 0, 12)
  40546. if m.created_at != nil {
  40547. fields = append(fields, whatsappchannel.FieldCreatedAt)
  40548. }
  40549. if m.updated_at != nil {
  40550. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  40551. }
  40552. if m.status != nil {
  40553. fields = append(fields, whatsappchannel.FieldStatus)
  40554. }
  40555. if m.deleted_at != nil {
  40556. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40557. }
  40558. if m.ak != nil {
  40559. fields = append(fields, whatsappchannel.FieldAk)
  40560. }
  40561. if m.sk != nil {
  40562. fields = append(fields, whatsappchannel.FieldSk)
  40563. }
  40564. if m.wa_id != nil {
  40565. fields = append(fields, whatsappchannel.FieldWaID)
  40566. }
  40567. if m.wa_name != nil {
  40568. fields = append(fields, whatsappchannel.FieldWaName)
  40569. }
  40570. if m.waba_id != nil {
  40571. fields = append(fields, whatsappchannel.FieldWabaID)
  40572. }
  40573. if m.business_id != nil {
  40574. fields = append(fields, whatsappchannel.FieldBusinessID)
  40575. }
  40576. if m.organization_id != nil {
  40577. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40578. }
  40579. if m.verify_account != nil {
  40580. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  40581. }
  40582. return fields
  40583. }
  40584. // Field returns the value of a field with the given name. The second boolean
  40585. // return value indicates that this field was not set, or was not defined in the
  40586. // schema.
  40587. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  40588. switch name {
  40589. case whatsappchannel.FieldCreatedAt:
  40590. return m.CreatedAt()
  40591. case whatsappchannel.FieldUpdatedAt:
  40592. return m.UpdatedAt()
  40593. case whatsappchannel.FieldStatus:
  40594. return m.Status()
  40595. case whatsappchannel.FieldDeletedAt:
  40596. return m.DeletedAt()
  40597. case whatsappchannel.FieldAk:
  40598. return m.Ak()
  40599. case whatsappchannel.FieldSk:
  40600. return m.Sk()
  40601. case whatsappchannel.FieldWaID:
  40602. return m.WaID()
  40603. case whatsappchannel.FieldWaName:
  40604. return m.WaName()
  40605. case whatsappchannel.FieldWabaID:
  40606. return m.WabaID()
  40607. case whatsappchannel.FieldBusinessID:
  40608. return m.BusinessID()
  40609. case whatsappchannel.FieldOrganizationID:
  40610. return m.OrganizationID()
  40611. case whatsappchannel.FieldVerifyAccount:
  40612. return m.VerifyAccount()
  40613. }
  40614. return nil, false
  40615. }
  40616. // OldField returns the old value of the field from the database. An error is
  40617. // returned if the mutation operation is not UpdateOne, or the query to the
  40618. // database failed.
  40619. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40620. switch name {
  40621. case whatsappchannel.FieldCreatedAt:
  40622. return m.OldCreatedAt(ctx)
  40623. case whatsappchannel.FieldUpdatedAt:
  40624. return m.OldUpdatedAt(ctx)
  40625. case whatsappchannel.FieldStatus:
  40626. return m.OldStatus(ctx)
  40627. case whatsappchannel.FieldDeletedAt:
  40628. return m.OldDeletedAt(ctx)
  40629. case whatsappchannel.FieldAk:
  40630. return m.OldAk(ctx)
  40631. case whatsappchannel.FieldSk:
  40632. return m.OldSk(ctx)
  40633. case whatsappchannel.FieldWaID:
  40634. return m.OldWaID(ctx)
  40635. case whatsappchannel.FieldWaName:
  40636. return m.OldWaName(ctx)
  40637. case whatsappchannel.FieldWabaID:
  40638. return m.OldWabaID(ctx)
  40639. case whatsappchannel.FieldBusinessID:
  40640. return m.OldBusinessID(ctx)
  40641. case whatsappchannel.FieldOrganizationID:
  40642. return m.OldOrganizationID(ctx)
  40643. case whatsappchannel.FieldVerifyAccount:
  40644. return m.OldVerifyAccount(ctx)
  40645. }
  40646. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  40647. }
  40648. // SetField sets the value of a field with the given name. It returns an error if
  40649. // the field is not defined in the schema, or if the type mismatched the field
  40650. // type.
  40651. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  40652. switch name {
  40653. case whatsappchannel.FieldCreatedAt:
  40654. v, ok := value.(time.Time)
  40655. if !ok {
  40656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40657. }
  40658. m.SetCreatedAt(v)
  40659. return nil
  40660. case whatsappchannel.FieldUpdatedAt:
  40661. v, ok := value.(time.Time)
  40662. if !ok {
  40663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40664. }
  40665. m.SetUpdatedAt(v)
  40666. return nil
  40667. case whatsappchannel.FieldStatus:
  40668. v, ok := value.(uint8)
  40669. if !ok {
  40670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40671. }
  40672. m.SetStatus(v)
  40673. return nil
  40674. case whatsappchannel.FieldDeletedAt:
  40675. v, ok := value.(time.Time)
  40676. if !ok {
  40677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40678. }
  40679. m.SetDeletedAt(v)
  40680. return nil
  40681. case whatsappchannel.FieldAk:
  40682. v, ok := value.(string)
  40683. if !ok {
  40684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40685. }
  40686. m.SetAk(v)
  40687. return nil
  40688. case whatsappchannel.FieldSk:
  40689. v, ok := value.(string)
  40690. if !ok {
  40691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40692. }
  40693. m.SetSk(v)
  40694. return nil
  40695. case whatsappchannel.FieldWaID:
  40696. v, ok := value.(string)
  40697. if !ok {
  40698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40699. }
  40700. m.SetWaID(v)
  40701. return nil
  40702. case whatsappchannel.FieldWaName:
  40703. v, ok := value.(string)
  40704. if !ok {
  40705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40706. }
  40707. m.SetWaName(v)
  40708. return nil
  40709. case whatsappchannel.FieldWabaID:
  40710. v, ok := value.(uint64)
  40711. if !ok {
  40712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40713. }
  40714. m.SetWabaID(v)
  40715. return nil
  40716. case whatsappchannel.FieldBusinessID:
  40717. v, ok := value.(uint64)
  40718. if !ok {
  40719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40720. }
  40721. m.SetBusinessID(v)
  40722. return nil
  40723. case whatsappchannel.FieldOrganizationID:
  40724. v, ok := value.(uint64)
  40725. if !ok {
  40726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40727. }
  40728. m.SetOrganizationID(v)
  40729. return nil
  40730. case whatsappchannel.FieldVerifyAccount:
  40731. v, ok := value.(string)
  40732. if !ok {
  40733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40734. }
  40735. m.SetVerifyAccount(v)
  40736. return nil
  40737. }
  40738. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40739. }
  40740. // AddedFields returns all numeric fields that were incremented/decremented during
  40741. // this mutation.
  40742. func (m *WhatsappChannelMutation) AddedFields() []string {
  40743. var fields []string
  40744. if m.addstatus != nil {
  40745. fields = append(fields, whatsappchannel.FieldStatus)
  40746. }
  40747. if m.addwaba_id != nil {
  40748. fields = append(fields, whatsappchannel.FieldWabaID)
  40749. }
  40750. if m.addbusiness_id != nil {
  40751. fields = append(fields, whatsappchannel.FieldBusinessID)
  40752. }
  40753. if m.addorganization_id != nil {
  40754. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40755. }
  40756. return fields
  40757. }
  40758. // AddedField returns the numeric value that was incremented/decremented on a field
  40759. // with the given name. The second boolean return value indicates that this field
  40760. // was not set, or was not defined in the schema.
  40761. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  40762. switch name {
  40763. case whatsappchannel.FieldStatus:
  40764. return m.AddedStatus()
  40765. case whatsappchannel.FieldWabaID:
  40766. return m.AddedWabaID()
  40767. case whatsappchannel.FieldBusinessID:
  40768. return m.AddedBusinessID()
  40769. case whatsappchannel.FieldOrganizationID:
  40770. return m.AddedOrganizationID()
  40771. }
  40772. return nil, false
  40773. }
  40774. // AddField adds the value to the field with the given name. It returns an error if
  40775. // the field is not defined in the schema, or if the type mismatched the field
  40776. // type.
  40777. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  40778. switch name {
  40779. case whatsappchannel.FieldStatus:
  40780. v, ok := value.(int8)
  40781. if !ok {
  40782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40783. }
  40784. m.AddStatus(v)
  40785. return nil
  40786. case whatsappchannel.FieldWabaID:
  40787. v, ok := value.(int64)
  40788. if !ok {
  40789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40790. }
  40791. m.AddWabaID(v)
  40792. return nil
  40793. case whatsappchannel.FieldBusinessID:
  40794. v, ok := value.(int64)
  40795. if !ok {
  40796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40797. }
  40798. m.AddBusinessID(v)
  40799. return nil
  40800. case whatsappchannel.FieldOrganizationID:
  40801. v, ok := value.(int64)
  40802. if !ok {
  40803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40804. }
  40805. m.AddOrganizationID(v)
  40806. return nil
  40807. }
  40808. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  40809. }
  40810. // ClearedFields returns all nullable fields that were cleared during this
  40811. // mutation.
  40812. func (m *WhatsappChannelMutation) ClearedFields() []string {
  40813. var fields []string
  40814. if m.FieldCleared(whatsappchannel.FieldStatus) {
  40815. fields = append(fields, whatsappchannel.FieldStatus)
  40816. }
  40817. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  40818. fields = append(fields, whatsappchannel.FieldDeletedAt)
  40819. }
  40820. if m.FieldCleared(whatsappchannel.FieldAk) {
  40821. fields = append(fields, whatsappchannel.FieldAk)
  40822. }
  40823. if m.FieldCleared(whatsappchannel.FieldWaID) {
  40824. fields = append(fields, whatsappchannel.FieldWaID)
  40825. }
  40826. if m.FieldCleared(whatsappchannel.FieldWaName) {
  40827. fields = append(fields, whatsappchannel.FieldWaName)
  40828. }
  40829. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  40830. fields = append(fields, whatsappchannel.FieldOrganizationID)
  40831. }
  40832. return fields
  40833. }
  40834. // FieldCleared returns a boolean indicating if a field with the given name was
  40835. // cleared in this mutation.
  40836. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  40837. _, ok := m.clearedFields[name]
  40838. return ok
  40839. }
  40840. // ClearField clears the value of the field with the given name. It returns an
  40841. // error if the field is not defined in the schema.
  40842. func (m *WhatsappChannelMutation) ClearField(name string) error {
  40843. switch name {
  40844. case whatsappchannel.FieldStatus:
  40845. m.ClearStatus()
  40846. return nil
  40847. case whatsappchannel.FieldDeletedAt:
  40848. m.ClearDeletedAt()
  40849. return nil
  40850. case whatsappchannel.FieldAk:
  40851. m.ClearAk()
  40852. return nil
  40853. case whatsappchannel.FieldWaID:
  40854. m.ClearWaID()
  40855. return nil
  40856. case whatsappchannel.FieldWaName:
  40857. m.ClearWaName()
  40858. return nil
  40859. case whatsappchannel.FieldOrganizationID:
  40860. m.ClearOrganizationID()
  40861. return nil
  40862. }
  40863. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  40864. }
  40865. // ResetField resets all changes in the mutation for the field with the given name.
  40866. // It returns an error if the field is not defined in the schema.
  40867. func (m *WhatsappChannelMutation) ResetField(name string) error {
  40868. switch name {
  40869. case whatsappchannel.FieldCreatedAt:
  40870. m.ResetCreatedAt()
  40871. return nil
  40872. case whatsappchannel.FieldUpdatedAt:
  40873. m.ResetUpdatedAt()
  40874. return nil
  40875. case whatsappchannel.FieldStatus:
  40876. m.ResetStatus()
  40877. return nil
  40878. case whatsappchannel.FieldDeletedAt:
  40879. m.ResetDeletedAt()
  40880. return nil
  40881. case whatsappchannel.FieldAk:
  40882. m.ResetAk()
  40883. return nil
  40884. case whatsappchannel.FieldSk:
  40885. m.ResetSk()
  40886. return nil
  40887. case whatsappchannel.FieldWaID:
  40888. m.ResetWaID()
  40889. return nil
  40890. case whatsappchannel.FieldWaName:
  40891. m.ResetWaName()
  40892. return nil
  40893. case whatsappchannel.FieldWabaID:
  40894. m.ResetWabaID()
  40895. return nil
  40896. case whatsappchannel.FieldBusinessID:
  40897. m.ResetBusinessID()
  40898. return nil
  40899. case whatsappchannel.FieldOrganizationID:
  40900. m.ResetOrganizationID()
  40901. return nil
  40902. case whatsappchannel.FieldVerifyAccount:
  40903. m.ResetVerifyAccount()
  40904. return nil
  40905. }
  40906. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  40907. }
  40908. // AddedEdges returns all edge names that were set/added in this mutation.
  40909. func (m *WhatsappChannelMutation) AddedEdges() []string {
  40910. edges := make([]string, 0, 0)
  40911. return edges
  40912. }
  40913. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40914. // name in this mutation.
  40915. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  40916. return nil
  40917. }
  40918. // RemovedEdges returns all edge names that were removed in this mutation.
  40919. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  40920. edges := make([]string, 0, 0)
  40921. return edges
  40922. }
  40923. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40924. // the given name in this mutation.
  40925. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  40926. return nil
  40927. }
  40928. // ClearedEdges returns all edge names that were cleared in this mutation.
  40929. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  40930. edges := make([]string, 0, 0)
  40931. return edges
  40932. }
  40933. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40934. // was cleared in this mutation.
  40935. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  40936. return false
  40937. }
  40938. // ClearEdge clears the value of the edge with the given name. It returns an error
  40939. // if that edge is not defined in the schema.
  40940. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  40941. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  40942. }
  40943. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40944. // It returns an error if the edge is not defined in the schema.
  40945. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  40946. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  40947. }
  40948. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  40949. type WorkExperienceMutation struct {
  40950. config
  40951. op Op
  40952. typ string
  40953. id *uint64
  40954. created_at *time.Time
  40955. updated_at *time.Time
  40956. deleted_at *time.Time
  40957. start_date *time.Time
  40958. end_date *time.Time
  40959. company *string
  40960. experience *string
  40961. organization_id *uint64
  40962. addorganization_id *int64
  40963. clearedFields map[string]struct{}
  40964. employee *uint64
  40965. clearedemployee bool
  40966. done bool
  40967. oldValue func(context.Context) (*WorkExperience, error)
  40968. predicates []predicate.WorkExperience
  40969. }
  40970. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  40971. // workexperienceOption allows management of the mutation configuration using functional options.
  40972. type workexperienceOption func(*WorkExperienceMutation)
  40973. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  40974. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  40975. m := &WorkExperienceMutation{
  40976. config: c,
  40977. op: op,
  40978. typ: TypeWorkExperience,
  40979. clearedFields: make(map[string]struct{}),
  40980. }
  40981. for _, opt := range opts {
  40982. opt(m)
  40983. }
  40984. return m
  40985. }
  40986. // withWorkExperienceID sets the ID field of the mutation.
  40987. func withWorkExperienceID(id uint64) workexperienceOption {
  40988. return func(m *WorkExperienceMutation) {
  40989. var (
  40990. err error
  40991. once sync.Once
  40992. value *WorkExperience
  40993. )
  40994. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  40995. once.Do(func() {
  40996. if m.done {
  40997. err = errors.New("querying old values post mutation is not allowed")
  40998. } else {
  40999. value, err = m.Client().WorkExperience.Get(ctx, id)
  41000. }
  41001. })
  41002. return value, err
  41003. }
  41004. m.id = &id
  41005. }
  41006. }
  41007. // withWorkExperience sets the old WorkExperience of the mutation.
  41008. func withWorkExperience(node *WorkExperience) workexperienceOption {
  41009. return func(m *WorkExperienceMutation) {
  41010. m.oldValue = func(context.Context) (*WorkExperience, error) {
  41011. return node, nil
  41012. }
  41013. m.id = &node.ID
  41014. }
  41015. }
  41016. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41017. // executed in a transaction (ent.Tx), a transactional client is returned.
  41018. func (m WorkExperienceMutation) Client() *Client {
  41019. client := &Client{config: m.config}
  41020. client.init()
  41021. return client
  41022. }
  41023. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41024. // it returns an error otherwise.
  41025. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  41026. if _, ok := m.driver.(*txDriver); !ok {
  41027. return nil, errors.New("ent: mutation is not running in a transaction")
  41028. }
  41029. tx := &Tx{config: m.config}
  41030. tx.init()
  41031. return tx, nil
  41032. }
  41033. // SetID sets the value of the id field. Note that this
  41034. // operation is only accepted on creation of WorkExperience entities.
  41035. func (m *WorkExperienceMutation) SetID(id uint64) {
  41036. m.id = &id
  41037. }
  41038. // ID returns the ID value in the mutation. Note that the ID is only available
  41039. // if it was provided to the builder or after it was returned from the database.
  41040. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  41041. if m.id == nil {
  41042. return
  41043. }
  41044. return *m.id, true
  41045. }
  41046. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41047. // That means, if the mutation is applied within a transaction with an isolation level such
  41048. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41049. // or updated by the mutation.
  41050. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  41051. switch {
  41052. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41053. id, exists := m.ID()
  41054. if exists {
  41055. return []uint64{id}, nil
  41056. }
  41057. fallthrough
  41058. case m.op.Is(OpUpdate | OpDelete):
  41059. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  41060. default:
  41061. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41062. }
  41063. }
  41064. // SetCreatedAt sets the "created_at" field.
  41065. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  41066. m.created_at = &t
  41067. }
  41068. // CreatedAt returns the value of the "created_at" field in the mutation.
  41069. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  41070. v := m.created_at
  41071. if v == nil {
  41072. return
  41073. }
  41074. return *v, true
  41075. }
  41076. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  41077. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41079. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41080. if !m.op.Is(OpUpdateOne) {
  41081. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41082. }
  41083. if m.id == nil || m.oldValue == nil {
  41084. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41085. }
  41086. oldValue, err := m.oldValue(ctx)
  41087. if err != nil {
  41088. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41089. }
  41090. return oldValue.CreatedAt, nil
  41091. }
  41092. // ResetCreatedAt resets all changes to the "created_at" field.
  41093. func (m *WorkExperienceMutation) ResetCreatedAt() {
  41094. m.created_at = nil
  41095. }
  41096. // SetUpdatedAt sets the "updated_at" field.
  41097. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  41098. m.updated_at = &t
  41099. }
  41100. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41101. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  41102. v := m.updated_at
  41103. if v == nil {
  41104. return
  41105. }
  41106. return *v, true
  41107. }
  41108. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  41109. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41111. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41112. if !m.op.Is(OpUpdateOne) {
  41113. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41114. }
  41115. if m.id == nil || m.oldValue == nil {
  41116. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41117. }
  41118. oldValue, err := m.oldValue(ctx)
  41119. if err != nil {
  41120. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41121. }
  41122. return oldValue.UpdatedAt, nil
  41123. }
  41124. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41125. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  41126. m.updated_at = nil
  41127. }
  41128. // SetDeletedAt sets the "deleted_at" field.
  41129. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  41130. m.deleted_at = &t
  41131. }
  41132. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41133. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  41134. v := m.deleted_at
  41135. if v == nil {
  41136. return
  41137. }
  41138. return *v, true
  41139. }
  41140. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  41141. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41143. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41144. if !m.op.Is(OpUpdateOne) {
  41145. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41146. }
  41147. if m.id == nil || m.oldValue == nil {
  41148. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41149. }
  41150. oldValue, err := m.oldValue(ctx)
  41151. if err != nil {
  41152. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41153. }
  41154. return oldValue.DeletedAt, nil
  41155. }
  41156. // ClearDeletedAt clears the value of the "deleted_at" field.
  41157. func (m *WorkExperienceMutation) ClearDeletedAt() {
  41158. m.deleted_at = nil
  41159. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  41160. }
  41161. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41162. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  41163. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  41164. return ok
  41165. }
  41166. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41167. func (m *WorkExperienceMutation) ResetDeletedAt() {
  41168. m.deleted_at = nil
  41169. delete(m.clearedFields, workexperience.FieldDeletedAt)
  41170. }
  41171. // SetEmployeeID sets the "employee_id" field.
  41172. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  41173. m.employee = &u
  41174. }
  41175. // EmployeeID returns the value of the "employee_id" field in the mutation.
  41176. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  41177. v := m.employee
  41178. if v == nil {
  41179. return
  41180. }
  41181. return *v, true
  41182. }
  41183. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  41184. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41186. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  41187. if !m.op.Is(OpUpdateOne) {
  41188. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  41189. }
  41190. if m.id == nil || m.oldValue == nil {
  41191. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  41192. }
  41193. oldValue, err := m.oldValue(ctx)
  41194. if err != nil {
  41195. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  41196. }
  41197. return oldValue.EmployeeID, nil
  41198. }
  41199. // ResetEmployeeID resets all changes to the "employee_id" field.
  41200. func (m *WorkExperienceMutation) ResetEmployeeID() {
  41201. m.employee = nil
  41202. }
  41203. // SetStartDate sets the "start_date" field.
  41204. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  41205. m.start_date = &t
  41206. }
  41207. // StartDate returns the value of the "start_date" field in the mutation.
  41208. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  41209. v := m.start_date
  41210. if v == nil {
  41211. return
  41212. }
  41213. return *v, true
  41214. }
  41215. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  41216. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41218. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  41219. if !m.op.Is(OpUpdateOne) {
  41220. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  41221. }
  41222. if m.id == nil || m.oldValue == nil {
  41223. return v, errors.New("OldStartDate requires an ID field in the mutation")
  41224. }
  41225. oldValue, err := m.oldValue(ctx)
  41226. if err != nil {
  41227. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  41228. }
  41229. return oldValue.StartDate, nil
  41230. }
  41231. // ResetStartDate resets all changes to the "start_date" field.
  41232. func (m *WorkExperienceMutation) ResetStartDate() {
  41233. m.start_date = nil
  41234. }
  41235. // SetEndDate sets the "end_date" field.
  41236. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  41237. m.end_date = &t
  41238. }
  41239. // EndDate returns the value of the "end_date" field in the mutation.
  41240. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  41241. v := m.end_date
  41242. if v == nil {
  41243. return
  41244. }
  41245. return *v, true
  41246. }
  41247. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  41248. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41250. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  41251. if !m.op.Is(OpUpdateOne) {
  41252. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  41253. }
  41254. if m.id == nil || m.oldValue == nil {
  41255. return v, errors.New("OldEndDate requires an ID field in the mutation")
  41256. }
  41257. oldValue, err := m.oldValue(ctx)
  41258. if err != nil {
  41259. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  41260. }
  41261. return oldValue.EndDate, nil
  41262. }
  41263. // ResetEndDate resets all changes to the "end_date" field.
  41264. func (m *WorkExperienceMutation) ResetEndDate() {
  41265. m.end_date = nil
  41266. }
  41267. // SetCompany sets the "company" field.
  41268. func (m *WorkExperienceMutation) SetCompany(s string) {
  41269. m.company = &s
  41270. }
  41271. // Company returns the value of the "company" field in the mutation.
  41272. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  41273. v := m.company
  41274. if v == nil {
  41275. return
  41276. }
  41277. return *v, true
  41278. }
  41279. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  41280. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41282. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  41283. if !m.op.Is(OpUpdateOne) {
  41284. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  41285. }
  41286. if m.id == nil || m.oldValue == nil {
  41287. return v, errors.New("OldCompany requires an ID field in the mutation")
  41288. }
  41289. oldValue, err := m.oldValue(ctx)
  41290. if err != nil {
  41291. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  41292. }
  41293. return oldValue.Company, nil
  41294. }
  41295. // ResetCompany resets all changes to the "company" field.
  41296. func (m *WorkExperienceMutation) ResetCompany() {
  41297. m.company = nil
  41298. }
  41299. // SetExperience sets the "experience" field.
  41300. func (m *WorkExperienceMutation) SetExperience(s string) {
  41301. m.experience = &s
  41302. }
  41303. // Experience returns the value of the "experience" field in the mutation.
  41304. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  41305. v := m.experience
  41306. if v == nil {
  41307. return
  41308. }
  41309. return *v, true
  41310. }
  41311. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  41312. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41314. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  41315. if !m.op.Is(OpUpdateOne) {
  41316. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  41317. }
  41318. if m.id == nil || m.oldValue == nil {
  41319. return v, errors.New("OldExperience requires an ID field in the mutation")
  41320. }
  41321. oldValue, err := m.oldValue(ctx)
  41322. if err != nil {
  41323. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  41324. }
  41325. return oldValue.Experience, nil
  41326. }
  41327. // ResetExperience resets all changes to the "experience" field.
  41328. func (m *WorkExperienceMutation) ResetExperience() {
  41329. m.experience = nil
  41330. }
  41331. // SetOrganizationID sets the "organization_id" field.
  41332. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  41333. m.organization_id = &u
  41334. m.addorganization_id = nil
  41335. }
  41336. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41337. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  41338. v := m.organization_id
  41339. if v == nil {
  41340. return
  41341. }
  41342. return *v, true
  41343. }
  41344. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  41345. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  41346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41347. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41348. if !m.op.Is(OpUpdateOne) {
  41349. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41350. }
  41351. if m.id == nil || m.oldValue == nil {
  41352. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41353. }
  41354. oldValue, err := m.oldValue(ctx)
  41355. if err != nil {
  41356. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41357. }
  41358. return oldValue.OrganizationID, nil
  41359. }
  41360. // AddOrganizationID adds u to the "organization_id" field.
  41361. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  41362. if m.addorganization_id != nil {
  41363. *m.addorganization_id += u
  41364. } else {
  41365. m.addorganization_id = &u
  41366. }
  41367. }
  41368. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41369. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  41370. v := m.addorganization_id
  41371. if v == nil {
  41372. return
  41373. }
  41374. return *v, true
  41375. }
  41376. // ResetOrganizationID resets all changes to the "organization_id" field.
  41377. func (m *WorkExperienceMutation) ResetOrganizationID() {
  41378. m.organization_id = nil
  41379. m.addorganization_id = nil
  41380. }
  41381. // ClearEmployee clears the "employee" edge to the Employee entity.
  41382. func (m *WorkExperienceMutation) ClearEmployee() {
  41383. m.clearedemployee = true
  41384. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  41385. }
  41386. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  41387. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  41388. return m.clearedemployee
  41389. }
  41390. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  41391. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41392. // EmployeeID instead. It exists only for internal usage by the builders.
  41393. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  41394. if id := m.employee; id != nil {
  41395. ids = append(ids, *id)
  41396. }
  41397. return
  41398. }
  41399. // ResetEmployee resets all changes to the "employee" edge.
  41400. func (m *WorkExperienceMutation) ResetEmployee() {
  41401. m.employee = nil
  41402. m.clearedemployee = false
  41403. }
  41404. // Where appends a list predicates to the WorkExperienceMutation builder.
  41405. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  41406. m.predicates = append(m.predicates, ps...)
  41407. }
  41408. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  41409. // users can use type-assertion to append predicates that do not depend on any generated package.
  41410. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  41411. p := make([]predicate.WorkExperience, len(ps))
  41412. for i := range ps {
  41413. p[i] = ps[i]
  41414. }
  41415. m.Where(p...)
  41416. }
  41417. // Op returns the operation name.
  41418. func (m *WorkExperienceMutation) Op() Op {
  41419. return m.op
  41420. }
  41421. // SetOp allows setting the mutation operation.
  41422. func (m *WorkExperienceMutation) SetOp(op Op) {
  41423. m.op = op
  41424. }
  41425. // Type returns the node type of this mutation (WorkExperience).
  41426. func (m *WorkExperienceMutation) Type() string {
  41427. return m.typ
  41428. }
  41429. // Fields returns all fields that were changed during this mutation. Note that in
  41430. // order to get all numeric fields that were incremented/decremented, call
  41431. // AddedFields().
  41432. func (m *WorkExperienceMutation) Fields() []string {
  41433. fields := make([]string, 0, 9)
  41434. if m.created_at != nil {
  41435. fields = append(fields, workexperience.FieldCreatedAt)
  41436. }
  41437. if m.updated_at != nil {
  41438. fields = append(fields, workexperience.FieldUpdatedAt)
  41439. }
  41440. if m.deleted_at != nil {
  41441. fields = append(fields, workexperience.FieldDeletedAt)
  41442. }
  41443. if m.employee != nil {
  41444. fields = append(fields, workexperience.FieldEmployeeID)
  41445. }
  41446. if m.start_date != nil {
  41447. fields = append(fields, workexperience.FieldStartDate)
  41448. }
  41449. if m.end_date != nil {
  41450. fields = append(fields, workexperience.FieldEndDate)
  41451. }
  41452. if m.company != nil {
  41453. fields = append(fields, workexperience.FieldCompany)
  41454. }
  41455. if m.experience != nil {
  41456. fields = append(fields, workexperience.FieldExperience)
  41457. }
  41458. if m.organization_id != nil {
  41459. fields = append(fields, workexperience.FieldOrganizationID)
  41460. }
  41461. return fields
  41462. }
  41463. // Field returns the value of a field with the given name. The second boolean
  41464. // return value indicates that this field was not set, or was not defined in the
  41465. // schema.
  41466. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  41467. switch name {
  41468. case workexperience.FieldCreatedAt:
  41469. return m.CreatedAt()
  41470. case workexperience.FieldUpdatedAt:
  41471. return m.UpdatedAt()
  41472. case workexperience.FieldDeletedAt:
  41473. return m.DeletedAt()
  41474. case workexperience.FieldEmployeeID:
  41475. return m.EmployeeID()
  41476. case workexperience.FieldStartDate:
  41477. return m.StartDate()
  41478. case workexperience.FieldEndDate:
  41479. return m.EndDate()
  41480. case workexperience.FieldCompany:
  41481. return m.Company()
  41482. case workexperience.FieldExperience:
  41483. return m.Experience()
  41484. case workexperience.FieldOrganizationID:
  41485. return m.OrganizationID()
  41486. }
  41487. return nil, false
  41488. }
  41489. // OldField returns the old value of the field from the database. An error is
  41490. // returned if the mutation operation is not UpdateOne, or the query to the
  41491. // database failed.
  41492. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41493. switch name {
  41494. case workexperience.FieldCreatedAt:
  41495. return m.OldCreatedAt(ctx)
  41496. case workexperience.FieldUpdatedAt:
  41497. return m.OldUpdatedAt(ctx)
  41498. case workexperience.FieldDeletedAt:
  41499. return m.OldDeletedAt(ctx)
  41500. case workexperience.FieldEmployeeID:
  41501. return m.OldEmployeeID(ctx)
  41502. case workexperience.FieldStartDate:
  41503. return m.OldStartDate(ctx)
  41504. case workexperience.FieldEndDate:
  41505. return m.OldEndDate(ctx)
  41506. case workexperience.FieldCompany:
  41507. return m.OldCompany(ctx)
  41508. case workexperience.FieldExperience:
  41509. return m.OldExperience(ctx)
  41510. case workexperience.FieldOrganizationID:
  41511. return m.OldOrganizationID(ctx)
  41512. }
  41513. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  41514. }
  41515. // SetField sets the value of a field with the given name. It returns an error if
  41516. // the field is not defined in the schema, or if the type mismatched the field
  41517. // type.
  41518. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  41519. switch name {
  41520. case workexperience.FieldCreatedAt:
  41521. v, ok := value.(time.Time)
  41522. if !ok {
  41523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41524. }
  41525. m.SetCreatedAt(v)
  41526. return nil
  41527. case workexperience.FieldUpdatedAt:
  41528. v, ok := value.(time.Time)
  41529. if !ok {
  41530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41531. }
  41532. m.SetUpdatedAt(v)
  41533. return nil
  41534. case workexperience.FieldDeletedAt:
  41535. v, ok := value.(time.Time)
  41536. if !ok {
  41537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41538. }
  41539. m.SetDeletedAt(v)
  41540. return nil
  41541. case workexperience.FieldEmployeeID:
  41542. v, ok := value.(uint64)
  41543. if !ok {
  41544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41545. }
  41546. m.SetEmployeeID(v)
  41547. return nil
  41548. case workexperience.FieldStartDate:
  41549. v, ok := value.(time.Time)
  41550. if !ok {
  41551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41552. }
  41553. m.SetStartDate(v)
  41554. return nil
  41555. case workexperience.FieldEndDate:
  41556. v, ok := value.(time.Time)
  41557. if !ok {
  41558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41559. }
  41560. m.SetEndDate(v)
  41561. return nil
  41562. case workexperience.FieldCompany:
  41563. v, ok := value.(string)
  41564. if !ok {
  41565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41566. }
  41567. m.SetCompany(v)
  41568. return nil
  41569. case workexperience.FieldExperience:
  41570. v, ok := value.(string)
  41571. if !ok {
  41572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41573. }
  41574. m.SetExperience(v)
  41575. return nil
  41576. case workexperience.FieldOrganizationID:
  41577. v, ok := value.(uint64)
  41578. if !ok {
  41579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41580. }
  41581. m.SetOrganizationID(v)
  41582. return nil
  41583. }
  41584. return fmt.Errorf("unknown WorkExperience field %s", name)
  41585. }
  41586. // AddedFields returns all numeric fields that were incremented/decremented during
  41587. // this mutation.
  41588. func (m *WorkExperienceMutation) AddedFields() []string {
  41589. var fields []string
  41590. if m.addorganization_id != nil {
  41591. fields = append(fields, workexperience.FieldOrganizationID)
  41592. }
  41593. return fields
  41594. }
  41595. // AddedField returns the numeric value that was incremented/decremented on a field
  41596. // with the given name. The second boolean return value indicates that this field
  41597. // was not set, or was not defined in the schema.
  41598. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  41599. switch name {
  41600. case workexperience.FieldOrganizationID:
  41601. return m.AddedOrganizationID()
  41602. }
  41603. return nil, false
  41604. }
  41605. // AddField adds the value to the field with the given name. It returns an error if
  41606. // the field is not defined in the schema, or if the type mismatched the field
  41607. // type.
  41608. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  41609. switch name {
  41610. case workexperience.FieldOrganizationID:
  41611. v, ok := value.(int64)
  41612. if !ok {
  41613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41614. }
  41615. m.AddOrganizationID(v)
  41616. return nil
  41617. }
  41618. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  41619. }
  41620. // ClearedFields returns all nullable fields that were cleared during this
  41621. // mutation.
  41622. func (m *WorkExperienceMutation) ClearedFields() []string {
  41623. var fields []string
  41624. if m.FieldCleared(workexperience.FieldDeletedAt) {
  41625. fields = append(fields, workexperience.FieldDeletedAt)
  41626. }
  41627. return fields
  41628. }
  41629. // FieldCleared returns a boolean indicating if a field with the given name was
  41630. // cleared in this mutation.
  41631. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  41632. _, ok := m.clearedFields[name]
  41633. return ok
  41634. }
  41635. // ClearField clears the value of the field with the given name. It returns an
  41636. // error if the field is not defined in the schema.
  41637. func (m *WorkExperienceMutation) ClearField(name string) error {
  41638. switch name {
  41639. case workexperience.FieldDeletedAt:
  41640. m.ClearDeletedAt()
  41641. return nil
  41642. }
  41643. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  41644. }
  41645. // ResetField resets all changes in the mutation for the field with the given name.
  41646. // It returns an error if the field is not defined in the schema.
  41647. func (m *WorkExperienceMutation) ResetField(name string) error {
  41648. switch name {
  41649. case workexperience.FieldCreatedAt:
  41650. m.ResetCreatedAt()
  41651. return nil
  41652. case workexperience.FieldUpdatedAt:
  41653. m.ResetUpdatedAt()
  41654. return nil
  41655. case workexperience.FieldDeletedAt:
  41656. m.ResetDeletedAt()
  41657. return nil
  41658. case workexperience.FieldEmployeeID:
  41659. m.ResetEmployeeID()
  41660. return nil
  41661. case workexperience.FieldStartDate:
  41662. m.ResetStartDate()
  41663. return nil
  41664. case workexperience.FieldEndDate:
  41665. m.ResetEndDate()
  41666. return nil
  41667. case workexperience.FieldCompany:
  41668. m.ResetCompany()
  41669. return nil
  41670. case workexperience.FieldExperience:
  41671. m.ResetExperience()
  41672. return nil
  41673. case workexperience.FieldOrganizationID:
  41674. m.ResetOrganizationID()
  41675. return nil
  41676. }
  41677. return fmt.Errorf("unknown WorkExperience field %s", name)
  41678. }
  41679. // AddedEdges returns all edge names that were set/added in this mutation.
  41680. func (m *WorkExperienceMutation) AddedEdges() []string {
  41681. edges := make([]string, 0, 1)
  41682. if m.employee != nil {
  41683. edges = append(edges, workexperience.EdgeEmployee)
  41684. }
  41685. return edges
  41686. }
  41687. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41688. // name in this mutation.
  41689. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  41690. switch name {
  41691. case workexperience.EdgeEmployee:
  41692. if id := m.employee; id != nil {
  41693. return []ent.Value{*id}
  41694. }
  41695. }
  41696. return nil
  41697. }
  41698. // RemovedEdges returns all edge names that were removed in this mutation.
  41699. func (m *WorkExperienceMutation) RemovedEdges() []string {
  41700. edges := make([]string, 0, 1)
  41701. return edges
  41702. }
  41703. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41704. // the given name in this mutation.
  41705. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  41706. return nil
  41707. }
  41708. // ClearedEdges returns all edge names that were cleared in this mutation.
  41709. func (m *WorkExperienceMutation) ClearedEdges() []string {
  41710. edges := make([]string, 0, 1)
  41711. if m.clearedemployee {
  41712. edges = append(edges, workexperience.EdgeEmployee)
  41713. }
  41714. return edges
  41715. }
  41716. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41717. // was cleared in this mutation.
  41718. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  41719. switch name {
  41720. case workexperience.EdgeEmployee:
  41721. return m.clearedemployee
  41722. }
  41723. return false
  41724. }
  41725. // ClearEdge clears the value of the edge with the given name. It returns an error
  41726. // if that edge is not defined in the schema.
  41727. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  41728. switch name {
  41729. case workexperience.EdgeEmployee:
  41730. m.ClearEmployee()
  41731. return nil
  41732. }
  41733. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  41734. }
  41735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41736. // It returns an error if the edge is not defined in the schema.
  41737. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  41738. switch name {
  41739. case workexperience.EdgeEmployee:
  41740. m.ResetEmployee()
  41741. return nil
  41742. }
  41743. return fmt.Errorf("unknown WorkExperience edge %s", name)
  41744. }
  41745. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  41746. type WpChatroomMutation struct {
  41747. config
  41748. op Op
  41749. typ string
  41750. id *uint64
  41751. created_at *time.Time
  41752. updated_at *time.Time
  41753. status *uint8
  41754. addstatus *int8
  41755. wx_wxid *string
  41756. chatroom_id *string
  41757. nickname *string
  41758. owner *string
  41759. avatar *string
  41760. member_list *[]string
  41761. appendmember_list []string
  41762. clearedFields map[string]struct{}
  41763. done bool
  41764. oldValue func(context.Context) (*WpChatroom, error)
  41765. predicates []predicate.WpChatroom
  41766. }
  41767. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  41768. // wpchatroomOption allows management of the mutation configuration using functional options.
  41769. type wpchatroomOption func(*WpChatroomMutation)
  41770. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  41771. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  41772. m := &WpChatroomMutation{
  41773. config: c,
  41774. op: op,
  41775. typ: TypeWpChatroom,
  41776. clearedFields: make(map[string]struct{}),
  41777. }
  41778. for _, opt := range opts {
  41779. opt(m)
  41780. }
  41781. return m
  41782. }
  41783. // withWpChatroomID sets the ID field of the mutation.
  41784. func withWpChatroomID(id uint64) wpchatroomOption {
  41785. return func(m *WpChatroomMutation) {
  41786. var (
  41787. err error
  41788. once sync.Once
  41789. value *WpChatroom
  41790. )
  41791. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  41792. once.Do(func() {
  41793. if m.done {
  41794. err = errors.New("querying old values post mutation is not allowed")
  41795. } else {
  41796. value, err = m.Client().WpChatroom.Get(ctx, id)
  41797. }
  41798. })
  41799. return value, err
  41800. }
  41801. m.id = &id
  41802. }
  41803. }
  41804. // withWpChatroom sets the old WpChatroom of the mutation.
  41805. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  41806. return func(m *WpChatroomMutation) {
  41807. m.oldValue = func(context.Context) (*WpChatroom, error) {
  41808. return node, nil
  41809. }
  41810. m.id = &node.ID
  41811. }
  41812. }
  41813. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41814. // executed in a transaction (ent.Tx), a transactional client is returned.
  41815. func (m WpChatroomMutation) Client() *Client {
  41816. client := &Client{config: m.config}
  41817. client.init()
  41818. return client
  41819. }
  41820. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41821. // it returns an error otherwise.
  41822. func (m WpChatroomMutation) Tx() (*Tx, error) {
  41823. if _, ok := m.driver.(*txDriver); !ok {
  41824. return nil, errors.New("ent: mutation is not running in a transaction")
  41825. }
  41826. tx := &Tx{config: m.config}
  41827. tx.init()
  41828. return tx, nil
  41829. }
  41830. // SetID sets the value of the id field. Note that this
  41831. // operation is only accepted on creation of WpChatroom entities.
  41832. func (m *WpChatroomMutation) SetID(id uint64) {
  41833. m.id = &id
  41834. }
  41835. // ID returns the ID value in the mutation. Note that the ID is only available
  41836. // if it was provided to the builder or after it was returned from the database.
  41837. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  41838. if m.id == nil {
  41839. return
  41840. }
  41841. return *m.id, true
  41842. }
  41843. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41844. // That means, if the mutation is applied within a transaction with an isolation level such
  41845. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41846. // or updated by the mutation.
  41847. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  41848. switch {
  41849. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41850. id, exists := m.ID()
  41851. if exists {
  41852. return []uint64{id}, nil
  41853. }
  41854. fallthrough
  41855. case m.op.Is(OpUpdate | OpDelete):
  41856. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  41857. default:
  41858. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41859. }
  41860. }
  41861. // SetCreatedAt sets the "created_at" field.
  41862. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  41863. m.created_at = &t
  41864. }
  41865. // CreatedAt returns the value of the "created_at" field in the mutation.
  41866. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  41867. v := m.created_at
  41868. if v == nil {
  41869. return
  41870. }
  41871. return *v, true
  41872. }
  41873. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  41874. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41876. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41877. if !m.op.Is(OpUpdateOne) {
  41878. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41879. }
  41880. if m.id == nil || m.oldValue == nil {
  41881. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41882. }
  41883. oldValue, err := m.oldValue(ctx)
  41884. if err != nil {
  41885. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41886. }
  41887. return oldValue.CreatedAt, nil
  41888. }
  41889. // ResetCreatedAt resets all changes to the "created_at" field.
  41890. func (m *WpChatroomMutation) ResetCreatedAt() {
  41891. m.created_at = nil
  41892. }
  41893. // SetUpdatedAt sets the "updated_at" field.
  41894. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  41895. m.updated_at = &t
  41896. }
  41897. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41898. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  41899. v := m.updated_at
  41900. if v == nil {
  41901. return
  41902. }
  41903. return *v, true
  41904. }
  41905. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  41906. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41908. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41909. if !m.op.Is(OpUpdateOne) {
  41910. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41911. }
  41912. if m.id == nil || m.oldValue == nil {
  41913. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41914. }
  41915. oldValue, err := m.oldValue(ctx)
  41916. if err != nil {
  41917. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41918. }
  41919. return oldValue.UpdatedAt, nil
  41920. }
  41921. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41922. func (m *WpChatroomMutation) ResetUpdatedAt() {
  41923. m.updated_at = nil
  41924. }
  41925. // SetStatus sets the "status" field.
  41926. func (m *WpChatroomMutation) SetStatus(u uint8) {
  41927. m.status = &u
  41928. m.addstatus = nil
  41929. }
  41930. // Status returns the value of the "status" field in the mutation.
  41931. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  41932. v := m.status
  41933. if v == nil {
  41934. return
  41935. }
  41936. return *v, true
  41937. }
  41938. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  41939. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41941. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41942. if !m.op.Is(OpUpdateOne) {
  41943. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41944. }
  41945. if m.id == nil || m.oldValue == nil {
  41946. return v, errors.New("OldStatus requires an ID field in the mutation")
  41947. }
  41948. oldValue, err := m.oldValue(ctx)
  41949. if err != nil {
  41950. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41951. }
  41952. return oldValue.Status, nil
  41953. }
  41954. // AddStatus adds u to the "status" field.
  41955. func (m *WpChatroomMutation) AddStatus(u int8) {
  41956. if m.addstatus != nil {
  41957. *m.addstatus += u
  41958. } else {
  41959. m.addstatus = &u
  41960. }
  41961. }
  41962. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41963. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  41964. v := m.addstatus
  41965. if v == nil {
  41966. return
  41967. }
  41968. return *v, true
  41969. }
  41970. // ClearStatus clears the value of the "status" field.
  41971. func (m *WpChatroomMutation) ClearStatus() {
  41972. m.status = nil
  41973. m.addstatus = nil
  41974. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  41975. }
  41976. // StatusCleared returns if the "status" field was cleared in this mutation.
  41977. func (m *WpChatroomMutation) StatusCleared() bool {
  41978. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  41979. return ok
  41980. }
  41981. // ResetStatus resets all changes to the "status" field.
  41982. func (m *WpChatroomMutation) ResetStatus() {
  41983. m.status = nil
  41984. m.addstatus = nil
  41985. delete(m.clearedFields, wpchatroom.FieldStatus)
  41986. }
  41987. // SetWxWxid sets the "wx_wxid" field.
  41988. func (m *WpChatroomMutation) SetWxWxid(s string) {
  41989. m.wx_wxid = &s
  41990. }
  41991. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41992. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  41993. v := m.wx_wxid
  41994. if v == nil {
  41995. return
  41996. }
  41997. return *v, true
  41998. }
  41999. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  42000. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42002. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42003. if !m.op.Is(OpUpdateOne) {
  42004. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42005. }
  42006. if m.id == nil || m.oldValue == nil {
  42007. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42008. }
  42009. oldValue, err := m.oldValue(ctx)
  42010. if err != nil {
  42011. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42012. }
  42013. return oldValue.WxWxid, nil
  42014. }
  42015. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42016. func (m *WpChatroomMutation) ResetWxWxid() {
  42017. m.wx_wxid = nil
  42018. }
  42019. // SetChatroomID sets the "chatroom_id" field.
  42020. func (m *WpChatroomMutation) SetChatroomID(s string) {
  42021. m.chatroom_id = &s
  42022. }
  42023. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  42024. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  42025. v := m.chatroom_id
  42026. if v == nil {
  42027. return
  42028. }
  42029. return *v, true
  42030. }
  42031. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  42032. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42034. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  42035. if !m.op.Is(OpUpdateOne) {
  42036. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  42037. }
  42038. if m.id == nil || m.oldValue == nil {
  42039. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  42040. }
  42041. oldValue, err := m.oldValue(ctx)
  42042. if err != nil {
  42043. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  42044. }
  42045. return oldValue.ChatroomID, nil
  42046. }
  42047. // ResetChatroomID resets all changes to the "chatroom_id" field.
  42048. func (m *WpChatroomMutation) ResetChatroomID() {
  42049. m.chatroom_id = nil
  42050. }
  42051. // SetNickname sets the "nickname" field.
  42052. func (m *WpChatroomMutation) SetNickname(s string) {
  42053. m.nickname = &s
  42054. }
  42055. // Nickname returns the value of the "nickname" field in the mutation.
  42056. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  42057. v := m.nickname
  42058. if v == nil {
  42059. return
  42060. }
  42061. return *v, true
  42062. }
  42063. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  42064. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42066. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  42067. if !m.op.Is(OpUpdateOne) {
  42068. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42069. }
  42070. if m.id == nil || m.oldValue == nil {
  42071. return v, errors.New("OldNickname requires an ID field in the mutation")
  42072. }
  42073. oldValue, err := m.oldValue(ctx)
  42074. if err != nil {
  42075. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42076. }
  42077. return oldValue.Nickname, nil
  42078. }
  42079. // ResetNickname resets all changes to the "nickname" field.
  42080. func (m *WpChatroomMutation) ResetNickname() {
  42081. m.nickname = nil
  42082. }
  42083. // SetOwner sets the "owner" field.
  42084. func (m *WpChatroomMutation) SetOwner(s string) {
  42085. m.owner = &s
  42086. }
  42087. // Owner returns the value of the "owner" field in the mutation.
  42088. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  42089. v := m.owner
  42090. if v == nil {
  42091. return
  42092. }
  42093. return *v, true
  42094. }
  42095. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  42096. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42098. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  42099. if !m.op.Is(OpUpdateOne) {
  42100. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  42101. }
  42102. if m.id == nil || m.oldValue == nil {
  42103. return v, errors.New("OldOwner requires an ID field in the mutation")
  42104. }
  42105. oldValue, err := m.oldValue(ctx)
  42106. if err != nil {
  42107. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  42108. }
  42109. return oldValue.Owner, nil
  42110. }
  42111. // ResetOwner resets all changes to the "owner" field.
  42112. func (m *WpChatroomMutation) ResetOwner() {
  42113. m.owner = nil
  42114. }
  42115. // SetAvatar sets the "avatar" field.
  42116. func (m *WpChatroomMutation) SetAvatar(s string) {
  42117. m.avatar = &s
  42118. }
  42119. // Avatar returns the value of the "avatar" field in the mutation.
  42120. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  42121. v := m.avatar
  42122. if v == nil {
  42123. return
  42124. }
  42125. return *v, true
  42126. }
  42127. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  42128. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42130. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42131. if !m.op.Is(OpUpdateOne) {
  42132. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42133. }
  42134. if m.id == nil || m.oldValue == nil {
  42135. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42136. }
  42137. oldValue, err := m.oldValue(ctx)
  42138. if err != nil {
  42139. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42140. }
  42141. return oldValue.Avatar, nil
  42142. }
  42143. // ResetAvatar resets all changes to the "avatar" field.
  42144. func (m *WpChatroomMutation) ResetAvatar() {
  42145. m.avatar = nil
  42146. }
  42147. // SetMemberList sets the "member_list" field.
  42148. func (m *WpChatroomMutation) SetMemberList(s []string) {
  42149. m.member_list = &s
  42150. m.appendmember_list = nil
  42151. }
  42152. // MemberList returns the value of the "member_list" field in the mutation.
  42153. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  42154. v := m.member_list
  42155. if v == nil {
  42156. return
  42157. }
  42158. return *v, true
  42159. }
  42160. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  42161. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  42162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42163. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  42164. if !m.op.Is(OpUpdateOne) {
  42165. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  42166. }
  42167. if m.id == nil || m.oldValue == nil {
  42168. return v, errors.New("OldMemberList requires an ID field in the mutation")
  42169. }
  42170. oldValue, err := m.oldValue(ctx)
  42171. if err != nil {
  42172. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  42173. }
  42174. return oldValue.MemberList, nil
  42175. }
  42176. // AppendMemberList adds s to the "member_list" field.
  42177. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  42178. m.appendmember_list = append(m.appendmember_list, s...)
  42179. }
  42180. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  42181. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  42182. if len(m.appendmember_list) == 0 {
  42183. return nil, false
  42184. }
  42185. return m.appendmember_list, true
  42186. }
  42187. // ResetMemberList resets all changes to the "member_list" field.
  42188. func (m *WpChatroomMutation) ResetMemberList() {
  42189. m.member_list = nil
  42190. m.appendmember_list = nil
  42191. }
  42192. // Where appends a list predicates to the WpChatroomMutation builder.
  42193. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  42194. m.predicates = append(m.predicates, ps...)
  42195. }
  42196. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  42197. // users can use type-assertion to append predicates that do not depend on any generated package.
  42198. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  42199. p := make([]predicate.WpChatroom, len(ps))
  42200. for i := range ps {
  42201. p[i] = ps[i]
  42202. }
  42203. m.Where(p...)
  42204. }
  42205. // Op returns the operation name.
  42206. func (m *WpChatroomMutation) Op() Op {
  42207. return m.op
  42208. }
  42209. // SetOp allows setting the mutation operation.
  42210. func (m *WpChatroomMutation) SetOp(op Op) {
  42211. m.op = op
  42212. }
  42213. // Type returns the node type of this mutation (WpChatroom).
  42214. func (m *WpChatroomMutation) Type() string {
  42215. return m.typ
  42216. }
  42217. // Fields returns all fields that were changed during this mutation. Note that in
  42218. // order to get all numeric fields that were incremented/decremented, call
  42219. // AddedFields().
  42220. func (m *WpChatroomMutation) Fields() []string {
  42221. fields := make([]string, 0, 9)
  42222. if m.created_at != nil {
  42223. fields = append(fields, wpchatroom.FieldCreatedAt)
  42224. }
  42225. if m.updated_at != nil {
  42226. fields = append(fields, wpchatroom.FieldUpdatedAt)
  42227. }
  42228. if m.status != nil {
  42229. fields = append(fields, wpchatroom.FieldStatus)
  42230. }
  42231. if m.wx_wxid != nil {
  42232. fields = append(fields, wpchatroom.FieldWxWxid)
  42233. }
  42234. if m.chatroom_id != nil {
  42235. fields = append(fields, wpchatroom.FieldChatroomID)
  42236. }
  42237. if m.nickname != nil {
  42238. fields = append(fields, wpchatroom.FieldNickname)
  42239. }
  42240. if m.owner != nil {
  42241. fields = append(fields, wpchatroom.FieldOwner)
  42242. }
  42243. if m.avatar != nil {
  42244. fields = append(fields, wpchatroom.FieldAvatar)
  42245. }
  42246. if m.member_list != nil {
  42247. fields = append(fields, wpchatroom.FieldMemberList)
  42248. }
  42249. return fields
  42250. }
  42251. // Field returns the value of a field with the given name. The second boolean
  42252. // return value indicates that this field was not set, or was not defined in the
  42253. // schema.
  42254. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  42255. switch name {
  42256. case wpchatroom.FieldCreatedAt:
  42257. return m.CreatedAt()
  42258. case wpchatroom.FieldUpdatedAt:
  42259. return m.UpdatedAt()
  42260. case wpchatroom.FieldStatus:
  42261. return m.Status()
  42262. case wpchatroom.FieldWxWxid:
  42263. return m.WxWxid()
  42264. case wpchatroom.FieldChatroomID:
  42265. return m.ChatroomID()
  42266. case wpchatroom.FieldNickname:
  42267. return m.Nickname()
  42268. case wpchatroom.FieldOwner:
  42269. return m.Owner()
  42270. case wpchatroom.FieldAvatar:
  42271. return m.Avatar()
  42272. case wpchatroom.FieldMemberList:
  42273. return m.MemberList()
  42274. }
  42275. return nil, false
  42276. }
  42277. // OldField returns the old value of the field from the database. An error is
  42278. // returned if the mutation operation is not UpdateOne, or the query to the
  42279. // database failed.
  42280. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42281. switch name {
  42282. case wpchatroom.FieldCreatedAt:
  42283. return m.OldCreatedAt(ctx)
  42284. case wpchatroom.FieldUpdatedAt:
  42285. return m.OldUpdatedAt(ctx)
  42286. case wpchatroom.FieldStatus:
  42287. return m.OldStatus(ctx)
  42288. case wpchatroom.FieldWxWxid:
  42289. return m.OldWxWxid(ctx)
  42290. case wpchatroom.FieldChatroomID:
  42291. return m.OldChatroomID(ctx)
  42292. case wpchatroom.FieldNickname:
  42293. return m.OldNickname(ctx)
  42294. case wpchatroom.FieldOwner:
  42295. return m.OldOwner(ctx)
  42296. case wpchatroom.FieldAvatar:
  42297. return m.OldAvatar(ctx)
  42298. case wpchatroom.FieldMemberList:
  42299. return m.OldMemberList(ctx)
  42300. }
  42301. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  42302. }
  42303. // SetField sets the value of a field with the given name. It returns an error if
  42304. // the field is not defined in the schema, or if the type mismatched the field
  42305. // type.
  42306. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  42307. switch name {
  42308. case wpchatroom.FieldCreatedAt:
  42309. v, ok := value.(time.Time)
  42310. if !ok {
  42311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42312. }
  42313. m.SetCreatedAt(v)
  42314. return nil
  42315. case wpchatroom.FieldUpdatedAt:
  42316. v, ok := value.(time.Time)
  42317. if !ok {
  42318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42319. }
  42320. m.SetUpdatedAt(v)
  42321. return nil
  42322. case wpchatroom.FieldStatus:
  42323. v, ok := value.(uint8)
  42324. if !ok {
  42325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42326. }
  42327. m.SetStatus(v)
  42328. return nil
  42329. case wpchatroom.FieldWxWxid:
  42330. v, ok := value.(string)
  42331. if !ok {
  42332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42333. }
  42334. m.SetWxWxid(v)
  42335. return nil
  42336. case wpchatroom.FieldChatroomID:
  42337. v, ok := value.(string)
  42338. if !ok {
  42339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42340. }
  42341. m.SetChatroomID(v)
  42342. return nil
  42343. case wpchatroom.FieldNickname:
  42344. v, ok := value.(string)
  42345. if !ok {
  42346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42347. }
  42348. m.SetNickname(v)
  42349. return nil
  42350. case wpchatroom.FieldOwner:
  42351. v, ok := value.(string)
  42352. if !ok {
  42353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42354. }
  42355. m.SetOwner(v)
  42356. return nil
  42357. case wpchatroom.FieldAvatar:
  42358. v, ok := value.(string)
  42359. if !ok {
  42360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42361. }
  42362. m.SetAvatar(v)
  42363. return nil
  42364. case wpchatroom.FieldMemberList:
  42365. v, ok := value.([]string)
  42366. if !ok {
  42367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42368. }
  42369. m.SetMemberList(v)
  42370. return nil
  42371. }
  42372. return fmt.Errorf("unknown WpChatroom field %s", name)
  42373. }
  42374. // AddedFields returns all numeric fields that were incremented/decremented during
  42375. // this mutation.
  42376. func (m *WpChatroomMutation) AddedFields() []string {
  42377. var fields []string
  42378. if m.addstatus != nil {
  42379. fields = append(fields, wpchatroom.FieldStatus)
  42380. }
  42381. return fields
  42382. }
  42383. // AddedField returns the numeric value that was incremented/decremented on a field
  42384. // with the given name. The second boolean return value indicates that this field
  42385. // was not set, or was not defined in the schema.
  42386. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  42387. switch name {
  42388. case wpchatroom.FieldStatus:
  42389. return m.AddedStatus()
  42390. }
  42391. return nil, false
  42392. }
  42393. // AddField adds the value to the field with the given name. It returns an error if
  42394. // the field is not defined in the schema, or if the type mismatched the field
  42395. // type.
  42396. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  42397. switch name {
  42398. case wpchatroom.FieldStatus:
  42399. v, ok := value.(int8)
  42400. if !ok {
  42401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42402. }
  42403. m.AddStatus(v)
  42404. return nil
  42405. }
  42406. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  42407. }
  42408. // ClearedFields returns all nullable fields that were cleared during this
  42409. // mutation.
  42410. func (m *WpChatroomMutation) ClearedFields() []string {
  42411. var fields []string
  42412. if m.FieldCleared(wpchatroom.FieldStatus) {
  42413. fields = append(fields, wpchatroom.FieldStatus)
  42414. }
  42415. return fields
  42416. }
  42417. // FieldCleared returns a boolean indicating if a field with the given name was
  42418. // cleared in this mutation.
  42419. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  42420. _, ok := m.clearedFields[name]
  42421. return ok
  42422. }
  42423. // ClearField clears the value of the field with the given name. It returns an
  42424. // error if the field is not defined in the schema.
  42425. func (m *WpChatroomMutation) ClearField(name string) error {
  42426. switch name {
  42427. case wpchatroom.FieldStatus:
  42428. m.ClearStatus()
  42429. return nil
  42430. }
  42431. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  42432. }
  42433. // ResetField resets all changes in the mutation for the field with the given name.
  42434. // It returns an error if the field is not defined in the schema.
  42435. func (m *WpChatroomMutation) ResetField(name string) error {
  42436. switch name {
  42437. case wpchatroom.FieldCreatedAt:
  42438. m.ResetCreatedAt()
  42439. return nil
  42440. case wpchatroom.FieldUpdatedAt:
  42441. m.ResetUpdatedAt()
  42442. return nil
  42443. case wpchatroom.FieldStatus:
  42444. m.ResetStatus()
  42445. return nil
  42446. case wpchatroom.FieldWxWxid:
  42447. m.ResetWxWxid()
  42448. return nil
  42449. case wpchatroom.FieldChatroomID:
  42450. m.ResetChatroomID()
  42451. return nil
  42452. case wpchatroom.FieldNickname:
  42453. m.ResetNickname()
  42454. return nil
  42455. case wpchatroom.FieldOwner:
  42456. m.ResetOwner()
  42457. return nil
  42458. case wpchatroom.FieldAvatar:
  42459. m.ResetAvatar()
  42460. return nil
  42461. case wpchatroom.FieldMemberList:
  42462. m.ResetMemberList()
  42463. return nil
  42464. }
  42465. return fmt.Errorf("unknown WpChatroom field %s", name)
  42466. }
  42467. // AddedEdges returns all edge names that were set/added in this mutation.
  42468. func (m *WpChatroomMutation) AddedEdges() []string {
  42469. edges := make([]string, 0, 0)
  42470. return edges
  42471. }
  42472. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42473. // name in this mutation.
  42474. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  42475. return nil
  42476. }
  42477. // RemovedEdges returns all edge names that were removed in this mutation.
  42478. func (m *WpChatroomMutation) RemovedEdges() []string {
  42479. edges := make([]string, 0, 0)
  42480. return edges
  42481. }
  42482. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42483. // the given name in this mutation.
  42484. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  42485. return nil
  42486. }
  42487. // ClearedEdges returns all edge names that were cleared in this mutation.
  42488. func (m *WpChatroomMutation) ClearedEdges() []string {
  42489. edges := make([]string, 0, 0)
  42490. return edges
  42491. }
  42492. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42493. // was cleared in this mutation.
  42494. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  42495. return false
  42496. }
  42497. // ClearEdge clears the value of the edge with the given name. It returns an error
  42498. // if that edge is not defined in the schema.
  42499. func (m *WpChatroomMutation) ClearEdge(name string) error {
  42500. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  42501. }
  42502. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42503. // It returns an error if the edge is not defined in the schema.
  42504. func (m *WpChatroomMutation) ResetEdge(name string) error {
  42505. return fmt.Errorf("unknown WpChatroom edge %s", name)
  42506. }
  42507. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  42508. type WpChatroomMemberMutation struct {
  42509. config
  42510. op Op
  42511. typ string
  42512. id *uint64
  42513. created_at *time.Time
  42514. updated_at *time.Time
  42515. status *uint8
  42516. addstatus *int8
  42517. wx_wxid *string
  42518. wxid *string
  42519. nickname *string
  42520. avatar *string
  42521. clearedFields map[string]struct{}
  42522. done bool
  42523. oldValue func(context.Context) (*WpChatroomMember, error)
  42524. predicates []predicate.WpChatroomMember
  42525. }
  42526. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  42527. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  42528. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  42529. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  42530. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  42531. m := &WpChatroomMemberMutation{
  42532. config: c,
  42533. op: op,
  42534. typ: TypeWpChatroomMember,
  42535. clearedFields: make(map[string]struct{}),
  42536. }
  42537. for _, opt := range opts {
  42538. opt(m)
  42539. }
  42540. return m
  42541. }
  42542. // withWpChatroomMemberID sets the ID field of the mutation.
  42543. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  42544. return func(m *WpChatroomMemberMutation) {
  42545. var (
  42546. err error
  42547. once sync.Once
  42548. value *WpChatroomMember
  42549. )
  42550. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  42551. once.Do(func() {
  42552. if m.done {
  42553. err = errors.New("querying old values post mutation is not allowed")
  42554. } else {
  42555. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  42556. }
  42557. })
  42558. return value, err
  42559. }
  42560. m.id = &id
  42561. }
  42562. }
  42563. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  42564. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  42565. return func(m *WpChatroomMemberMutation) {
  42566. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  42567. return node, nil
  42568. }
  42569. m.id = &node.ID
  42570. }
  42571. }
  42572. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42573. // executed in a transaction (ent.Tx), a transactional client is returned.
  42574. func (m WpChatroomMemberMutation) Client() *Client {
  42575. client := &Client{config: m.config}
  42576. client.init()
  42577. return client
  42578. }
  42579. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42580. // it returns an error otherwise.
  42581. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  42582. if _, ok := m.driver.(*txDriver); !ok {
  42583. return nil, errors.New("ent: mutation is not running in a transaction")
  42584. }
  42585. tx := &Tx{config: m.config}
  42586. tx.init()
  42587. return tx, nil
  42588. }
  42589. // SetID sets the value of the id field. Note that this
  42590. // operation is only accepted on creation of WpChatroomMember entities.
  42591. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  42592. m.id = &id
  42593. }
  42594. // ID returns the ID value in the mutation. Note that the ID is only available
  42595. // if it was provided to the builder or after it was returned from the database.
  42596. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  42597. if m.id == nil {
  42598. return
  42599. }
  42600. return *m.id, true
  42601. }
  42602. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42603. // That means, if the mutation is applied within a transaction with an isolation level such
  42604. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42605. // or updated by the mutation.
  42606. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  42607. switch {
  42608. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42609. id, exists := m.ID()
  42610. if exists {
  42611. return []uint64{id}, nil
  42612. }
  42613. fallthrough
  42614. case m.op.Is(OpUpdate | OpDelete):
  42615. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  42616. default:
  42617. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42618. }
  42619. }
  42620. // SetCreatedAt sets the "created_at" field.
  42621. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  42622. m.created_at = &t
  42623. }
  42624. // CreatedAt returns the value of the "created_at" field in the mutation.
  42625. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  42626. v := m.created_at
  42627. if v == nil {
  42628. return
  42629. }
  42630. return *v, true
  42631. }
  42632. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  42633. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42635. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42636. if !m.op.Is(OpUpdateOne) {
  42637. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42638. }
  42639. if m.id == nil || m.oldValue == nil {
  42640. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42641. }
  42642. oldValue, err := m.oldValue(ctx)
  42643. if err != nil {
  42644. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42645. }
  42646. return oldValue.CreatedAt, nil
  42647. }
  42648. // ResetCreatedAt resets all changes to the "created_at" field.
  42649. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  42650. m.created_at = nil
  42651. }
  42652. // SetUpdatedAt sets the "updated_at" field.
  42653. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  42654. m.updated_at = &t
  42655. }
  42656. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42657. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  42658. v := m.updated_at
  42659. if v == nil {
  42660. return
  42661. }
  42662. return *v, true
  42663. }
  42664. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  42665. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42667. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42668. if !m.op.Is(OpUpdateOne) {
  42669. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42670. }
  42671. if m.id == nil || m.oldValue == nil {
  42672. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42673. }
  42674. oldValue, err := m.oldValue(ctx)
  42675. if err != nil {
  42676. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42677. }
  42678. return oldValue.UpdatedAt, nil
  42679. }
  42680. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42681. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  42682. m.updated_at = nil
  42683. }
  42684. // SetStatus sets the "status" field.
  42685. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  42686. m.status = &u
  42687. m.addstatus = nil
  42688. }
  42689. // Status returns the value of the "status" field in the mutation.
  42690. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  42691. v := m.status
  42692. if v == nil {
  42693. return
  42694. }
  42695. return *v, true
  42696. }
  42697. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  42698. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42700. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42701. if !m.op.Is(OpUpdateOne) {
  42702. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42703. }
  42704. if m.id == nil || m.oldValue == nil {
  42705. return v, errors.New("OldStatus requires an ID field in the mutation")
  42706. }
  42707. oldValue, err := m.oldValue(ctx)
  42708. if err != nil {
  42709. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42710. }
  42711. return oldValue.Status, nil
  42712. }
  42713. // AddStatus adds u to the "status" field.
  42714. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  42715. if m.addstatus != nil {
  42716. *m.addstatus += u
  42717. } else {
  42718. m.addstatus = &u
  42719. }
  42720. }
  42721. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42722. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  42723. v := m.addstatus
  42724. if v == nil {
  42725. return
  42726. }
  42727. return *v, true
  42728. }
  42729. // ClearStatus clears the value of the "status" field.
  42730. func (m *WpChatroomMemberMutation) ClearStatus() {
  42731. m.status = nil
  42732. m.addstatus = nil
  42733. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  42734. }
  42735. // StatusCleared returns if the "status" field was cleared in this mutation.
  42736. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  42737. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  42738. return ok
  42739. }
  42740. // ResetStatus resets all changes to the "status" field.
  42741. func (m *WpChatroomMemberMutation) ResetStatus() {
  42742. m.status = nil
  42743. m.addstatus = nil
  42744. delete(m.clearedFields, wpchatroommember.FieldStatus)
  42745. }
  42746. // SetWxWxid sets the "wx_wxid" field.
  42747. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  42748. m.wx_wxid = &s
  42749. }
  42750. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  42751. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  42752. v := m.wx_wxid
  42753. if v == nil {
  42754. return
  42755. }
  42756. return *v, true
  42757. }
  42758. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  42759. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42761. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  42762. if !m.op.Is(OpUpdateOne) {
  42763. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  42764. }
  42765. if m.id == nil || m.oldValue == nil {
  42766. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  42767. }
  42768. oldValue, err := m.oldValue(ctx)
  42769. if err != nil {
  42770. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  42771. }
  42772. return oldValue.WxWxid, nil
  42773. }
  42774. // ResetWxWxid resets all changes to the "wx_wxid" field.
  42775. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  42776. m.wx_wxid = nil
  42777. }
  42778. // SetWxid sets the "wxid" field.
  42779. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  42780. m.wxid = &s
  42781. }
  42782. // Wxid returns the value of the "wxid" field in the mutation.
  42783. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  42784. v := m.wxid
  42785. if v == nil {
  42786. return
  42787. }
  42788. return *v, true
  42789. }
  42790. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  42791. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42793. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  42794. if !m.op.Is(OpUpdateOne) {
  42795. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42796. }
  42797. if m.id == nil || m.oldValue == nil {
  42798. return v, errors.New("OldWxid requires an ID field in the mutation")
  42799. }
  42800. oldValue, err := m.oldValue(ctx)
  42801. if err != nil {
  42802. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42803. }
  42804. return oldValue.Wxid, nil
  42805. }
  42806. // ResetWxid resets all changes to the "wxid" field.
  42807. func (m *WpChatroomMemberMutation) ResetWxid() {
  42808. m.wxid = nil
  42809. }
  42810. // SetNickname sets the "nickname" field.
  42811. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  42812. m.nickname = &s
  42813. }
  42814. // Nickname returns the value of the "nickname" field in the mutation.
  42815. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  42816. v := m.nickname
  42817. if v == nil {
  42818. return
  42819. }
  42820. return *v, true
  42821. }
  42822. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  42823. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42825. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  42826. if !m.op.Is(OpUpdateOne) {
  42827. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42828. }
  42829. if m.id == nil || m.oldValue == nil {
  42830. return v, errors.New("OldNickname requires an ID field in the mutation")
  42831. }
  42832. oldValue, err := m.oldValue(ctx)
  42833. if err != nil {
  42834. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42835. }
  42836. return oldValue.Nickname, nil
  42837. }
  42838. // ResetNickname resets all changes to the "nickname" field.
  42839. func (m *WpChatroomMemberMutation) ResetNickname() {
  42840. m.nickname = nil
  42841. }
  42842. // SetAvatar sets the "avatar" field.
  42843. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  42844. m.avatar = &s
  42845. }
  42846. // Avatar returns the value of the "avatar" field in the mutation.
  42847. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  42848. v := m.avatar
  42849. if v == nil {
  42850. return
  42851. }
  42852. return *v, true
  42853. }
  42854. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  42855. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  42856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42857. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  42858. if !m.op.Is(OpUpdateOne) {
  42859. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  42860. }
  42861. if m.id == nil || m.oldValue == nil {
  42862. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42863. }
  42864. oldValue, err := m.oldValue(ctx)
  42865. if err != nil {
  42866. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42867. }
  42868. return oldValue.Avatar, nil
  42869. }
  42870. // ResetAvatar resets all changes to the "avatar" field.
  42871. func (m *WpChatroomMemberMutation) ResetAvatar() {
  42872. m.avatar = nil
  42873. }
  42874. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  42875. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  42876. m.predicates = append(m.predicates, ps...)
  42877. }
  42878. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  42879. // users can use type-assertion to append predicates that do not depend on any generated package.
  42880. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  42881. p := make([]predicate.WpChatroomMember, len(ps))
  42882. for i := range ps {
  42883. p[i] = ps[i]
  42884. }
  42885. m.Where(p...)
  42886. }
  42887. // Op returns the operation name.
  42888. func (m *WpChatroomMemberMutation) Op() Op {
  42889. return m.op
  42890. }
  42891. // SetOp allows setting the mutation operation.
  42892. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  42893. m.op = op
  42894. }
  42895. // Type returns the node type of this mutation (WpChatroomMember).
  42896. func (m *WpChatroomMemberMutation) Type() string {
  42897. return m.typ
  42898. }
  42899. // Fields returns all fields that were changed during this mutation. Note that in
  42900. // order to get all numeric fields that were incremented/decremented, call
  42901. // AddedFields().
  42902. func (m *WpChatroomMemberMutation) Fields() []string {
  42903. fields := make([]string, 0, 7)
  42904. if m.created_at != nil {
  42905. fields = append(fields, wpchatroommember.FieldCreatedAt)
  42906. }
  42907. if m.updated_at != nil {
  42908. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  42909. }
  42910. if m.status != nil {
  42911. fields = append(fields, wpchatroommember.FieldStatus)
  42912. }
  42913. if m.wx_wxid != nil {
  42914. fields = append(fields, wpchatroommember.FieldWxWxid)
  42915. }
  42916. if m.wxid != nil {
  42917. fields = append(fields, wpchatroommember.FieldWxid)
  42918. }
  42919. if m.nickname != nil {
  42920. fields = append(fields, wpchatroommember.FieldNickname)
  42921. }
  42922. if m.avatar != nil {
  42923. fields = append(fields, wpchatroommember.FieldAvatar)
  42924. }
  42925. return fields
  42926. }
  42927. // Field returns the value of a field with the given name. The second boolean
  42928. // return value indicates that this field was not set, or was not defined in the
  42929. // schema.
  42930. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  42931. switch name {
  42932. case wpchatroommember.FieldCreatedAt:
  42933. return m.CreatedAt()
  42934. case wpchatroommember.FieldUpdatedAt:
  42935. return m.UpdatedAt()
  42936. case wpchatroommember.FieldStatus:
  42937. return m.Status()
  42938. case wpchatroommember.FieldWxWxid:
  42939. return m.WxWxid()
  42940. case wpchatroommember.FieldWxid:
  42941. return m.Wxid()
  42942. case wpchatroommember.FieldNickname:
  42943. return m.Nickname()
  42944. case wpchatroommember.FieldAvatar:
  42945. return m.Avatar()
  42946. }
  42947. return nil, false
  42948. }
  42949. // OldField returns the old value of the field from the database. An error is
  42950. // returned if the mutation operation is not UpdateOne, or the query to the
  42951. // database failed.
  42952. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42953. switch name {
  42954. case wpchatroommember.FieldCreatedAt:
  42955. return m.OldCreatedAt(ctx)
  42956. case wpchatroommember.FieldUpdatedAt:
  42957. return m.OldUpdatedAt(ctx)
  42958. case wpchatroommember.FieldStatus:
  42959. return m.OldStatus(ctx)
  42960. case wpchatroommember.FieldWxWxid:
  42961. return m.OldWxWxid(ctx)
  42962. case wpchatroommember.FieldWxid:
  42963. return m.OldWxid(ctx)
  42964. case wpchatroommember.FieldNickname:
  42965. return m.OldNickname(ctx)
  42966. case wpchatroommember.FieldAvatar:
  42967. return m.OldAvatar(ctx)
  42968. }
  42969. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  42970. }
  42971. // SetField sets the value of a field with the given name. It returns an error if
  42972. // the field is not defined in the schema, or if the type mismatched the field
  42973. // type.
  42974. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  42975. switch name {
  42976. case wpchatroommember.FieldCreatedAt:
  42977. v, ok := value.(time.Time)
  42978. if !ok {
  42979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42980. }
  42981. m.SetCreatedAt(v)
  42982. return nil
  42983. case wpchatroommember.FieldUpdatedAt:
  42984. v, ok := value.(time.Time)
  42985. if !ok {
  42986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42987. }
  42988. m.SetUpdatedAt(v)
  42989. return nil
  42990. case wpchatroommember.FieldStatus:
  42991. v, ok := value.(uint8)
  42992. if !ok {
  42993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42994. }
  42995. m.SetStatus(v)
  42996. return nil
  42997. case wpchatroommember.FieldWxWxid:
  42998. v, ok := value.(string)
  42999. if !ok {
  43000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43001. }
  43002. m.SetWxWxid(v)
  43003. return nil
  43004. case wpchatroommember.FieldWxid:
  43005. v, ok := value.(string)
  43006. if !ok {
  43007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43008. }
  43009. m.SetWxid(v)
  43010. return nil
  43011. case wpchatroommember.FieldNickname:
  43012. v, ok := value.(string)
  43013. if !ok {
  43014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43015. }
  43016. m.SetNickname(v)
  43017. return nil
  43018. case wpchatroommember.FieldAvatar:
  43019. v, ok := value.(string)
  43020. if !ok {
  43021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43022. }
  43023. m.SetAvatar(v)
  43024. return nil
  43025. }
  43026. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  43027. }
  43028. // AddedFields returns all numeric fields that were incremented/decremented during
  43029. // this mutation.
  43030. func (m *WpChatroomMemberMutation) AddedFields() []string {
  43031. var fields []string
  43032. if m.addstatus != nil {
  43033. fields = append(fields, wpchatroommember.FieldStatus)
  43034. }
  43035. return fields
  43036. }
  43037. // AddedField returns the numeric value that was incremented/decremented on a field
  43038. // with the given name. The second boolean return value indicates that this field
  43039. // was not set, or was not defined in the schema.
  43040. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  43041. switch name {
  43042. case wpchatroommember.FieldStatus:
  43043. return m.AddedStatus()
  43044. }
  43045. return nil, false
  43046. }
  43047. // AddField adds the value to the field with the given name. It returns an error if
  43048. // the field is not defined in the schema, or if the type mismatched the field
  43049. // type.
  43050. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  43051. switch name {
  43052. case wpchatroommember.FieldStatus:
  43053. v, ok := value.(int8)
  43054. if !ok {
  43055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43056. }
  43057. m.AddStatus(v)
  43058. return nil
  43059. }
  43060. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  43061. }
  43062. // ClearedFields returns all nullable fields that were cleared during this
  43063. // mutation.
  43064. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  43065. var fields []string
  43066. if m.FieldCleared(wpchatroommember.FieldStatus) {
  43067. fields = append(fields, wpchatroommember.FieldStatus)
  43068. }
  43069. return fields
  43070. }
  43071. // FieldCleared returns a boolean indicating if a field with the given name was
  43072. // cleared in this mutation.
  43073. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  43074. _, ok := m.clearedFields[name]
  43075. return ok
  43076. }
  43077. // ClearField clears the value of the field with the given name. It returns an
  43078. // error if the field is not defined in the schema.
  43079. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  43080. switch name {
  43081. case wpchatroommember.FieldStatus:
  43082. m.ClearStatus()
  43083. return nil
  43084. }
  43085. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  43086. }
  43087. // ResetField resets all changes in the mutation for the field with the given name.
  43088. // It returns an error if the field is not defined in the schema.
  43089. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  43090. switch name {
  43091. case wpchatroommember.FieldCreatedAt:
  43092. m.ResetCreatedAt()
  43093. return nil
  43094. case wpchatroommember.FieldUpdatedAt:
  43095. m.ResetUpdatedAt()
  43096. return nil
  43097. case wpchatroommember.FieldStatus:
  43098. m.ResetStatus()
  43099. return nil
  43100. case wpchatroommember.FieldWxWxid:
  43101. m.ResetWxWxid()
  43102. return nil
  43103. case wpchatroommember.FieldWxid:
  43104. m.ResetWxid()
  43105. return nil
  43106. case wpchatroommember.FieldNickname:
  43107. m.ResetNickname()
  43108. return nil
  43109. case wpchatroommember.FieldAvatar:
  43110. m.ResetAvatar()
  43111. return nil
  43112. }
  43113. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  43114. }
  43115. // AddedEdges returns all edge names that were set/added in this mutation.
  43116. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  43117. edges := make([]string, 0, 0)
  43118. return edges
  43119. }
  43120. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43121. // name in this mutation.
  43122. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  43123. return nil
  43124. }
  43125. // RemovedEdges returns all edge names that were removed in this mutation.
  43126. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  43127. edges := make([]string, 0, 0)
  43128. return edges
  43129. }
  43130. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43131. // the given name in this mutation.
  43132. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  43133. return nil
  43134. }
  43135. // ClearedEdges returns all edge names that were cleared in this mutation.
  43136. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  43137. edges := make([]string, 0, 0)
  43138. return edges
  43139. }
  43140. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43141. // was cleared in this mutation.
  43142. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  43143. return false
  43144. }
  43145. // ClearEdge clears the value of the edge with the given name. It returns an error
  43146. // if that edge is not defined in the schema.
  43147. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  43148. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  43149. }
  43150. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43151. // It returns an error if the edge is not defined in the schema.
  43152. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  43153. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  43154. }
  43155. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  43156. type WxMutation struct {
  43157. config
  43158. op Op
  43159. typ string
  43160. id *uint64
  43161. created_at *time.Time
  43162. updated_at *time.Time
  43163. status *uint8
  43164. addstatus *int8
  43165. deleted_at *time.Time
  43166. port *string
  43167. process_id *string
  43168. callback *string
  43169. wxid *string
  43170. account *string
  43171. nickname *string
  43172. tel *string
  43173. head_big *string
  43174. organization_id *uint64
  43175. addorganization_id *int64
  43176. api_base *string
  43177. api_key *string
  43178. allow_list *[]string
  43179. appendallow_list []string
  43180. group_allow_list *[]string
  43181. appendgroup_allow_list []string
  43182. block_list *[]string
  43183. appendblock_list []string
  43184. group_block_list *[]string
  43185. appendgroup_block_list []string
  43186. ctype *uint64
  43187. addctype *int64
  43188. clearedFields map[string]struct{}
  43189. server *uint64
  43190. clearedserver bool
  43191. agent *uint64
  43192. clearedagent bool
  43193. done bool
  43194. oldValue func(context.Context) (*Wx, error)
  43195. predicates []predicate.Wx
  43196. }
  43197. var _ ent.Mutation = (*WxMutation)(nil)
  43198. // wxOption allows management of the mutation configuration using functional options.
  43199. type wxOption func(*WxMutation)
  43200. // newWxMutation creates new mutation for the Wx entity.
  43201. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  43202. m := &WxMutation{
  43203. config: c,
  43204. op: op,
  43205. typ: TypeWx,
  43206. clearedFields: make(map[string]struct{}),
  43207. }
  43208. for _, opt := range opts {
  43209. opt(m)
  43210. }
  43211. return m
  43212. }
  43213. // withWxID sets the ID field of the mutation.
  43214. func withWxID(id uint64) wxOption {
  43215. return func(m *WxMutation) {
  43216. var (
  43217. err error
  43218. once sync.Once
  43219. value *Wx
  43220. )
  43221. m.oldValue = func(ctx context.Context) (*Wx, error) {
  43222. once.Do(func() {
  43223. if m.done {
  43224. err = errors.New("querying old values post mutation is not allowed")
  43225. } else {
  43226. value, err = m.Client().Wx.Get(ctx, id)
  43227. }
  43228. })
  43229. return value, err
  43230. }
  43231. m.id = &id
  43232. }
  43233. }
  43234. // withWx sets the old Wx of the mutation.
  43235. func withWx(node *Wx) wxOption {
  43236. return func(m *WxMutation) {
  43237. m.oldValue = func(context.Context) (*Wx, error) {
  43238. return node, nil
  43239. }
  43240. m.id = &node.ID
  43241. }
  43242. }
  43243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43244. // executed in a transaction (ent.Tx), a transactional client is returned.
  43245. func (m WxMutation) Client() *Client {
  43246. client := &Client{config: m.config}
  43247. client.init()
  43248. return client
  43249. }
  43250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43251. // it returns an error otherwise.
  43252. func (m WxMutation) Tx() (*Tx, error) {
  43253. if _, ok := m.driver.(*txDriver); !ok {
  43254. return nil, errors.New("ent: mutation is not running in a transaction")
  43255. }
  43256. tx := &Tx{config: m.config}
  43257. tx.init()
  43258. return tx, nil
  43259. }
  43260. // SetID sets the value of the id field. Note that this
  43261. // operation is only accepted on creation of Wx entities.
  43262. func (m *WxMutation) SetID(id uint64) {
  43263. m.id = &id
  43264. }
  43265. // ID returns the ID value in the mutation. Note that the ID is only available
  43266. // if it was provided to the builder or after it was returned from the database.
  43267. func (m *WxMutation) ID() (id uint64, exists bool) {
  43268. if m.id == nil {
  43269. return
  43270. }
  43271. return *m.id, true
  43272. }
  43273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43274. // That means, if the mutation is applied within a transaction with an isolation level such
  43275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43276. // or updated by the mutation.
  43277. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  43278. switch {
  43279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43280. id, exists := m.ID()
  43281. if exists {
  43282. return []uint64{id}, nil
  43283. }
  43284. fallthrough
  43285. case m.op.Is(OpUpdate | OpDelete):
  43286. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  43287. default:
  43288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43289. }
  43290. }
  43291. // SetCreatedAt sets the "created_at" field.
  43292. func (m *WxMutation) SetCreatedAt(t time.Time) {
  43293. m.created_at = &t
  43294. }
  43295. // CreatedAt returns the value of the "created_at" field in the mutation.
  43296. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  43297. v := m.created_at
  43298. if v == nil {
  43299. return
  43300. }
  43301. return *v, true
  43302. }
  43303. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  43304. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43306. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43307. if !m.op.Is(OpUpdateOne) {
  43308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43309. }
  43310. if m.id == nil || m.oldValue == nil {
  43311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43312. }
  43313. oldValue, err := m.oldValue(ctx)
  43314. if err != nil {
  43315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43316. }
  43317. return oldValue.CreatedAt, nil
  43318. }
  43319. // ResetCreatedAt resets all changes to the "created_at" field.
  43320. func (m *WxMutation) ResetCreatedAt() {
  43321. m.created_at = nil
  43322. }
  43323. // SetUpdatedAt sets the "updated_at" field.
  43324. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  43325. m.updated_at = &t
  43326. }
  43327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43328. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  43329. v := m.updated_at
  43330. if v == nil {
  43331. return
  43332. }
  43333. return *v, true
  43334. }
  43335. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  43336. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43338. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43339. if !m.op.Is(OpUpdateOne) {
  43340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43341. }
  43342. if m.id == nil || m.oldValue == nil {
  43343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43344. }
  43345. oldValue, err := m.oldValue(ctx)
  43346. if err != nil {
  43347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43348. }
  43349. return oldValue.UpdatedAt, nil
  43350. }
  43351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43352. func (m *WxMutation) ResetUpdatedAt() {
  43353. m.updated_at = nil
  43354. }
  43355. // SetStatus sets the "status" field.
  43356. func (m *WxMutation) SetStatus(u uint8) {
  43357. m.status = &u
  43358. m.addstatus = nil
  43359. }
  43360. // Status returns the value of the "status" field in the mutation.
  43361. func (m *WxMutation) Status() (r uint8, exists bool) {
  43362. v := m.status
  43363. if v == nil {
  43364. return
  43365. }
  43366. return *v, true
  43367. }
  43368. // OldStatus returns the old "status" field's value of the Wx entity.
  43369. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43371. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43372. if !m.op.Is(OpUpdateOne) {
  43373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43374. }
  43375. if m.id == nil || m.oldValue == nil {
  43376. return v, errors.New("OldStatus requires an ID field in the mutation")
  43377. }
  43378. oldValue, err := m.oldValue(ctx)
  43379. if err != nil {
  43380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43381. }
  43382. return oldValue.Status, nil
  43383. }
  43384. // AddStatus adds u to the "status" field.
  43385. func (m *WxMutation) AddStatus(u int8) {
  43386. if m.addstatus != nil {
  43387. *m.addstatus += u
  43388. } else {
  43389. m.addstatus = &u
  43390. }
  43391. }
  43392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43393. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  43394. v := m.addstatus
  43395. if v == nil {
  43396. return
  43397. }
  43398. return *v, true
  43399. }
  43400. // ClearStatus clears the value of the "status" field.
  43401. func (m *WxMutation) ClearStatus() {
  43402. m.status = nil
  43403. m.addstatus = nil
  43404. m.clearedFields[wx.FieldStatus] = struct{}{}
  43405. }
  43406. // StatusCleared returns if the "status" field was cleared in this mutation.
  43407. func (m *WxMutation) StatusCleared() bool {
  43408. _, ok := m.clearedFields[wx.FieldStatus]
  43409. return ok
  43410. }
  43411. // ResetStatus resets all changes to the "status" field.
  43412. func (m *WxMutation) ResetStatus() {
  43413. m.status = nil
  43414. m.addstatus = nil
  43415. delete(m.clearedFields, wx.FieldStatus)
  43416. }
  43417. // SetDeletedAt sets the "deleted_at" field.
  43418. func (m *WxMutation) SetDeletedAt(t time.Time) {
  43419. m.deleted_at = &t
  43420. }
  43421. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43422. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  43423. v := m.deleted_at
  43424. if v == nil {
  43425. return
  43426. }
  43427. return *v, true
  43428. }
  43429. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  43430. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43432. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43433. if !m.op.Is(OpUpdateOne) {
  43434. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43435. }
  43436. if m.id == nil || m.oldValue == nil {
  43437. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43438. }
  43439. oldValue, err := m.oldValue(ctx)
  43440. if err != nil {
  43441. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43442. }
  43443. return oldValue.DeletedAt, nil
  43444. }
  43445. // ClearDeletedAt clears the value of the "deleted_at" field.
  43446. func (m *WxMutation) ClearDeletedAt() {
  43447. m.deleted_at = nil
  43448. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  43449. }
  43450. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43451. func (m *WxMutation) DeletedAtCleared() bool {
  43452. _, ok := m.clearedFields[wx.FieldDeletedAt]
  43453. return ok
  43454. }
  43455. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43456. func (m *WxMutation) ResetDeletedAt() {
  43457. m.deleted_at = nil
  43458. delete(m.clearedFields, wx.FieldDeletedAt)
  43459. }
  43460. // SetServerID sets the "server_id" field.
  43461. func (m *WxMutation) SetServerID(u uint64) {
  43462. m.server = &u
  43463. }
  43464. // ServerID returns the value of the "server_id" field in the mutation.
  43465. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  43466. v := m.server
  43467. if v == nil {
  43468. return
  43469. }
  43470. return *v, true
  43471. }
  43472. // OldServerID returns the old "server_id" field's value of the Wx entity.
  43473. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43475. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  43476. if !m.op.Is(OpUpdateOne) {
  43477. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  43478. }
  43479. if m.id == nil || m.oldValue == nil {
  43480. return v, errors.New("OldServerID requires an ID field in the mutation")
  43481. }
  43482. oldValue, err := m.oldValue(ctx)
  43483. if err != nil {
  43484. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  43485. }
  43486. return oldValue.ServerID, nil
  43487. }
  43488. // ClearServerID clears the value of the "server_id" field.
  43489. func (m *WxMutation) ClearServerID() {
  43490. m.server = nil
  43491. m.clearedFields[wx.FieldServerID] = struct{}{}
  43492. }
  43493. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  43494. func (m *WxMutation) ServerIDCleared() bool {
  43495. _, ok := m.clearedFields[wx.FieldServerID]
  43496. return ok
  43497. }
  43498. // ResetServerID resets all changes to the "server_id" field.
  43499. func (m *WxMutation) ResetServerID() {
  43500. m.server = nil
  43501. delete(m.clearedFields, wx.FieldServerID)
  43502. }
  43503. // SetPort sets the "port" field.
  43504. func (m *WxMutation) SetPort(s string) {
  43505. m.port = &s
  43506. }
  43507. // Port returns the value of the "port" field in the mutation.
  43508. func (m *WxMutation) Port() (r string, exists bool) {
  43509. v := m.port
  43510. if v == nil {
  43511. return
  43512. }
  43513. return *v, true
  43514. }
  43515. // OldPort returns the old "port" field's value of the Wx entity.
  43516. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43518. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  43519. if !m.op.Is(OpUpdateOne) {
  43520. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  43521. }
  43522. if m.id == nil || m.oldValue == nil {
  43523. return v, errors.New("OldPort requires an ID field in the mutation")
  43524. }
  43525. oldValue, err := m.oldValue(ctx)
  43526. if err != nil {
  43527. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  43528. }
  43529. return oldValue.Port, nil
  43530. }
  43531. // ResetPort resets all changes to the "port" field.
  43532. func (m *WxMutation) ResetPort() {
  43533. m.port = nil
  43534. }
  43535. // SetProcessID sets the "process_id" field.
  43536. func (m *WxMutation) SetProcessID(s string) {
  43537. m.process_id = &s
  43538. }
  43539. // ProcessID returns the value of the "process_id" field in the mutation.
  43540. func (m *WxMutation) ProcessID() (r string, exists bool) {
  43541. v := m.process_id
  43542. if v == nil {
  43543. return
  43544. }
  43545. return *v, true
  43546. }
  43547. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  43548. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43550. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  43551. if !m.op.Is(OpUpdateOne) {
  43552. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  43553. }
  43554. if m.id == nil || m.oldValue == nil {
  43555. return v, errors.New("OldProcessID requires an ID field in the mutation")
  43556. }
  43557. oldValue, err := m.oldValue(ctx)
  43558. if err != nil {
  43559. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  43560. }
  43561. return oldValue.ProcessID, nil
  43562. }
  43563. // ResetProcessID resets all changes to the "process_id" field.
  43564. func (m *WxMutation) ResetProcessID() {
  43565. m.process_id = nil
  43566. }
  43567. // SetCallback sets the "callback" field.
  43568. func (m *WxMutation) SetCallback(s string) {
  43569. m.callback = &s
  43570. }
  43571. // Callback returns the value of the "callback" field in the mutation.
  43572. func (m *WxMutation) Callback() (r string, exists bool) {
  43573. v := m.callback
  43574. if v == nil {
  43575. return
  43576. }
  43577. return *v, true
  43578. }
  43579. // OldCallback returns the old "callback" field's value of the Wx entity.
  43580. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43582. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  43583. if !m.op.Is(OpUpdateOne) {
  43584. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  43585. }
  43586. if m.id == nil || m.oldValue == nil {
  43587. return v, errors.New("OldCallback requires an ID field in the mutation")
  43588. }
  43589. oldValue, err := m.oldValue(ctx)
  43590. if err != nil {
  43591. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  43592. }
  43593. return oldValue.Callback, nil
  43594. }
  43595. // ResetCallback resets all changes to the "callback" field.
  43596. func (m *WxMutation) ResetCallback() {
  43597. m.callback = nil
  43598. }
  43599. // SetWxid sets the "wxid" field.
  43600. func (m *WxMutation) SetWxid(s string) {
  43601. m.wxid = &s
  43602. }
  43603. // Wxid returns the value of the "wxid" field in the mutation.
  43604. func (m *WxMutation) Wxid() (r string, exists bool) {
  43605. v := m.wxid
  43606. if v == nil {
  43607. return
  43608. }
  43609. return *v, true
  43610. }
  43611. // OldWxid returns the old "wxid" field's value of the Wx entity.
  43612. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43614. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  43615. if !m.op.Is(OpUpdateOne) {
  43616. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43617. }
  43618. if m.id == nil || m.oldValue == nil {
  43619. return v, errors.New("OldWxid requires an ID field in the mutation")
  43620. }
  43621. oldValue, err := m.oldValue(ctx)
  43622. if err != nil {
  43623. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43624. }
  43625. return oldValue.Wxid, nil
  43626. }
  43627. // ResetWxid resets all changes to the "wxid" field.
  43628. func (m *WxMutation) ResetWxid() {
  43629. m.wxid = nil
  43630. }
  43631. // SetAccount sets the "account" field.
  43632. func (m *WxMutation) SetAccount(s string) {
  43633. m.account = &s
  43634. }
  43635. // Account returns the value of the "account" field in the mutation.
  43636. func (m *WxMutation) Account() (r string, exists bool) {
  43637. v := m.account
  43638. if v == nil {
  43639. return
  43640. }
  43641. return *v, true
  43642. }
  43643. // OldAccount returns the old "account" field's value of the Wx entity.
  43644. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43646. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  43647. if !m.op.Is(OpUpdateOne) {
  43648. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43649. }
  43650. if m.id == nil || m.oldValue == nil {
  43651. return v, errors.New("OldAccount requires an ID field in the mutation")
  43652. }
  43653. oldValue, err := m.oldValue(ctx)
  43654. if err != nil {
  43655. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43656. }
  43657. return oldValue.Account, nil
  43658. }
  43659. // ResetAccount resets all changes to the "account" field.
  43660. func (m *WxMutation) ResetAccount() {
  43661. m.account = nil
  43662. }
  43663. // SetNickname sets the "nickname" field.
  43664. func (m *WxMutation) SetNickname(s string) {
  43665. m.nickname = &s
  43666. }
  43667. // Nickname returns the value of the "nickname" field in the mutation.
  43668. func (m *WxMutation) Nickname() (r string, exists bool) {
  43669. v := m.nickname
  43670. if v == nil {
  43671. return
  43672. }
  43673. return *v, true
  43674. }
  43675. // OldNickname returns the old "nickname" field's value of the Wx entity.
  43676. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43678. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  43679. if !m.op.Is(OpUpdateOne) {
  43680. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43681. }
  43682. if m.id == nil || m.oldValue == nil {
  43683. return v, errors.New("OldNickname requires an ID field in the mutation")
  43684. }
  43685. oldValue, err := m.oldValue(ctx)
  43686. if err != nil {
  43687. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43688. }
  43689. return oldValue.Nickname, nil
  43690. }
  43691. // ResetNickname resets all changes to the "nickname" field.
  43692. func (m *WxMutation) ResetNickname() {
  43693. m.nickname = nil
  43694. }
  43695. // SetTel sets the "tel" field.
  43696. func (m *WxMutation) SetTel(s string) {
  43697. m.tel = &s
  43698. }
  43699. // Tel returns the value of the "tel" field in the mutation.
  43700. func (m *WxMutation) Tel() (r string, exists bool) {
  43701. v := m.tel
  43702. if v == nil {
  43703. return
  43704. }
  43705. return *v, true
  43706. }
  43707. // OldTel returns the old "tel" field's value of the Wx entity.
  43708. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43710. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  43711. if !m.op.Is(OpUpdateOne) {
  43712. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  43713. }
  43714. if m.id == nil || m.oldValue == nil {
  43715. return v, errors.New("OldTel requires an ID field in the mutation")
  43716. }
  43717. oldValue, err := m.oldValue(ctx)
  43718. if err != nil {
  43719. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  43720. }
  43721. return oldValue.Tel, nil
  43722. }
  43723. // ResetTel resets all changes to the "tel" field.
  43724. func (m *WxMutation) ResetTel() {
  43725. m.tel = nil
  43726. }
  43727. // SetHeadBig sets the "head_big" field.
  43728. func (m *WxMutation) SetHeadBig(s string) {
  43729. m.head_big = &s
  43730. }
  43731. // HeadBig returns the value of the "head_big" field in the mutation.
  43732. func (m *WxMutation) HeadBig() (r string, exists bool) {
  43733. v := m.head_big
  43734. if v == nil {
  43735. return
  43736. }
  43737. return *v, true
  43738. }
  43739. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  43740. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43742. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  43743. if !m.op.Is(OpUpdateOne) {
  43744. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  43745. }
  43746. if m.id == nil || m.oldValue == nil {
  43747. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  43748. }
  43749. oldValue, err := m.oldValue(ctx)
  43750. if err != nil {
  43751. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  43752. }
  43753. return oldValue.HeadBig, nil
  43754. }
  43755. // ResetHeadBig resets all changes to the "head_big" field.
  43756. func (m *WxMutation) ResetHeadBig() {
  43757. m.head_big = nil
  43758. }
  43759. // SetOrganizationID sets the "organization_id" field.
  43760. func (m *WxMutation) SetOrganizationID(u uint64) {
  43761. m.organization_id = &u
  43762. m.addorganization_id = nil
  43763. }
  43764. // OrganizationID returns the value of the "organization_id" field in the mutation.
  43765. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  43766. v := m.organization_id
  43767. if v == nil {
  43768. return
  43769. }
  43770. return *v, true
  43771. }
  43772. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  43773. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43775. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  43776. if !m.op.Is(OpUpdateOne) {
  43777. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  43778. }
  43779. if m.id == nil || m.oldValue == nil {
  43780. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  43781. }
  43782. oldValue, err := m.oldValue(ctx)
  43783. if err != nil {
  43784. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  43785. }
  43786. return oldValue.OrganizationID, nil
  43787. }
  43788. // AddOrganizationID adds u to the "organization_id" field.
  43789. func (m *WxMutation) AddOrganizationID(u int64) {
  43790. if m.addorganization_id != nil {
  43791. *m.addorganization_id += u
  43792. } else {
  43793. m.addorganization_id = &u
  43794. }
  43795. }
  43796. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  43797. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  43798. v := m.addorganization_id
  43799. if v == nil {
  43800. return
  43801. }
  43802. return *v, true
  43803. }
  43804. // ClearOrganizationID clears the value of the "organization_id" field.
  43805. func (m *WxMutation) ClearOrganizationID() {
  43806. m.organization_id = nil
  43807. m.addorganization_id = nil
  43808. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  43809. }
  43810. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  43811. func (m *WxMutation) OrganizationIDCleared() bool {
  43812. _, ok := m.clearedFields[wx.FieldOrganizationID]
  43813. return ok
  43814. }
  43815. // ResetOrganizationID resets all changes to the "organization_id" field.
  43816. func (m *WxMutation) ResetOrganizationID() {
  43817. m.organization_id = nil
  43818. m.addorganization_id = nil
  43819. delete(m.clearedFields, wx.FieldOrganizationID)
  43820. }
  43821. // SetAgentID sets the "agent_id" field.
  43822. func (m *WxMutation) SetAgentID(u uint64) {
  43823. m.agent = &u
  43824. }
  43825. // AgentID returns the value of the "agent_id" field in the mutation.
  43826. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  43827. v := m.agent
  43828. if v == nil {
  43829. return
  43830. }
  43831. return *v, true
  43832. }
  43833. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  43834. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43836. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  43837. if !m.op.Is(OpUpdateOne) {
  43838. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  43839. }
  43840. if m.id == nil || m.oldValue == nil {
  43841. return v, errors.New("OldAgentID requires an ID field in the mutation")
  43842. }
  43843. oldValue, err := m.oldValue(ctx)
  43844. if err != nil {
  43845. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  43846. }
  43847. return oldValue.AgentID, nil
  43848. }
  43849. // ResetAgentID resets all changes to the "agent_id" field.
  43850. func (m *WxMutation) ResetAgentID() {
  43851. m.agent = nil
  43852. }
  43853. // SetAPIBase sets the "api_base" field.
  43854. func (m *WxMutation) SetAPIBase(s string) {
  43855. m.api_base = &s
  43856. }
  43857. // APIBase returns the value of the "api_base" field in the mutation.
  43858. func (m *WxMutation) APIBase() (r string, exists bool) {
  43859. v := m.api_base
  43860. if v == nil {
  43861. return
  43862. }
  43863. return *v, true
  43864. }
  43865. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  43866. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43868. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43869. if !m.op.Is(OpUpdateOne) {
  43870. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43871. }
  43872. if m.id == nil || m.oldValue == nil {
  43873. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43874. }
  43875. oldValue, err := m.oldValue(ctx)
  43876. if err != nil {
  43877. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43878. }
  43879. return oldValue.APIBase, nil
  43880. }
  43881. // ClearAPIBase clears the value of the "api_base" field.
  43882. func (m *WxMutation) ClearAPIBase() {
  43883. m.api_base = nil
  43884. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  43885. }
  43886. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43887. func (m *WxMutation) APIBaseCleared() bool {
  43888. _, ok := m.clearedFields[wx.FieldAPIBase]
  43889. return ok
  43890. }
  43891. // ResetAPIBase resets all changes to the "api_base" field.
  43892. func (m *WxMutation) ResetAPIBase() {
  43893. m.api_base = nil
  43894. delete(m.clearedFields, wx.FieldAPIBase)
  43895. }
  43896. // SetAPIKey sets the "api_key" field.
  43897. func (m *WxMutation) SetAPIKey(s string) {
  43898. m.api_key = &s
  43899. }
  43900. // APIKey returns the value of the "api_key" field in the mutation.
  43901. func (m *WxMutation) APIKey() (r string, exists bool) {
  43902. v := m.api_key
  43903. if v == nil {
  43904. return
  43905. }
  43906. return *v, true
  43907. }
  43908. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  43909. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43911. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43912. if !m.op.Is(OpUpdateOne) {
  43913. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43914. }
  43915. if m.id == nil || m.oldValue == nil {
  43916. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43917. }
  43918. oldValue, err := m.oldValue(ctx)
  43919. if err != nil {
  43920. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43921. }
  43922. return oldValue.APIKey, nil
  43923. }
  43924. // ClearAPIKey clears the value of the "api_key" field.
  43925. func (m *WxMutation) ClearAPIKey() {
  43926. m.api_key = nil
  43927. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  43928. }
  43929. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43930. func (m *WxMutation) APIKeyCleared() bool {
  43931. _, ok := m.clearedFields[wx.FieldAPIKey]
  43932. return ok
  43933. }
  43934. // ResetAPIKey resets all changes to the "api_key" field.
  43935. func (m *WxMutation) ResetAPIKey() {
  43936. m.api_key = nil
  43937. delete(m.clearedFields, wx.FieldAPIKey)
  43938. }
  43939. // SetAllowList sets the "allow_list" field.
  43940. func (m *WxMutation) SetAllowList(s []string) {
  43941. m.allow_list = &s
  43942. m.appendallow_list = nil
  43943. }
  43944. // AllowList returns the value of the "allow_list" field in the mutation.
  43945. func (m *WxMutation) AllowList() (r []string, exists bool) {
  43946. v := m.allow_list
  43947. if v == nil {
  43948. return
  43949. }
  43950. return *v, true
  43951. }
  43952. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  43953. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43955. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  43956. if !m.op.Is(OpUpdateOne) {
  43957. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  43958. }
  43959. if m.id == nil || m.oldValue == nil {
  43960. return v, errors.New("OldAllowList requires an ID field in the mutation")
  43961. }
  43962. oldValue, err := m.oldValue(ctx)
  43963. if err != nil {
  43964. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  43965. }
  43966. return oldValue.AllowList, nil
  43967. }
  43968. // AppendAllowList adds s to the "allow_list" field.
  43969. func (m *WxMutation) AppendAllowList(s []string) {
  43970. m.appendallow_list = append(m.appendallow_list, s...)
  43971. }
  43972. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  43973. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  43974. if len(m.appendallow_list) == 0 {
  43975. return nil, false
  43976. }
  43977. return m.appendallow_list, true
  43978. }
  43979. // ResetAllowList resets all changes to the "allow_list" field.
  43980. func (m *WxMutation) ResetAllowList() {
  43981. m.allow_list = nil
  43982. m.appendallow_list = nil
  43983. }
  43984. // SetGroupAllowList sets the "group_allow_list" field.
  43985. func (m *WxMutation) SetGroupAllowList(s []string) {
  43986. m.group_allow_list = &s
  43987. m.appendgroup_allow_list = nil
  43988. }
  43989. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  43990. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  43991. v := m.group_allow_list
  43992. if v == nil {
  43993. return
  43994. }
  43995. return *v, true
  43996. }
  43997. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  43998. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44000. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  44001. if !m.op.Is(OpUpdateOne) {
  44002. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  44003. }
  44004. if m.id == nil || m.oldValue == nil {
  44005. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  44006. }
  44007. oldValue, err := m.oldValue(ctx)
  44008. if err != nil {
  44009. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  44010. }
  44011. return oldValue.GroupAllowList, nil
  44012. }
  44013. // AppendGroupAllowList adds s to the "group_allow_list" field.
  44014. func (m *WxMutation) AppendGroupAllowList(s []string) {
  44015. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  44016. }
  44017. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  44018. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  44019. if len(m.appendgroup_allow_list) == 0 {
  44020. return nil, false
  44021. }
  44022. return m.appendgroup_allow_list, true
  44023. }
  44024. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  44025. func (m *WxMutation) ResetGroupAllowList() {
  44026. m.group_allow_list = nil
  44027. m.appendgroup_allow_list = nil
  44028. }
  44029. // SetBlockList sets the "block_list" field.
  44030. func (m *WxMutation) SetBlockList(s []string) {
  44031. m.block_list = &s
  44032. m.appendblock_list = nil
  44033. }
  44034. // BlockList returns the value of the "block_list" field in the mutation.
  44035. func (m *WxMutation) BlockList() (r []string, exists bool) {
  44036. v := m.block_list
  44037. if v == nil {
  44038. return
  44039. }
  44040. return *v, true
  44041. }
  44042. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  44043. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44045. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  44046. if !m.op.Is(OpUpdateOne) {
  44047. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  44048. }
  44049. if m.id == nil || m.oldValue == nil {
  44050. return v, errors.New("OldBlockList requires an ID field in the mutation")
  44051. }
  44052. oldValue, err := m.oldValue(ctx)
  44053. if err != nil {
  44054. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  44055. }
  44056. return oldValue.BlockList, nil
  44057. }
  44058. // AppendBlockList adds s to the "block_list" field.
  44059. func (m *WxMutation) AppendBlockList(s []string) {
  44060. m.appendblock_list = append(m.appendblock_list, s...)
  44061. }
  44062. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  44063. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  44064. if len(m.appendblock_list) == 0 {
  44065. return nil, false
  44066. }
  44067. return m.appendblock_list, true
  44068. }
  44069. // ResetBlockList resets all changes to the "block_list" field.
  44070. func (m *WxMutation) ResetBlockList() {
  44071. m.block_list = nil
  44072. m.appendblock_list = nil
  44073. }
  44074. // SetGroupBlockList sets the "group_block_list" field.
  44075. func (m *WxMutation) SetGroupBlockList(s []string) {
  44076. m.group_block_list = &s
  44077. m.appendgroup_block_list = nil
  44078. }
  44079. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  44080. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  44081. v := m.group_block_list
  44082. if v == nil {
  44083. return
  44084. }
  44085. return *v, true
  44086. }
  44087. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  44088. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44090. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  44091. if !m.op.Is(OpUpdateOne) {
  44092. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  44093. }
  44094. if m.id == nil || m.oldValue == nil {
  44095. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  44096. }
  44097. oldValue, err := m.oldValue(ctx)
  44098. if err != nil {
  44099. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  44100. }
  44101. return oldValue.GroupBlockList, nil
  44102. }
  44103. // AppendGroupBlockList adds s to the "group_block_list" field.
  44104. func (m *WxMutation) AppendGroupBlockList(s []string) {
  44105. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  44106. }
  44107. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  44108. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  44109. if len(m.appendgroup_block_list) == 0 {
  44110. return nil, false
  44111. }
  44112. return m.appendgroup_block_list, true
  44113. }
  44114. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  44115. func (m *WxMutation) ResetGroupBlockList() {
  44116. m.group_block_list = nil
  44117. m.appendgroup_block_list = nil
  44118. }
  44119. // SetCtype sets the "ctype" field.
  44120. func (m *WxMutation) SetCtype(u uint64) {
  44121. m.ctype = &u
  44122. m.addctype = nil
  44123. }
  44124. // Ctype returns the value of the "ctype" field in the mutation.
  44125. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  44126. v := m.ctype
  44127. if v == nil {
  44128. return
  44129. }
  44130. return *v, true
  44131. }
  44132. // OldCtype returns the old "ctype" field's value of the Wx entity.
  44133. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44135. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  44136. if !m.op.Is(OpUpdateOne) {
  44137. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  44138. }
  44139. if m.id == nil || m.oldValue == nil {
  44140. return v, errors.New("OldCtype requires an ID field in the mutation")
  44141. }
  44142. oldValue, err := m.oldValue(ctx)
  44143. if err != nil {
  44144. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  44145. }
  44146. return oldValue.Ctype, nil
  44147. }
  44148. // AddCtype adds u to the "ctype" field.
  44149. func (m *WxMutation) AddCtype(u int64) {
  44150. if m.addctype != nil {
  44151. *m.addctype += u
  44152. } else {
  44153. m.addctype = &u
  44154. }
  44155. }
  44156. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  44157. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  44158. v := m.addctype
  44159. if v == nil {
  44160. return
  44161. }
  44162. return *v, true
  44163. }
  44164. // ClearCtype clears the value of the "ctype" field.
  44165. func (m *WxMutation) ClearCtype() {
  44166. m.ctype = nil
  44167. m.addctype = nil
  44168. m.clearedFields[wx.FieldCtype] = struct{}{}
  44169. }
  44170. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  44171. func (m *WxMutation) CtypeCleared() bool {
  44172. _, ok := m.clearedFields[wx.FieldCtype]
  44173. return ok
  44174. }
  44175. // ResetCtype resets all changes to the "ctype" field.
  44176. func (m *WxMutation) ResetCtype() {
  44177. m.ctype = nil
  44178. m.addctype = nil
  44179. delete(m.clearedFields, wx.FieldCtype)
  44180. }
  44181. // ClearServer clears the "server" edge to the Server entity.
  44182. func (m *WxMutation) ClearServer() {
  44183. m.clearedserver = true
  44184. m.clearedFields[wx.FieldServerID] = struct{}{}
  44185. }
  44186. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  44187. func (m *WxMutation) ServerCleared() bool {
  44188. return m.ServerIDCleared() || m.clearedserver
  44189. }
  44190. // ServerIDs returns the "server" edge IDs in the mutation.
  44191. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44192. // ServerID instead. It exists only for internal usage by the builders.
  44193. func (m *WxMutation) ServerIDs() (ids []uint64) {
  44194. if id := m.server; id != nil {
  44195. ids = append(ids, *id)
  44196. }
  44197. return
  44198. }
  44199. // ResetServer resets all changes to the "server" edge.
  44200. func (m *WxMutation) ResetServer() {
  44201. m.server = nil
  44202. m.clearedserver = false
  44203. }
  44204. // ClearAgent clears the "agent" edge to the Agent entity.
  44205. func (m *WxMutation) ClearAgent() {
  44206. m.clearedagent = true
  44207. m.clearedFields[wx.FieldAgentID] = struct{}{}
  44208. }
  44209. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  44210. func (m *WxMutation) AgentCleared() bool {
  44211. return m.clearedagent
  44212. }
  44213. // AgentIDs returns the "agent" edge IDs in the mutation.
  44214. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44215. // AgentID instead. It exists only for internal usage by the builders.
  44216. func (m *WxMutation) AgentIDs() (ids []uint64) {
  44217. if id := m.agent; id != nil {
  44218. ids = append(ids, *id)
  44219. }
  44220. return
  44221. }
  44222. // ResetAgent resets all changes to the "agent" edge.
  44223. func (m *WxMutation) ResetAgent() {
  44224. m.agent = nil
  44225. m.clearedagent = false
  44226. }
  44227. // Where appends a list predicates to the WxMutation builder.
  44228. func (m *WxMutation) Where(ps ...predicate.Wx) {
  44229. m.predicates = append(m.predicates, ps...)
  44230. }
  44231. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  44232. // users can use type-assertion to append predicates that do not depend on any generated package.
  44233. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  44234. p := make([]predicate.Wx, len(ps))
  44235. for i := range ps {
  44236. p[i] = ps[i]
  44237. }
  44238. m.Where(p...)
  44239. }
  44240. // Op returns the operation name.
  44241. func (m *WxMutation) Op() Op {
  44242. return m.op
  44243. }
  44244. // SetOp allows setting the mutation operation.
  44245. func (m *WxMutation) SetOp(op Op) {
  44246. m.op = op
  44247. }
  44248. // Type returns the node type of this mutation (Wx).
  44249. func (m *WxMutation) Type() string {
  44250. return m.typ
  44251. }
  44252. // Fields returns all fields that were changed during this mutation. Note that in
  44253. // order to get all numeric fields that were incremented/decremented, call
  44254. // AddedFields().
  44255. func (m *WxMutation) Fields() []string {
  44256. fields := make([]string, 0, 22)
  44257. if m.created_at != nil {
  44258. fields = append(fields, wx.FieldCreatedAt)
  44259. }
  44260. if m.updated_at != nil {
  44261. fields = append(fields, wx.FieldUpdatedAt)
  44262. }
  44263. if m.status != nil {
  44264. fields = append(fields, wx.FieldStatus)
  44265. }
  44266. if m.deleted_at != nil {
  44267. fields = append(fields, wx.FieldDeletedAt)
  44268. }
  44269. if m.server != nil {
  44270. fields = append(fields, wx.FieldServerID)
  44271. }
  44272. if m.port != nil {
  44273. fields = append(fields, wx.FieldPort)
  44274. }
  44275. if m.process_id != nil {
  44276. fields = append(fields, wx.FieldProcessID)
  44277. }
  44278. if m.callback != nil {
  44279. fields = append(fields, wx.FieldCallback)
  44280. }
  44281. if m.wxid != nil {
  44282. fields = append(fields, wx.FieldWxid)
  44283. }
  44284. if m.account != nil {
  44285. fields = append(fields, wx.FieldAccount)
  44286. }
  44287. if m.nickname != nil {
  44288. fields = append(fields, wx.FieldNickname)
  44289. }
  44290. if m.tel != nil {
  44291. fields = append(fields, wx.FieldTel)
  44292. }
  44293. if m.head_big != nil {
  44294. fields = append(fields, wx.FieldHeadBig)
  44295. }
  44296. if m.organization_id != nil {
  44297. fields = append(fields, wx.FieldOrganizationID)
  44298. }
  44299. if m.agent != nil {
  44300. fields = append(fields, wx.FieldAgentID)
  44301. }
  44302. if m.api_base != nil {
  44303. fields = append(fields, wx.FieldAPIBase)
  44304. }
  44305. if m.api_key != nil {
  44306. fields = append(fields, wx.FieldAPIKey)
  44307. }
  44308. if m.allow_list != nil {
  44309. fields = append(fields, wx.FieldAllowList)
  44310. }
  44311. if m.group_allow_list != nil {
  44312. fields = append(fields, wx.FieldGroupAllowList)
  44313. }
  44314. if m.block_list != nil {
  44315. fields = append(fields, wx.FieldBlockList)
  44316. }
  44317. if m.group_block_list != nil {
  44318. fields = append(fields, wx.FieldGroupBlockList)
  44319. }
  44320. if m.ctype != nil {
  44321. fields = append(fields, wx.FieldCtype)
  44322. }
  44323. return fields
  44324. }
  44325. // Field returns the value of a field with the given name. The second boolean
  44326. // return value indicates that this field was not set, or was not defined in the
  44327. // schema.
  44328. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  44329. switch name {
  44330. case wx.FieldCreatedAt:
  44331. return m.CreatedAt()
  44332. case wx.FieldUpdatedAt:
  44333. return m.UpdatedAt()
  44334. case wx.FieldStatus:
  44335. return m.Status()
  44336. case wx.FieldDeletedAt:
  44337. return m.DeletedAt()
  44338. case wx.FieldServerID:
  44339. return m.ServerID()
  44340. case wx.FieldPort:
  44341. return m.Port()
  44342. case wx.FieldProcessID:
  44343. return m.ProcessID()
  44344. case wx.FieldCallback:
  44345. return m.Callback()
  44346. case wx.FieldWxid:
  44347. return m.Wxid()
  44348. case wx.FieldAccount:
  44349. return m.Account()
  44350. case wx.FieldNickname:
  44351. return m.Nickname()
  44352. case wx.FieldTel:
  44353. return m.Tel()
  44354. case wx.FieldHeadBig:
  44355. return m.HeadBig()
  44356. case wx.FieldOrganizationID:
  44357. return m.OrganizationID()
  44358. case wx.FieldAgentID:
  44359. return m.AgentID()
  44360. case wx.FieldAPIBase:
  44361. return m.APIBase()
  44362. case wx.FieldAPIKey:
  44363. return m.APIKey()
  44364. case wx.FieldAllowList:
  44365. return m.AllowList()
  44366. case wx.FieldGroupAllowList:
  44367. return m.GroupAllowList()
  44368. case wx.FieldBlockList:
  44369. return m.BlockList()
  44370. case wx.FieldGroupBlockList:
  44371. return m.GroupBlockList()
  44372. case wx.FieldCtype:
  44373. return m.Ctype()
  44374. }
  44375. return nil, false
  44376. }
  44377. // OldField returns the old value of the field from the database. An error is
  44378. // returned if the mutation operation is not UpdateOne, or the query to the
  44379. // database failed.
  44380. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44381. switch name {
  44382. case wx.FieldCreatedAt:
  44383. return m.OldCreatedAt(ctx)
  44384. case wx.FieldUpdatedAt:
  44385. return m.OldUpdatedAt(ctx)
  44386. case wx.FieldStatus:
  44387. return m.OldStatus(ctx)
  44388. case wx.FieldDeletedAt:
  44389. return m.OldDeletedAt(ctx)
  44390. case wx.FieldServerID:
  44391. return m.OldServerID(ctx)
  44392. case wx.FieldPort:
  44393. return m.OldPort(ctx)
  44394. case wx.FieldProcessID:
  44395. return m.OldProcessID(ctx)
  44396. case wx.FieldCallback:
  44397. return m.OldCallback(ctx)
  44398. case wx.FieldWxid:
  44399. return m.OldWxid(ctx)
  44400. case wx.FieldAccount:
  44401. return m.OldAccount(ctx)
  44402. case wx.FieldNickname:
  44403. return m.OldNickname(ctx)
  44404. case wx.FieldTel:
  44405. return m.OldTel(ctx)
  44406. case wx.FieldHeadBig:
  44407. return m.OldHeadBig(ctx)
  44408. case wx.FieldOrganizationID:
  44409. return m.OldOrganizationID(ctx)
  44410. case wx.FieldAgentID:
  44411. return m.OldAgentID(ctx)
  44412. case wx.FieldAPIBase:
  44413. return m.OldAPIBase(ctx)
  44414. case wx.FieldAPIKey:
  44415. return m.OldAPIKey(ctx)
  44416. case wx.FieldAllowList:
  44417. return m.OldAllowList(ctx)
  44418. case wx.FieldGroupAllowList:
  44419. return m.OldGroupAllowList(ctx)
  44420. case wx.FieldBlockList:
  44421. return m.OldBlockList(ctx)
  44422. case wx.FieldGroupBlockList:
  44423. return m.OldGroupBlockList(ctx)
  44424. case wx.FieldCtype:
  44425. return m.OldCtype(ctx)
  44426. }
  44427. return nil, fmt.Errorf("unknown Wx field %s", name)
  44428. }
  44429. // SetField sets the value of a field with the given name. It returns an error if
  44430. // the field is not defined in the schema, or if the type mismatched the field
  44431. // type.
  44432. func (m *WxMutation) SetField(name string, value ent.Value) error {
  44433. switch name {
  44434. case wx.FieldCreatedAt:
  44435. v, ok := value.(time.Time)
  44436. if !ok {
  44437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44438. }
  44439. m.SetCreatedAt(v)
  44440. return nil
  44441. case wx.FieldUpdatedAt:
  44442. v, ok := value.(time.Time)
  44443. if !ok {
  44444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44445. }
  44446. m.SetUpdatedAt(v)
  44447. return nil
  44448. case wx.FieldStatus:
  44449. v, ok := value.(uint8)
  44450. if !ok {
  44451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44452. }
  44453. m.SetStatus(v)
  44454. return nil
  44455. case wx.FieldDeletedAt:
  44456. v, ok := value.(time.Time)
  44457. if !ok {
  44458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44459. }
  44460. m.SetDeletedAt(v)
  44461. return nil
  44462. case wx.FieldServerID:
  44463. v, ok := value.(uint64)
  44464. if !ok {
  44465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44466. }
  44467. m.SetServerID(v)
  44468. return nil
  44469. case wx.FieldPort:
  44470. v, ok := value.(string)
  44471. if !ok {
  44472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44473. }
  44474. m.SetPort(v)
  44475. return nil
  44476. case wx.FieldProcessID:
  44477. v, ok := value.(string)
  44478. if !ok {
  44479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44480. }
  44481. m.SetProcessID(v)
  44482. return nil
  44483. case wx.FieldCallback:
  44484. v, ok := value.(string)
  44485. if !ok {
  44486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44487. }
  44488. m.SetCallback(v)
  44489. return nil
  44490. case wx.FieldWxid:
  44491. v, ok := value.(string)
  44492. if !ok {
  44493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44494. }
  44495. m.SetWxid(v)
  44496. return nil
  44497. case wx.FieldAccount:
  44498. v, ok := value.(string)
  44499. if !ok {
  44500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44501. }
  44502. m.SetAccount(v)
  44503. return nil
  44504. case wx.FieldNickname:
  44505. v, ok := value.(string)
  44506. if !ok {
  44507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44508. }
  44509. m.SetNickname(v)
  44510. return nil
  44511. case wx.FieldTel:
  44512. v, ok := value.(string)
  44513. if !ok {
  44514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44515. }
  44516. m.SetTel(v)
  44517. return nil
  44518. case wx.FieldHeadBig:
  44519. v, ok := value.(string)
  44520. if !ok {
  44521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44522. }
  44523. m.SetHeadBig(v)
  44524. return nil
  44525. case wx.FieldOrganizationID:
  44526. v, ok := value.(uint64)
  44527. if !ok {
  44528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44529. }
  44530. m.SetOrganizationID(v)
  44531. return nil
  44532. case wx.FieldAgentID:
  44533. v, ok := value.(uint64)
  44534. if !ok {
  44535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44536. }
  44537. m.SetAgentID(v)
  44538. return nil
  44539. case wx.FieldAPIBase:
  44540. v, ok := value.(string)
  44541. if !ok {
  44542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44543. }
  44544. m.SetAPIBase(v)
  44545. return nil
  44546. case wx.FieldAPIKey:
  44547. v, ok := value.(string)
  44548. if !ok {
  44549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44550. }
  44551. m.SetAPIKey(v)
  44552. return nil
  44553. case wx.FieldAllowList:
  44554. v, ok := value.([]string)
  44555. if !ok {
  44556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44557. }
  44558. m.SetAllowList(v)
  44559. return nil
  44560. case wx.FieldGroupAllowList:
  44561. v, ok := value.([]string)
  44562. if !ok {
  44563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44564. }
  44565. m.SetGroupAllowList(v)
  44566. return nil
  44567. case wx.FieldBlockList:
  44568. v, ok := value.([]string)
  44569. if !ok {
  44570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44571. }
  44572. m.SetBlockList(v)
  44573. return nil
  44574. case wx.FieldGroupBlockList:
  44575. v, ok := value.([]string)
  44576. if !ok {
  44577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44578. }
  44579. m.SetGroupBlockList(v)
  44580. return nil
  44581. case wx.FieldCtype:
  44582. v, ok := value.(uint64)
  44583. if !ok {
  44584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44585. }
  44586. m.SetCtype(v)
  44587. return nil
  44588. }
  44589. return fmt.Errorf("unknown Wx field %s", name)
  44590. }
  44591. // AddedFields returns all numeric fields that were incremented/decremented during
  44592. // this mutation.
  44593. func (m *WxMutation) AddedFields() []string {
  44594. var fields []string
  44595. if m.addstatus != nil {
  44596. fields = append(fields, wx.FieldStatus)
  44597. }
  44598. if m.addorganization_id != nil {
  44599. fields = append(fields, wx.FieldOrganizationID)
  44600. }
  44601. if m.addctype != nil {
  44602. fields = append(fields, wx.FieldCtype)
  44603. }
  44604. return fields
  44605. }
  44606. // AddedField returns the numeric value that was incremented/decremented on a field
  44607. // with the given name. The second boolean return value indicates that this field
  44608. // was not set, or was not defined in the schema.
  44609. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  44610. switch name {
  44611. case wx.FieldStatus:
  44612. return m.AddedStatus()
  44613. case wx.FieldOrganizationID:
  44614. return m.AddedOrganizationID()
  44615. case wx.FieldCtype:
  44616. return m.AddedCtype()
  44617. }
  44618. return nil, false
  44619. }
  44620. // AddField adds the value to the field with the given name. It returns an error if
  44621. // the field is not defined in the schema, or if the type mismatched the field
  44622. // type.
  44623. func (m *WxMutation) AddField(name string, value ent.Value) error {
  44624. switch name {
  44625. case wx.FieldStatus:
  44626. v, ok := value.(int8)
  44627. if !ok {
  44628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44629. }
  44630. m.AddStatus(v)
  44631. return nil
  44632. case wx.FieldOrganizationID:
  44633. v, ok := value.(int64)
  44634. if !ok {
  44635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44636. }
  44637. m.AddOrganizationID(v)
  44638. return nil
  44639. case wx.FieldCtype:
  44640. v, ok := value.(int64)
  44641. if !ok {
  44642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44643. }
  44644. m.AddCtype(v)
  44645. return nil
  44646. }
  44647. return fmt.Errorf("unknown Wx numeric field %s", name)
  44648. }
  44649. // ClearedFields returns all nullable fields that were cleared during this
  44650. // mutation.
  44651. func (m *WxMutation) ClearedFields() []string {
  44652. var fields []string
  44653. if m.FieldCleared(wx.FieldStatus) {
  44654. fields = append(fields, wx.FieldStatus)
  44655. }
  44656. if m.FieldCleared(wx.FieldDeletedAt) {
  44657. fields = append(fields, wx.FieldDeletedAt)
  44658. }
  44659. if m.FieldCleared(wx.FieldServerID) {
  44660. fields = append(fields, wx.FieldServerID)
  44661. }
  44662. if m.FieldCleared(wx.FieldOrganizationID) {
  44663. fields = append(fields, wx.FieldOrganizationID)
  44664. }
  44665. if m.FieldCleared(wx.FieldAPIBase) {
  44666. fields = append(fields, wx.FieldAPIBase)
  44667. }
  44668. if m.FieldCleared(wx.FieldAPIKey) {
  44669. fields = append(fields, wx.FieldAPIKey)
  44670. }
  44671. if m.FieldCleared(wx.FieldCtype) {
  44672. fields = append(fields, wx.FieldCtype)
  44673. }
  44674. return fields
  44675. }
  44676. // FieldCleared returns a boolean indicating if a field with the given name was
  44677. // cleared in this mutation.
  44678. func (m *WxMutation) FieldCleared(name string) bool {
  44679. _, ok := m.clearedFields[name]
  44680. return ok
  44681. }
  44682. // ClearField clears the value of the field with the given name. It returns an
  44683. // error if the field is not defined in the schema.
  44684. func (m *WxMutation) ClearField(name string) error {
  44685. switch name {
  44686. case wx.FieldStatus:
  44687. m.ClearStatus()
  44688. return nil
  44689. case wx.FieldDeletedAt:
  44690. m.ClearDeletedAt()
  44691. return nil
  44692. case wx.FieldServerID:
  44693. m.ClearServerID()
  44694. return nil
  44695. case wx.FieldOrganizationID:
  44696. m.ClearOrganizationID()
  44697. return nil
  44698. case wx.FieldAPIBase:
  44699. m.ClearAPIBase()
  44700. return nil
  44701. case wx.FieldAPIKey:
  44702. m.ClearAPIKey()
  44703. return nil
  44704. case wx.FieldCtype:
  44705. m.ClearCtype()
  44706. return nil
  44707. }
  44708. return fmt.Errorf("unknown Wx nullable field %s", name)
  44709. }
  44710. // ResetField resets all changes in the mutation for the field with the given name.
  44711. // It returns an error if the field is not defined in the schema.
  44712. func (m *WxMutation) ResetField(name string) error {
  44713. switch name {
  44714. case wx.FieldCreatedAt:
  44715. m.ResetCreatedAt()
  44716. return nil
  44717. case wx.FieldUpdatedAt:
  44718. m.ResetUpdatedAt()
  44719. return nil
  44720. case wx.FieldStatus:
  44721. m.ResetStatus()
  44722. return nil
  44723. case wx.FieldDeletedAt:
  44724. m.ResetDeletedAt()
  44725. return nil
  44726. case wx.FieldServerID:
  44727. m.ResetServerID()
  44728. return nil
  44729. case wx.FieldPort:
  44730. m.ResetPort()
  44731. return nil
  44732. case wx.FieldProcessID:
  44733. m.ResetProcessID()
  44734. return nil
  44735. case wx.FieldCallback:
  44736. m.ResetCallback()
  44737. return nil
  44738. case wx.FieldWxid:
  44739. m.ResetWxid()
  44740. return nil
  44741. case wx.FieldAccount:
  44742. m.ResetAccount()
  44743. return nil
  44744. case wx.FieldNickname:
  44745. m.ResetNickname()
  44746. return nil
  44747. case wx.FieldTel:
  44748. m.ResetTel()
  44749. return nil
  44750. case wx.FieldHeadBig:
  44751. m.ResetHeadBig()
  44752. return nil
  44753. case wx.FieldOrganizationID:
  44754. m.ResetOrganizationID()
  44755. return nil
  44756. case wx.FieldAgentID:
  44757. m.ResetAgentID()
  44758. return nil
  44759. case wx.FieldAPIBase:
  44760. m.ResetAPIBase()
  44761. return nil
  44762. case wx.FieldAPIKey:
  44763. m.ResetAPIKey()
  44764. return nil
  44765. case wx.FieldAllowList:
  44766. m.ResetAllowList()
  44767. return nil
  44768. case wx.FieldGroupAllowList:
  44769. m.ResetGroupAllowList()
  44770. return nil
  44771. case wx.FieldBlockList:
  44772. m.ResetBlockList()
  44773. return nil
  44774. case wx.FieldGroupBlockList:
  44775. m.ResetGroupBlockList()
  44776. return nil
  44777. case wx.FieldCtype:
  44778. m.ResetCtype()
  44779. return nil
  44780. }
  44781. return fmt.Errorf("unknown Wx field %s", name)
  44782. }
  44783. // AddedEdges returns all edge names that were set/added in this mutation.
  44784. func (m *WxMutation) AddedEdges() []string {
  44785. edges := make([]string, 0, 2)
  44786. if m.server != nil {
  44787. edges = append(edges, wx.EdgeServer)
  44788. }
  44789. if m.agent != nil {
  44790. edges = append(edges, wx.EdgeAgent)
  44791. }
  44792. return edges
  44793. }
  44794. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44795. // name in this mutation.
  44796. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  44797. switch name {
  44798. case wx.EdgeServer:
  44799. if id := m.server; id != nil {
  44800. return []ent.Value{*id}
  44801. }
  44802. case wx.EdgeAgent:
  44803. if id := m.agent; id != nil {
  44804. return []ent.Value{*id}
  44805. }
  44806. }
  44807. return nil
  44808. }
  44809. // RemovedEdges returns all edge names that were removed in this mutation.
  44810. func (m *WxMutation) RemovedEdges() []string {
  44811. edges := make([]string, 0, 2)
  44812. return edges
  44813. }
  44814. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44815. // the given name in this mutation.
  44816. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  44817. return nil
  44818. }
  44819. // ClearedEdges returns all edge names that were cleared in this mutation.
  44820. func (m *WxMutation) ClearedEdges() []string {
  44821. edges := make([]string, 0, 2)
  44822. if m.clearedserver {
  44823. edges = append(edges, wx.EdgeServer)
  44824. }
  44825. if m.clearedagent {
  44826. edges = append(edges, wx.EdgeAgent)
  44827. }
  44828. return edges
  44829. }
  44830. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44831. // was cleared in this mutation.
  44832. func (m *WxMutation) EdgeCleared(name string) bool {
  44833. switch name {
  44834. case wx.EdgeServer:
  44835. return m.clearedserver
  44836. case wx.EdgeAgent:
  44837. return m.clearedagent
  44838. }
  44839. return false
  44840. }
  44841. // ClearEdge clears the value of the edge with the given name. It returns an error
  44842. // if that edge is not defined in the schema.
  44843. func (m *WxMutation) ClearEdge(name string) error {
  44844. switch name {
  44845. case wx.EdgeServer:
  44846. m.ClearServer()
  44847. return nil
  44848. case wx.EdgeAgent:
  44849. m.ClearAgent()
  44850. return nil
  44851. }
  44852. return fmt.Errorf("unknown Wx unique edge %s", name)
  44853. }
  44854. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44855. // It returns an error if the edge is not defined in the schema.
  44856. func (m *WxMutation) ResetEdge(name string) error {
  44857. switch name {
  44858. case wx.EdgeServer:
  44859. m.ResetServer()
  44860. return nil
  44861. case wx.EdgeAgent:
  44862. m.ResetAgent()
  44863. return nil
  44864. }
  44865. return fmt.Errorf("unknown Wx edge %s", name)
  44866. }
  44867. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  44868. type WxCardMutation struct {
  44869. config
  44870. op Op
  44871. typ string
  44872. id *uint64
  44873. created_at *time.Time
  44874. updated_at *time.Time
  44875. deleted_at *time.Time
  44876. user_id *uint64
  44877. adduser_id *int64
  44878. wx_user_id *uint64
  44879. addwx_user_id *int64
  44880. avatar *string
  44881. logo *string
  44882. name *string
  44883. company *string
  44884. address *string
  44885. phone *string
  44886. official_account *string
  44887. wechat_account *string
  44888. email *string
  44889. api_base *string
  44890. api_key *string
  44891. ai_info *string
  44892. intro *string
  44893. clearedFields map[string]struct{}
  44894. done bool
  44895. oldValue func(context.Context) (*WxCard, error)
  44896. predicates []predicate.WxCard
  44897. }
  44898. var _ ent.Mutation = (*WxCardMutation)(nil)
  44899. // wxcardOption allows management of the mutation configuration using functional options.
  44900. type wxcardOption func(*WxCardMutation)
  44901. // newWxCardMutation creates new mutation for the WxCard entity.
  44902. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  44903. m := &WxCardMutation{
  44904. config: c,
  44905. op: op,
  44906. typ: TypeWxCard,
  44907. clearedFields: make(map[string]struct{}),
  44908. }
  44909. for _, opt := range opts {
  44910. opt(m)
  44911. }
  44912. return m
  44913. }
  44914. // withWxCardID sets the ID field of the mutation.
  44915. func withWxCardID(id uint64) wxcardOption {
  44916. return func(m *WxCardMutation) {
  44917. var (
  44918. err error
  44919. once sync.Once
  44920. value *WxCard
  44921. )
  44922. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  44923. once.Do(func() {
  44924. if m.done {
  44925. err = errors.New("querying old values post mutation is not allowed")
  44926. } else {
  44927. value, err = m.Client().WxCard.Get(ctx, id)
  44928. }
  44929. })
  44930. return value, err
  44931. }
  44932. m.id = &id
  44933. }
  44934. }
  44935. // withWxCard sets the old WxCard of the mutation.
  44936. func withWxCard(node *WxCard) wxcardOption {
  44937. return func(m *WxCardMutation) {
  44938. m.oldValue = func(context.Context) (*WxCard, error) {
  44939. return node, nil
  44940. }
  44941. m.id = &node.ID
  44942. }
  44943. }
  44944. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44945. // executed in a transaction (ent.Tx), a transactional client is returned.
  44946. func (m WxCardMutation) Client() *Client {
  44947. client := &Client{config: m.config}
  44948. client.init()
  44949. return client
  44950. }
  44951. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44952. // it returns an error otherwise.
  44953. func (m WxCardMutation) Tx() (*Tx, error) {
  44954. if _, ok := m.driver.(*txDriver); !ok {
  44955. return nil, errors.New("ent: mutation is not running in a transaction")
  44956. }
  44957. tx := &Tx{config: m.config}
  44958. tx.init()
  44959. return tx, nil
  44960. }
  44961. // SetID sets the value of the id field. Note that this
  44962. // operation is only accepted on creation of WxCard entities.
  44963. func (m *WxCardMutation) SetID(id uint64) {
  44964. m.id = &id
  44965. }
  44966. // ID returns the ID value in the mutation. Note that the ID is only available
  44967. // if it was provided to the builder or after it was returned from the database.
  44968. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  44969. if m.id == nil {
  44970. return
  44971. }
  44972. return *m.id, true
  44973. }
  44974. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44975. // That means, if the mutation is applied within a transaction with an isolation level such
  44976. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44977. // or updated by the mutation.
  44978. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  44979. switch {
  44980. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44981. id, exists := m.ID()
  44982. if exists {
  44983. return []uint64{id}, nil
  44984. }
  44985. fallthrough
  44986. case m.op.Is(OpUpdate | OpDelete):
  44987. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  44988. default:
  44989. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44990. }
  44991. }
  44992. // SetCreatedAt sets the "created_at" field.
  44993. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  44994. m.created_at = &t
  44995. }
  44996. // CreatedAt returns the value of the "created_at" field in the mutation.
  44997. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  44998. v := m.created_at
  44999. if v == nil {
  45000. return
  45001. }
  45002. return *v, true
  45003. }
  45004. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  45005. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45007. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45008. if !m.op.Is(OpUpdateOne) {
  45009. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45010. }
  45011. if m.id == nil || m.oldValue == nil {
  45012. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45013. }
  45014. oldValue, err := m.oldValue(ctx)
  45015. if err != nil {
  45016. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45017. }
  45018. return oldValue.CreatedAt, nil
  45019. }
  45020. // ResetCreatedAt resets all changes to the "created_at" field.
  45021. func (m *WxCardMutation) ResetCreatedAt() {
  45022. m.created_at = nil
  45023. }
  45024. // SetUpdatedAt sets the "updated_at" field.
  45025. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  45026. m.updated_at = &t
  45027. }
  45028. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45029. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  45030. v := m.updated_at
  45031. if v == nil {
  45032. return
  45033. }
  45034. return *v, true
  45035. }
  45036. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  45037. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45039. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45040. if !m.op.Is(OpUpdateOne) {
  45041. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45042. }
  45043. if m.id == nil || m.oldValue == nil {
  45044. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45045. }
  45046. oldValue, err := m.oldValue(ctx)
  45047. if err != nil {
  45048. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45049. }
  45050. return oldValue.UpdatedAt, nil
  45051. }
  45052. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45053. func (m *WxCardMutation) ResetUpdatedAt() {
  45054. m.updated_at = nil
  45055. }
  45056. // SetDeletedAt sets the "deleted_at" field.
  45057. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  45058. m.deleted_at = &t
  45059. }
  45060. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45061. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  45062. v := m.deleted_at
  45063. if v == nil {
  45064. return
  45065. }
  45066. return *v, true
  45067. }
  45068. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  45069. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45071. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45072. if !m.op.Is(OpUpdateOne) {
  45073. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45074. }
  45075. if m.id == nil || m.oldValue == nil {
  45076. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45077. }
  45078. oldValue, err := m.oldValue(ctx)
  45079. if err != nil {
  45080. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45081. }
  45082. return oldValue.DeletedAt, nil
  45083. }
  45084. // ClearDeletedAt clears the value of the "deleted_at" field.
  45085. func (m *WxCardMutation) ClearDeletedAt() {
  45086. m.deleted_at = nil
  45087. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  45088. }
  45089. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45090. func (m *WxCardMutation) DeletedAtCleared() bool {
  45091. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  45092. return ok
  45093. }
  45094. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45095. func (m *WxCardMutation) ResetDeletedAt() {
  45096. m.deleted_at = nil
  45097. delete(m.clearedFields, wxcard.FieldDeletedAt)
  45098. }
  45099. // SetUserID sets the "user_id" field.
  45100. func (m *WxCardMutation) SetUserID(u uint64) {
  45101. m.user_id = &u
  45102. m.adduser_id = nil
  45103. }
  45104. // UserID returns the value of the "user_id" field in the mutation.
  45105. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  45106. v := m.user_id
  45107. if v == nil {
  45108. return
  45109. }
  45110. return *v, true
  45111. }
  45112. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  45113. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45115. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45116. if !m.op.Is(OpUpdateOne) {
  45117. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45118. }
  45119. if m.id == nil || m.oldValue == nil {
  45120. return v, errors.New("OldUserID requires an ID field in the mutation")
  45121. }
  45122. oldValue, err := m.oldValue(ctx)
  45123. if err != nil {
  45124. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45125. }
  45126. return oldValue.UserID, nil
  45127. }
  45128. // AddUserID adds u to the "user_id" field.
  45129. func (m *WxCardMutation) AddUserID(u int64) {
  45130. if m.adduser_id != nil {
  45131. *m.adduser_id += u
  45132. } else {
  45133. m.adduser_id = &u
  45134. }
  45135. }
  45136. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45137. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  45138. v := m.adduser_id
  45139. if v == nil {
  45140. return
  45141. }
  45142. return *v, true
  45143. }
  45144. // ClearUserID clears the value of the "user_id" field.
  45145. func (m *WxCardMutation) ClearUserID() {
  45146. m.user_id = nil
  45147. m.adduser_id = nil
  45148. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  45149. }
  45150. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45151. func (m *WxCardMutation) UserIDCleared() bool {
  45152. _, ok := m.clearedFields[wxcard.FieldUserID]
  45153. return ok
  45154. }
  45155. // ResetUserID resets all changes to the "user_id" field.
  45156. func (m *WxCardMutation) ResetUserID() {
  45157. m.user_id = nil
  45158. m.adduser_id = nil
  45159. delete(m.clearedFields, wxcard.FieldUserID)
  45160. }
  45161. // SetWxUserID sets the "wx_user_id" field.
  45162. func (m *WxCardMutation) SetWxUserID(u uint64) {
  45163. m.wx_user_id = &u
  45164. m.addwx_user_id = nil
  45165. }
  45166. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  45167. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  45168. v := m.wx_user_id
  45169. if v == nil {
  45170. return
  45171. }
  45172. return *v, true
  45173. }
  45174. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  45175. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45177. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  45178. if !m.op.Is(OpUpdateOne) {
  45179. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  45180. }
  45181. if m.id == nil || m.oldValue == nil {
  45182. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  45183. }
  45184. oldValue, err := m.oldValue(ctx)
  45185. if err != nil {
  45186. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  45187. }
  45188. return oldValue.WxUserID, nil
  45189. }
  45190. // AddWxUserID adds u to the "wx_user_id" field.
  45191. func (m *WxCardMutation) AddWxUserID(u int64) {
  45192. if m.addwx_user_id != nil {
  45193. *m.addwx_user_id += u
  45194. } else {
  45195. m.addwx_user_id = &u
  45196. }
  45197. }
  45198. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  45199. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  45200. v := m.addwx_user_id
  45201. if v == nil {
  45202. return
  45203. }
  45204. return *v, true
  45205. }
  45206. // ClearWxUserID clears the value of the "wx_user_id" field.
  45207. func (m *WxCardMutation) ClearWxUserID() {
  45208. m.wx_user_id = nil
  45209. m.addwx_user_id = nil
  45210. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  45211. }
  45212. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  45213. func (m *WxCardMutation) WxUserIDCleared() bool {
  45214. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  45215. return ok
  45216. }
  45217. // ResetWxUserID resets all changes to the "wx_user_id" field.
  45218. func (m *WxCardMutation) ResetWxUserID() {
  45219. m.wx_user_id = nil
  45220. m.addwx_user_id = nil
  45221. delete(m.clearedFields, wxcard.FieldWxUserID)
  45222. }
  45223. // SetAvatar sets the "avatar" field.
  45224. func (m *WxCardMutation) SetAvatar(s string) {
  45225. m.avatar = &s
  45226. }
  45227. // Avatar returns the value of the "avatar" field in the mutation.
  45228. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  45229. v := m.avatar
  45230. if v == nil {
  45231. return
  45232. }
  45233. return *v, true
  45234. }
  45235. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  45236. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45238. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45239. if !m.op.Is(OpUpdateOne) {
  45240. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45241. }
  45242. if m.id == nil || m.oldValue == nil {
  45243. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45244. }
  45245. oldValue, err := m.oldValue(ctx)
  45246. if err != nil {
  45247. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45248. }
  45249. return oldValue.Avatar, nil
  45250. }
  45251. // ResetAvatar resets all changes to the "avatar" field.
  45252. func (m *WxCardMutation) ResetAvatar() {
  45253. m.avatar = nil
  45254. }
  45255. // SetLogo sets the "logo" field.
  45256. func (m *WxCardMutation) SetLogo(s string) {
  45257. m.logo = &s
  45258. }
  45259. // Logo returns the value of the "logo" field in the mutation.
  45260. func (m *WxCardMutation) Logo() (r string, exists bool) {
  45261. v := m.logo
  45262. if v == nil {
  45263. return
  45264. }
  45265. return *v, true
  45266. }
  45267. // OldLogo returns the old "logo" field's value of the WxCard entity.
  45268. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45270. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  45271. if !m.op.Is(OpUpdateOne) {
  45272. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  45273. }
  45274. if m.id == nil || m.oldValue == nil {
  45275. return v, errors.New("OldLogo requires an ID field in the mutation")
  45276. }
  45277. oldValue, err := m.oldValue(ctx)
  45278. if err != nil {
  45279. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  45280. }
  45281. return oldValue.Logo, nil
  45282. }
  45283. // ResetLogo resets all changes to the "logo" field.
  45284. func (m *WxCardMutation) ResetLogo() {
  45285. m.logo = nil
  45286. }
  45287. // SetName sets the "name" field.
  45288. func (m *WxCardMutation) SetName(s string) {
  45289. m.name = &s
  45290. }
  45291. // Name returns the value of the "name" field in the mutation.
  45292. func (m *WxCardMutation) Name() (r string, exists bool) {
  45293. v := m.name
  45294. if v == nil {
  45295. return
  45296. }
  45297. return *v, true
  45298. }
  45299. // OldName returns the old "name" field's value of the WxCard entity.
  45300. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45302. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  45303. if !m.op.Is(OpUpdateOne) {
  45304. return v, errors.New("OldName is only allowed on UpdateOne operations")
  45305. }
  45306. if m.id == nil || m.oldValue == nil {
  45307. return v, errors.New("OldName requires an ID field in the mutation")
  45308. }
  45309. oldValue, err := m.oldValue(ctx)
  45310. if err != nil {
  45311. return v, fmt.Errorf("querying old value for OldName: %w", err)
  45312. }
  45313. return oldValue.Name, nil
  45314. }
  45315. // ResetName resets all changes to the "name" field.
  45316. func (m *WxCardMutation) ResetName() {
  45317. m.name = nil
  45318. }
  45319. // SetCompany sets the "company" field.
  45320. func (m *WxCardMutation) SetCompany(s string) {
  45321. m.company = &s
  45322. }
  45323. // Company returns the value of the "company" field in the mutation.
  45324. func (m *WxCardMutation) Company() (r string, exists bool) {
  45325. v := m.company
  45326. if v == nil {
  45327. return
  45328. }
  45329. return *v, true
  45330. }
  45331. // OldCompany returns the old "company" field's value of the WxCard entity.
  45332. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45334. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  45335. if !m.op.Is(OpUpdateOne) {
  45336. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45337. }
  45338. if m.id == nil || m.oldValue == nil {
  45339. return v, errors.New("OldCompany requires an ID field in the mutation")
  45340. }
  45341. oldValue, err := m.oldValue(ctx)
  45342. if err != nil {
  45343. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45344. }
  45345. return oldValue.Company, nil
  45346. }
  45347. // ResetCompany resets all changes to the "company" field.
  45348. func (m *WxCardMutation) ResetCompany() {
  45349. m.company = nil
  45350. }
  45351. // SetAddress sets the "address" field.
  45352. func (m *WxCardMutation) SetAddress(s string) {
  45353. m.address = &s
  45354. }
  45355. // Address returns the value of the "address" field in the mutation.
  45356. func (m *WxCardMutation) Address() (r string, exists bool) {
  45357. v := m.address
  45358. if v == nil {
  45359. return
  45360. }
  45361. return *v, true
  45362. }
  45363. // OldAddress returns the old "address" field's value of the WxCard entity.
  45364. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45366. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  45367. if !m.op.Is(OpUpdateOne) {
  45368. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  45369. }
  45370. if m.id == nil || m.oldValue == nil {
  45371. return v, errors.New("OldAddress requires an ID field in the mutation")
  45372. }
  45373. oldValue, err := m.oldValue(ctx)
  45374. if err != nil {
  45375. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  45376. }
  45377. return oldValue.Address, nil
  45378. }
  45379. // ResetAddress resets all changes to the "address" field.
  45380. func (m *WxCardMutation) ResetAddress() {
  45381. m.address = nil
  45382. }
  45383. // SetPhone sets the "phone" field.
  45384. func (m *WxCardMutation) SetPhone(s string) {
  45385. m.phone = &s
  45386. }
  45387. // Phone returns the value of the "phone" field in the mutation.
  45388. func (m *WxCardMutation) Phone() (r string, exists bool) {
  45389. v := m.phone
  45390. if v == nil {
  45391. return
  45392. }
  45393. return *v, true
  45394. }
  45395. // OldPhone returns the old "phone" field's value of the WxCard entity.
  45396. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45398. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  45399. if !m.op.Is(OpUpdateOne) {
  45400. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45401. }
  45402. if m.id == nil || m.oldValue == nil {
  45403. return v, errors.New("OldPhone requires an ID field in the mutation")
  45404. }
  45405. oldValue, err := m.oldValue(ctx)
  45406. if err != nil {
  45407. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45408. }
  45409. return oldValue.Phone, nil
  45410. }
  45411. // ResetPhone resets all changes to the "phone" field.
  45412. func (m *WxCardMutation) ResetPhone() {
  45413. m.phone = nil
  45414. }
  45415. // SetOfficialAccount sets the "official_account" field.
  45416. func (m *WxCardMutation) SetOfficialAccount(s string) {
  45417. m.official_account = &s
  45418. }
  45419. // OfficialAccount returns the value of the "official_account" field in the mutation.
  45420. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  45421. v := m.official_account
  45422. if v == nil {
  45423. return
  45424. }
  45425. return *v, true
  45426. }
  45427. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  45428. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45430. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  45431. if !m.op.Is(OpUpdateOne) {
  45432. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  45433. }
  45434. if m.id == nil || m.oldValue == nil {
  45435. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  45436. }
  45437. oldValue, err := m.oldValue(ctx)
  45438. if err != nil {
  45439. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  45440. }
  45441. return oldValue.OfficialAccount, nil
  45442. }
  45443. // ResetOfficialAccount resets all changes to the "official_account" field.
  45444. func (m *WxCardMutation) ResetOfficialAccount() {
  45445. m.official_account = nil
  45446. }
  45447. // SetWechatAccount sets the "wechat_account" field.
  45448. func (m *WxCardMutation) SetWechatAccount(s string) {
  45449. m.wechat_account = &s
  45450. }
  45451. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  45452. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  45453. v := m.wechat_account
  45454. if v == nil {
  45455. return
  45456. }
  45457. return *v, true
  45458. }
  45459. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  45460. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45462. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  45463. if !m.op.Is(OpUpdateOne) {
  45464. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  45465. }
  45466. if m.id == nil || m.oldValue == nil {
  45467. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  45468. }
  45469. oldValue, err := m.oldValue(ctx)
  45470. if err != nil {
  45471. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  45472. }
  45473. return oldValue.WechatAccount, nil
  45474. }
  45475. // ResetWechatAccount resets all changes to the "wechat_account" field.
  45476. func (m *WxCardMutation) ResetWechatAccount() {
  45477. m.wechat_account = nil
  45478. }
  45479. // SetEmail sets the "email" field.
  45480. func (m *WxCardMutation) SetEmail(s string) {
  45481. m.email = &s
  45482. }
  45483. // Email returns the value of the "email" field in the mutation.
  45484. func (m *WxCardMutation) Email() (r string, exists bool) {
  45485. v := m.email
  45486. if v == nil {
  45487. return
  45488. }
  45489. return *v, true
  45490. }
  45491. // OldEmail returns the old "email" field's value of the WxCard entity.
  45492. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45494. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  45495. if !m.op.Is(OpUpdateOne) {
  45496. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  45497. }
  45498. if m.id == nil || m.oldValue == nil {
  45499. return v, errors.New("OldEmail requires an ID field in the mutation")
  45500. }
  45501. oldValue, err := m.oldValue(ctx)
  45502. if err != nil {
  45503. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  45504. }
  45505. return oldValue.Email, nil
  45506. }
  45507. // ClearEmail clears the value of the "email" field.
  45508. func (m *WxCardMutation) ClearEmail() {
  45509. m.email = nil
  45510. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  45511. }
  45512. // EmailCleared returns if the "email" field was cleared in this mutation.
  45513. func (m *WxCardMutation) EmailCleared() bool {
  45514. _, ok := m.clearedFields[wxcard.FieldEmail]
  45515. return ok
  45516. }
  45517. // ResetEmail resets all changes to the "email" field.
  45518. func (m *WxCardMutation) ResetEmail() {
  45519. m.email = nil
  45520. delete(m.clearedFields, wxcard.FieldEmail)
  45521. }
  45522. // SetAPIBase sets the "api_base" field.
  45523. func (m *WxCardMutation) SetAPIBase(s string) {
  45524. m.api_base = &s
  45525. }
  45526. // APIBase returns the value of the "api_base" field in the mutation.
  45527. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  45528. v := m.api_base
  45529. if v == nil {
  45530. return
  45531. }
  45532. return *v, true
  45533. }
  45534. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  45535. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45537. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45538. if !m.op.Is(OpUpdateOne) {
  45539. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45540. }
  45541. if m.id == nil || m.oldValue == nil {
  45542. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45543. }
  45544. oldValue, err := m.oldValue(ctx)
  45545. if err != nil {
  45546. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45547. }
  45548. return oldValue.APIBase, nil
  45549. }
  45550. // ClearAPIBase clears the value of the "api_base" field.
  45551. func (m *WxCardMutation) ClearAPIBase() {
  45552. m.api_base = nil
  45553. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  45554. }
  45555. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45556. func (m *WxCardMutation) APIBaseCleared() bool {
  45557. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  45558. return ok
  45559. }
  45560. // ResetAPIBase resets all changes to the "api_base" field.
  45561. func (m *WxCardMutation) ResetAPIBase() {
  45562. m.api_base = nil
  45563. delete(m.clearedFields, wxcard.FieldAPIBase)
  45564. }
  45565. // SetAPIKey sets the "api_key" field.
  45566. func (m *WxCardMutation) SetAPIKey(s string) {
  45567. m.api_key = &s
  45568. }
  45569. // APIKey returns the value of the "api_key" field in the mutation.
  45570. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  45571. v := m.api_key
  45572. if v == nil {
  45573. return
  45574. }
  45575. return *v, true
  45576. }
  45577. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  45578. // If the WxCard 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 *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45581. if !m.op.Is(OpUpdateOne) {
  45582. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45583. }
  45584. if m.id == nil || m.oldValue == nil {
  45585. return v, errors.New("OldAPIKey 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 OldAPIKey: %w", err)
  45590. }
  45591. return oldValue.APIKey, nil
  45592. }
  45593. // ClearAPIKey clears the value of the "api_key" field.
  45594. func (m *WxCardMutation) ClearAPIKey() {
  45595. m.api_key = nil
  45596. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  45597. }
  45598. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45599. func (m *WxCardMutation) APIKeyCleared() bool {
  45600. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  45601. return ok
  45602. }
  45603. // ResetAPIKey resets all changes to the "api_key" field.
  45604. func (m *WxCardMutation) ResetAPIKey() {
  45605. m.api_key = nil
  45606. delete(m.clearedFields, wxcard.FieldAPIKey)
  45607. }
  45608. // SetAiInfo sets the "ai_info" field.
  45609. func (m *WxCardMutation) SetAiInfo(s string) {
  45610. m.ai_info = &s
  45611. }
  45612. // AiInfo returns the value of the "ai_info" field in the mutation.
  45613. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  45614. v := m.ai_info
  45615. if v == nil {
  45616. return
  45617. }
  45618. return *v, true
  45619. }
  45620. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  45621. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45623. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  45624. if !m.op.Is(OpUpdateOne) {
  45625. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  45626. }
  45627. if m.id == nil || m.oldValue == nil {
  45628. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  45629. }
  45630. oldValue, err := m.oldValue(ctx)
  45631. if err != nil {
  45632. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  45633. }
  45634. return oldValue.AiInfo, nil
  45635. }
  45636. // ClearAiInfo clears the value of the "ai_info" field.
  45637. func (m *WxCardMutation) ClearAiInfo() {
  45638. m.ai_info = nil
  45639. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  45640. }
  45641. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  45642. func (m *WxCardMutation) AiInfoCleared() bool {
  45643. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  45644. return ok
  45645. }
  45646. // ResetAiInfo resets all changes to the "ai_info" field.
  45647. func (m *WxCardMutation) ResetAiInfo() {
  45648. m.ai_info = nil
  45649. delete(m.clearedFields, wxcard.FieldAiInfo)
  45650. }
  45651. // SetIntro sets the "intro" field.
  45652. func (m *WxCardMutation) SetIntro(s string) {
  45653. m.intro = &s
  45654. }
  45655. // Intro returns the value of the "intro" field in the mutation.
  45656. func (m *WxCardMutation) Intro() (r string, exists bool) {
  45657. v := m.intro
  45658. if v == nil {
  45659. return
  45660. }
  45661. return *v, true
  45662. }
  45663. // OldIntro returns the old "intro" field's value of the WxCard entity.
  45664. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  45665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45666. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  45667. if !m.op.Is(OpUpdateOne) {
  45668. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  45669. }
  45670. if m.id == nil || m.oldValue == nil {
  45671. return v, errors.New("OldIntro requires an ID field in the mutation")
  45672. }
  45673. oldValue, err := m.oldValue(ctx)
  45674. if err != nil {
  45675. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  45676. }
  45677. return oldValue.Intro, nil
  45678. }
  45679. // ClearIntro clears the value of the "intro" field.
  45680. func (m *WxCardMutation) ClearIntro() {
  45681. m.intro = nil
  45682. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  45683. }
  45684. // IntroCleared returns if the "intro" field was cleared in this mutation.
  45685. func (m *WxCardMutation) IntroCleared() bool {
  45686. _, ok := m.clearedFields[wxcard.FieldIntro]
  45687. return ok
  45688. }
  45689. // ResetIntro resets all changes to the "intro" field.
  45690. func (m *WxCardMutation) ResetIntro() {
  45691. m.intro = nil
  45692. delete(m.clearedFields, wxcard.FieldIntro)
  45693. }
  45694. // Where appends a list predicates to the WxCardMutation builder.
  45695. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  45696. m.predicates = append(m.predicates, ps...)
  45697. }
  45698. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  45699. // users can use type-assertion to append predicates that do not depend on any generated package.
  45700. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  45701. p := make([]predicate.WxCard, len(ps))
  45702. for i := range ps {
  45703. p[i] = ps[i]
  45704. }
  45705. m.Where(p...)
  45706. }
  45707. // Op returns the operation name.
  45708. func (m *WxCardMutation) Op() Op {
  45709. return m.op
  45710. }
  45711. // SetOp allows setting the mutation operation.
  45712. func (m *WxCardMutation) SetOp(op Op) {
  45713. m.op = op
  45714. }
  45715. // Type returns the node type of this mutation (WxCard).
  45716. func (m *WxCardMutation) Type() string {
  45717. return m.typ
  45718. }
  45719. // Fields returns all fields that were changed during this mutation. Note that in
  45720. // order to get all numeric fields that were incremented/decremented, call
  45721. // AddedFields().
  45722. func (m *WxCardMutation) Fields() []string {
  45723. fields := make([]string, 0, 18)
  45724. if m.created_at != nil {
  45725. fields = append(fields, wxcard.FieldCreatedAt)
  45726. }
  45727. if m.updated_at != nil {
  45728. fields = append(fields, wxcard.FieldUpdatedAt)
  45729. }
  45730. if m.deleted_at != nil {
  45731. fields = append(fields, wxcard.FieldDeletedAt)
  45732. }
  45733. if m.user_id != nil {
  45734. fields = append(fields, wxcard.FieldUserID)
  45735. }
  45736. if m.wx_user_id != nil {
  45737. fields = append(fields, wxcard.FieldWxUserID)
  45738. }
  45739. if m.avatar != nil {
  45740. fields = append(fields, wxcard.FieldAvatar)
  45741. }
  45742. if m.logo != nil {
  45743. fields = append(fields, wxcard.FieldLogo)
  45744. }
  45745. if m.name != nil {
  45746. fields = append(fields, wxcard.FieldName)
  45747. }
  45748. if m.company != nil {
  45749. fields = append(fields, wxcard.FieldCompany)
  45750. }
  45751. if m.address != nil {
  45752. fields = append(fields, wxcard.FieldAddress)
  45753. }
  45754. if m.phone != nil {
  45755. fields = append(fields, wxcard.FieldPhone)
  45756. }
  45757. if m.official_account != nil {
  45758. fields = append(fields, wxcard.FieldOfficialAccount)
  45759. }
  45760. if m.wechat_account != nil {
  45761. fields = append(fields, wxcard.FieldWechatAccount)
  45762. }
  45763. if m.email != nil {
  45764. fields = append(fields, wxcard.FieldEmail)
  45765. }
  45766. if m.api_base != nil {
  45767. fields = append(fields, wxcard.FieldAPIBase)
  45768. }
  45769. if m.api_key != nil {
  45770. fields = append(fields, wxcard.FieldAPIKey)
  45771. }
  45772. if m.ai_info != nil {
  45773. fields = append(fields, wxcard.FieldAiInfo)
  45774. }
  45775. if m.intro != nil {
  45776. fields = append(fields, wxcard.FieldIntro)
  45777. }
  45778. return fields
  45779. }
  45780. // Field returns the value of a field with the given name. The second boolean
  45781. // return value indicates that this field was not set, or was not defined in the
  45782. // schema.
  45783. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  45784. switch name {
  45785. case wxcard.FieldCreatedAt:
  45786. return m.CreatedAt()
  45787. case wxcard.FieldUpdatedAt:
  45788. return m.UpdatedAt()
  45789. case wxcard.FieldDeletedAt:
  45790. return m.DeletedAt()
  45791. case wxcard.FieldUserID:
  45792. return m.UserID()
  45793. case wxcard.FieldWxUserID:
  45794. return m.WxUserID()
  45795. case wxcard.FieldAvatar:
  45796. return m.Avatar()
  45797. case wxcard.FieldLogo:
  45798. return m.Logo()
  45799. case wxcard.FieldName:
  45800. return m.Name()
  45801. case wxcard.FieldCompany:
  45802. return m.Company()
  45803. case wxcard.FieldAddress:
  45804. return m.Address()
  45805. case wxcard.FieldPhone:
  45806. return m.Phone()
  45807. case wxcard.FieldOfficialAccount:
  45808. return m.OfficialAccount()
  45809. case wxcard.FieldWechatAccount:
  45810. return m.WechatAccount()
  45811. case wxcard.FieldEmail:
  45812. return m.Email()
  45813. case wxcard.FieldAPIBase:
  45814. return m.APIBase()
  45815. case wxcard.FieldAPIKey:
  45816. return m.APIKey()
  45817. case wxcard.FieldAiInfo:
  45818. return m.AiInfo()
  45819. case wxcard.FieldIntro:
  45820. return m.Intro()
  45821. }
  45822. return nil, false
  45823. }
  45824. // OldField returns the old value of the field from the database. An error is
  45825. // returned if the mutation operation is not UpdateOne, or the query to the
  45826. // database failed.
  45827. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45828. switch name {
  45829. case wxcard.FieldCreatedAt:
  45830. return m.OldCreatedAt(ctx)
  45831. case wxcard.FieldUpdatedAt:
  45832. return m.OldUpdatedAt(ctx)
  45833. case wxcard.FieldDeletedAt:
  45834. return m.OldDeletedAt(ctx)
  45835. case wxcard.FieldUserID:
  45836. return m.OldUserID(ctx)
  45837. case wxcard.FieldWxUserID:
  45838. return m.OldWxUserID(ctx)
  45839. case wxcard.FieldAvatar:
  45840. return m.OldAvatar(ctx)
  45841. case wxcard.FieldLogo:
  45842. return m.OldLogo(ctx)
  45843. case wxcard.FieldName:
  45844. return m.OldName(ctx)
  45845. case wxcard.FieldCompany:
  45846. return m.OldCompany(ctx)
  45847. case wxcard.FieldAddress:
  45848. return m.OldAddress(ctx)
  45849. case wxcard.FieldPhone:
  45850. return m.OldPhone(ctx)
  45851. case wxcard.FieldOfficialAccount:
  45852. return m.OldOfficialAccount(ctx)
  45853. case wxcard.FieldWechatAccount:
  45854. return m.OldWechatAccount(ctx)
  45855. case wxcard.FieldEmail:
  45856. return m.OldEmail(ctx)
  45857. case wxcard.FieldAPIBase:
  45858. return m.OldAPIBase(ctx)
  45859. case wxcard.FieldAPIKey:
  45860. return m.OldAPIKey(ctx)
  45861. case wxcard.FieldAiInfo:
  45862. return m.OldAiInfo(ctx)
  45863. case wxcard.FieldIntro:
  45864. return m.OldIntro(ctx)
  45865. }
  45866. return nil, fmt.Errorf("unknown WxCard field %s", name)
  45867. }
  45868. // SetField sets the value of a field with the given name. It returns an error if
  45869. // the field is not defined in the schema, or if the type mismatched the field
  45870. // type.
  45871. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  45872. switch name {
  45873. case wxcard.FieldCreatedAt:
  45874. v, ok := value.(time.Time)
  45875. if !ok {
  45876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45877. }
  45878. m.SetCreatedAt(v)
  45879. return nil
  45880. case wxcard.FieldUpdatedAt:
  45881. v, ok := value.(time.Time)
  45882. if !ok {
  45883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45884. }
  45885. m.SetUpdatedAt(v)
  45886. return nil
  45887. case wxcard.FieldDeletedAt:
  45888. v, ok := value.(time.Time)
  45889. if !ok {
  45890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45891. }
  45892. m.SetDeletedAt(v)
  45893. return nil
  45894. case wxcard.FieldUserID:
  45895. v, ok := value.(uint64)
  45896. if !ok {
  45897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45898. }
  45899. m.SetUserID(v)
  45900. return nil
  45901. case wxcard.FieldWxUserID:
  45902. v, ok := value.(uint64)
  45903. if !ok {
  45904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45905. }
  45906. m.SetWxUserID(v)
  45907. return nil
  45908. case wxcard.FieldAvatar:
  45909. v, ok := value.(string)
  45910. if !ok {
  45911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45912. }
  45913. m.SetAvatar(v)
  45914. return nil
  45915. case wxcard.FieldLogo:
  45916. v, ok := value.(string)
  45917. if !ok {
  45918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45919. }
  45920. m.SetLogo(v)
  45921. return nil
  45922. case wxcard.FieldName:
  45923. v, ok := value.(string)
  45924. if !ok {
  45925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45926. }
  45927. m.SetName(v)
  45928. return nil
  45929. case wxcard.FieldCompany:
  45930. v, ok := value.(string)
  45931. if !ok {
  45932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45933. }
  45934. m.SetCompany(v)
  45935. return nil
  45936. case wxcard.FieldAddress:
  45937. v, ok := value.(string)
  45938. if !ok {
  45939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45940. }
  45941. m.SetAddress(v)
  45942. return nil
  45943. case wxcard.FieldPhone:
  45944. v, ok := value.(string)
  45945. if !ok {
  45946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45947. }
  45948. m.SetPhone(v)
  45949. return nil
  45950. case wxcard.FieldOfficialAccount:
  45951. v, ok := value.(string)
  45952. if !ok {
  45953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45954. }
  45955. m.SetOfficialAccount(v)
  45956. return nil
  45957. case wxcard.FieldWechatAccount:
  45958. v, ok := value.(string)
  45959. if !ok {
  45960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45961. }
  45962. m.SetWechatAccount(v)
  45963. return nil
  45964. case wxcard.FieldEmail:
  45965. v, ok := value.(string)
  45966. if !ok {
  45967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45968. }
  45969. m.SetEmail(v)
  45970. return nil
  45971. case wxcard.FieldAPIBase:
  45972. v, ok := value.(string)
  45973. if !ok {
  45974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45975. }
  45976. m.SetAPIBase(v)
  45977. return nil
  45978. case wxcard.FieldAPIKey:
  45979. v, ok := value.(string)
  45980. if !ok {
  45981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45982. }
  45983. m.SetAPIKey(v)
  45984. return nil
  45985. case wxcard.FieldAiInfo:
  45986. v, ok := value.(string)
  45987. if !ok {
  45988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45989. }
  45990. m.SetAiInfo(v)
  45991. return nil
  45992. case wxcard.FieldIntro:
  45993. v, ok := value.(string)
  45994. if !ok {
  45995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45996. }
  45997. m.SetIntro(v)
  45998. return nil
  45999. }
  46000. return fmt.Errorf("unknown WxCard field %s", name)
  46001. }
  46002. // AddedFields returns all numeric fields that were incremented/decremented during
  46003. // this mutation.
  46004. func (m *WxCardMutation) AddedFields() []string {
  46005. var fields []string
  46006. if m.adduser_id != nil {
  46007. fields = append(fields, wxcard.FieldUserID)
  46008. }
  46009. if m.addwx_user_id != nil {
  46010. fields = append(fields, wxcard.FieldWxUserID)
  46011. }
  46012. return fields
  46013. }
  46014. // AddedField returns the numeric value that was incremented/decremented on a field
  46015. // with the given name. The second boolean return value indicates that this field
  46016. // was not set, or was not defined in the schema.
  46017. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  46018. switch name {
  46019. case wxcard.FieldUserID:
  46020. return m.AddedUserID()
  46021. case wxcard.FieldWxUserID:
  46022. return m.AddedWxUserID()
  46023. }
  46024. return nil, false
  46025. }
  46026. // AddField adds the value to the field with the given name. It returns an error if
  46027. // the field is not defined in the schema, or if the type mismatched the field
  46028. // type.
  46029. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  46030. switch name {
  46031. case wxcard.FieldUserID:
  46032. v, ok := value.(int64)
  46033. if !ok {
  46034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46035. }
  46036. m.AddUserID(v)
  46037. return nil
  46038. case wxcard.FieldWxUserID:
  46039. v, ok := value.(int64)
  46040. if !ok {
  46041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46042. }
  46043. m.AddWxUserID(v)
  46044. return nil
  46045. }
  46046. return fmt.Errorf("unknown WxCard numeric field %s", name)
  46047. }
  46048. // ClearedFields returns all nullable fields that were cleared during this
  46049. // mutation.
  46050. func (m *WxCardMutation) ClearedFields() []string {
  46051. var fields []string
  46052. if m.FieldCleared(wxcard.FieldDeletedAt) {
  46053. fields = append(fields, wxcard.FieldDeletedAt)
  46054. }
  46055. if m.FieldCleared(wxcard.FieldUserID) {
  46056. fields = append(fields, wxcard.FieldUserID)
  46057. }
  46058. if m.FieldCleared(wxcard.FieldWxUserID) {
  46059. fields = append(fields, wxcard.FieldWxUserID)
  46060. }
  46061. if m.FieldCleared(wxcard.FieldEmail) {
  46062. fields = append(fields, wxcard.FieldEmail)
  46063. }
  46064. if m.FieldCleared(wxcard.FieldAPIBase) {
  46065. fields = append(fields, wxcard.FieldAPIBase)
  46066. }
  46067. if m.FieldCleared(wxcard.FieldAPIKey) {
  46068. fields = append(fields, wxcard.FieldAPIKey)
  46069. }
  46070. if m.FieldCleared(wxcard.FieldAiInfo) {
  46071. fields = append(fields, wxcard.FieldAiInfo)
  46072. }
  46073. if m.FieldCleared(wxcard.FieldIntro) {
  46074. fields = append(fields, wxcard.FieldIntro)
  46075. }
  46076. return fields
  46077. }
  46078. // FieldCleared returns a boolean indicating if a field with the given name was
  46079. // cleared in this mutation.
  46080. func (m *WxCardMutation) FieldCleared(name string) bool {
  46081. _, ok := m.clearedFields[name]
  46082. return ok
  46083. }
  46084. // ClearField clears the value of the field with the given name. It returns an
  46085. // error if the field is not defined in the schema.
  46086. func (m *WxCardMutation) ClearField(name string) error {
  46087. switch name {
  46088. case wxcard.FieldDeletedAt:
  46089. m.ClearDeletedAt()
  46090. return nil
  46091. case wxcard.FieldUserID:
  46092. m.ClearUserID()
  46093. return nil
  46094. case wxcard.FieldWxUserID:
  46095. m.ClearWxUserID()
  46096. return nil
  46097. case wxcard.FieldEmail:
  46098. m.ClearEmail()
  46099. return nil
  46100. case wxcard.FieldAPIBase:
  46101. m.ClearAPIBase()
  46102. return nil
  46103. case wxcard.FieldAPIKey:
  46104. m.ClearAPIKey()
  46105. return nil
  46106. case wxcard.FieldAiInfo:
  46107. m.ClearAiInfo()
  46108. return nil
  46109. case wxcard.FieldIntro:
  46110. m.ClearIntro()
  46111. return nil
  46112. }
  46113. return fmt.Errorf("unknown WxCard nullable field %s", name)
  46114. }
  46115. // ResetField resets all changes in the mutation for the field with the given name.
  46116. // It returns an error if the field is not defined in the schema.
  46117. func (m *WxCardMutation) ResetField(name string) error {
  46118. switch name {
  46119. case wxcard.FieldCreatedAt:
  46120. m.ResetCreatedAt()
  46121. return nil
  46122. case wxcard.FieldUpdatedAt:
  46123. m.ResetUpdatedAt()
  46124. return nil
  46125. case wxcard.FieldDeletedAt:
  46126. m.ResetDeletedAt()
  46127. return nil
  46128. case wxcard.FieldUserID:
  46129. m.ResetUserID()
  46130. return nil
  46131. case wxcard.FieldWxUserID:
  46132. m.ResetWxUserID()
  46133. return nil
  46134. case wxcard.FieldAvatar:
  46135. m.ResetAvatar()
  46136. return nil
  46137. case wxcard.FieldLogo:
  46138. m.ResetLogo()
  46139. return nil
  46140. case wxcard.FieldName:
  46141. m.ResetName()
  46142. return nil
  46143. case wxcard.FieldCompany:
  46144. m.ResetCompany()
  46145. return nil
  46146. case wxcard.FieldAddress:
  46147. m.ResetAddress()
  46148. return nil
  46149. case wxcard.FieldPhone:
  46150. m.ResetPhone()
  46151. return nil
  46152. case wxcard.FieldOfficialAccount:
  46153. m.ResetOfficialAccount()
  46154. return nil
  46155. case wxcard.FieldWechatAccount:
  46156. m.ResetWechatAccount()
  46157. return nil
  46158. case wxcard.FieldEmail:
  46159. m.ResetEmail()
  46160. return nil
  46161. case wxcard.FieldAPIBase:
  46162. m.ResetAPIBase()
  46163. return nil
  46164. case wxcard.FieldAPIKey:
  46165. m.ResetAPIKey()
  46166. return nil
  46167. case wxcard.FieldAiInfo:
  46168. m.ResetAiInfo()
  46169. return nil
  46170. case wxcard.FieldIntro:
  46171. m.ResetIntro()
  46172. return nil
  46173. }
  46174. return fmt.Errorf("unknown WxCard field %s", name)
  46175. }
  46176. // AddedEdges returns all edge names that were set/added in this mutation.
  46177. func (m *WxCardMutation) AddedEdges() []string {
  46178. edges := make([]string, 0, 0)
  46179. return edges
  46180. }
  46181. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46182. // name in this mutation.
  46183. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  46184. return nil
  46185. }
  46186. // RemovedEdges returns all edge names that were removed in this mutation.
  46187. func (m *WxCardMutation) RemovedEdges() []string {
  46188. edges := make([]string, 0, 0)
  46189. return edges
  46190. }
  46191. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46192. // the given name in this mutation.
  46193. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  46194. return nil
  46195. }
  46196. // ClearedEdges returns all edge names that were cleared in this mutation.
  46197. func (m *WxCardMutation) ClearedEdges() []string {
  46198. edges := make([]string, 0, 0)
  46199. return edges
  46200. }
  46201. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46202. // was cleared in this mutation.
  46203. func (m *WxCardMutation) EdgeCleared(name string) bool {
  46204. return false
  46205. }
  46206. // ClearEdge clears the value of the edge with the given name. It returns an error
  46207. // if that edge is not defined in the schema.
  46208. func (m *WxCardMutation) ClearEdge(name string) error {
  46209. return fmt.Errorf("unknown WxCard unique edge %s", name)
  46210. }
  46211. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46212. // It returns an error if the edge is not defined in the schema.
  46213. func (m *WxCardMutation) ResetEdge(name string) error {
  46214. return fmt.Errorf("unknown WxCard edge %s", name)
  46215. }
  46216. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  46217. type WxCardUserMutation struct {
  46218. config
  46219. op Op
  46220. typ string
  46221. id *uint64
  46222. created_at *time.Time
  46223. updated_at *time.Time
  46224. deleted_at *time.Time
  46225. wxid *string
  46226. account *string
  46227. avatar *string
  46228. nickname *string
  46229. remark *string
  46230. phone *string
  46231. open_id *string
  46232. union_id *string
  46233. session_key *string
  46234. is_vip *int
  46235. addis_vip *int
  46236. clearedFields map[string]struct{}
  46237. done bool
  46238. oldValue func(context.Context) (*WxCardUser, error)
  46239. predicates []predicate.WxCardUser
  46240. }
  46241. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  46242. // wxcarduserOption allows management of the mutation configuration using functional options.
  46243. type wxcarduserOption func(*WxCardUserMutation)
  46244. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  46245. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  46246. m := &WxCardUserMutation{
  46247. config: c,
  46248. op: op,
  46249. typ: TypeWxCardUser,
  46250. clearedFields: make(map[string]struct{}),
  46251. }
  46252. for _, opt := range opts {
  46253. opt(m)
  46254. }
  46255. return m
  46256. }
  46257. // withWxCardUserID sets the ID field of the mutation.
  46258. func withWxCardUserID(id uint64) wxcarduserOption {
  46259. return func(m *WxCardUserMutation) {
  46260. var (
  46261. err error
  46262. once sync.Once
  46263. value *WxCardUser
  46264. )
  46265. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  46266. once.Do(func() {
  46267. if m.done {
  46268. err = errors.New("querying old values post mutation is not allowed")
  46269. } else {
  46270. value, err = m.Client().WxCardUser.Get(ctx, id)
  46271. }
  46272. })
  46273. return value, err
  46274. }
  46275. m.id = &id
  46276. }
  46277. }
  46278. // withWxCardUser sets the old WxCardUser of the mutation.
  46279. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  46280. return func(m *WxCardUserMutation) {
  46281. m.oldValue = func(context.Context) (*WxCardUser, error) {
  46282. return node, nil
  46283. }
  46284. m.id = &node.ID
  46285. }
  46286. }
  46287. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46288. // executed in a transaction (ent.Tx), a transactional client is returned.
  46289. func (m WxCardUserMutation) Client() *Client {
  46290. client := &Client{config: m.config}
  46291. client.init()
  46292. return client
  46293. }
  46294. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46295. // it returns an error otherwise.
  46296. func (m WxCardUserMutation) Tx() (*Tx, error) {
  46297. if _, ok := m.driver.(*txDriver); !ok {
  46298. return nil, errors.New("ent: mutation is not running in a transaction")
  46299. }
  46300. tx := &Tx{config: m.config}
  46301. tx.init()
  46302. return tx, nil
  46303. }
  46304. // SetID sets the value of the id field. Note that this
  46305. // operation is only accepted on creation of WxCardUser entities.
  46306. func (m *WxCardUserMutation) SetID(id uint64) {
  46307. m.id = &id
  46308. }
  46309. // ID returns the ID value in the mutation. Note that the ID is only available
  46310. // if it was provided to the builder or after it was returned from the database.
  46311. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  46312. if m.id == nil {
  46313. return
  46314. }
  46315. return *m.id, true
  46316. }
  46317. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46318. // That means, if the mutation is applied within a transaction with an isolation level such
  46319. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46320. // or updated by the mutation.
  46321. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  46322. switch {
  46323. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46324. id, exists := m.ID()
  46325. if exists {
  46326. return []uint64{id}, nil
  46327. }
  46328. fallthrough
  46329. case m.op.Is(OpUpdate | OpDelete):
  46330. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  46331. default:
  46332. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46333. }
  46334. }
  46335. // SetCreatedAt sets the "created_at" field.
  46336. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  46337. m.created_at = &t
  46338. }
  46339. // CreatedAt returns the value of the "created_at" field in the mutation.
  46340. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  46341. v := m.created_at
  46342. if v == nil {
  46343. return
  46344. }
  46345. return *v, true
  46346. }
  46347. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  46348. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46350. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46351. if !m.op.Is(OpUpdateOne) {
  46352. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46353. }
  46354. if m.id == nil || m.oldValue == nil {
  46355. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46356. }
  46357. oldValue, err := m.oldValue(ctx)
  46358. if err != nil {
  46359. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46360. }
  46361. return oldValue.CreatedAt, nil
  46362. }
  46363. // ResetCreatedAt resets all changes to the "created_at" field.
  46364. func (m *WxCardUserMutation) ResetCreatedAt() {
  46365. m.created_at = nil
  46366. }
  46367. // SetUpdatedAt sets the "updated_at" field.
  46368. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  46369. m.updated_at = &t
  46370. }
  46371. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46372. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  46373. v := m.updated_at
  46374. if v == nil {
  46375. return
  46376. }
  46377. return *v, true
  46378. }
  46379. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  46380. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46382. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46383. if !m.op.Is(OpUpdateOne) {
  46384. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46385. }
  46386. if m.id == nil || m.oldValue == nil {
  46387. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46388. }
  46389. oldValue, err := m.oldValue(ctx)
  46390. if err != nil {
  46391. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46392. }
  46393. return oldValue.UpdatedAt, nil
  46394. }
  46395. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46396. func (m *WxCardUserMutation) ResetUpdatedAt() {
  46397. m.updated_at = nil
  46398. }
  46399. // SetDeletedAt sets the "deleted_at" field.
  46400. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  46401. m.deleted_at = &t
  46402. }
  46403. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46404. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  46405. v := m.deleted_at
  46406. if v == nil {
  46407. return
  46408. }
  46409. return *v, true
  46410. }
  46411. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  46412. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46414. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46415. if !m.op.Is(OpUpdateOne) {
  46416. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46417. }
  46418. if m.id == nil || m.oldValue == nil {
  46419. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46420. }
  46421. oldValue, err := m.oldValue(ctx)
  46422. if err != nil {
  46423. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46424. }
  46425. return oldValue.DeletedAt, nil
  46426. }
  46427. // ClearDeletedAt clears the value of the "deleted_at" field.
  46428. func (m *WxCardUserMutation) ClearDeletedAt() {
  46429. m.deleted_at = nil
  46430. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  46431. }
  46432. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46433. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  46434. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  46435. return ok
  46436. }
  46437. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46438. func (m *WxCardUserMutation) ResetDeletedAt() {
  46439. m.deleted_at = nil
  46440. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  46441. }
  46442. // SetWxid sets the "wxid" field.
  46443. func (m *WxCardUserMutation) SetWxid(s string) {
  46444. m.wxid = &s
  46445. }
  46446. // Wxid returns the value of the "wxid" field in the mutation.
  46447. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  46448. v := m.wxid
  46449. if v == nil {
  46450. return
  46451. }
  46452. return *v, true
  46453. }
  46454. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  46455. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46457. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  46458. if !m.op.Is(OpUpdateOne) {
  46459. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46460. }
  46461. if m.id == nil || m.oldValue == nil {
  46462. return v, errors.New("OldWxid requires an ID field in the mutation")
  46463. }
  46464. oldValue, err := m.oldValue(ctx)
  46465. if err != nil {
  46466. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46467. }
  46468. return oldValue.Wxid, nil
  46469. }
  46470. // ResetWxid resets all changes to the "wxid" field.
  46471. func (m *WxCardUserMutation) ResetWxid() {
  46472. m.wxid = nil
  46473. }
  46474. // SetAccount sets the "account" field.
  46475. func (m *WxCardUserMutation) SetAccount(s string) {
  46476. m.account = &s
  46477. }
  46478. // Account returns the value of the "account" field in the mutation.
  46479. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  46480. v := m.account
  46481. if v == nil {
  46482. return
  46483. }
  46484. return *v, true
  46485. }
  46486. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  46487. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46489. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  46490. if !m.op.Is(OpUpdateOne) {
  46491. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  46492. }
  46493. if m.id == nil || m.oldValue == nil {
  46494. return v, errors.New("OldAccount requires an ID field in the mutation")
  46495. }
  46496. oldValue, err := m.oldValue(ctx)
  46497. if err != nil {
  46498. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  46499. }
  46500. return oldValue.Account, nil
  46501. }
  46502. // ResetAccount resets all changes to the "account" field.
  46503. func (m *WxCardUserMutation) ResetAccount() {
  46504. m.account = nil
  46505. }
  46506. // SetAvatar sets the "avatar" field.
  46507. func (m *WxCardUserMutation) SetAvatar(s string) {
  46508. m.avatar = &s
  46509. }
  46510. // Avatar returns the value of the "avatar" field in the mutation.
  46511. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  46512. v := m.avatar
  46513. if v == nil {
  46514. return
  46515. }
  46516. return *v, true
  46517. }
  46518. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  46519. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46521. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46522. if !m.op.Is(OpUpdateOne) {
  46523. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46524. }
  46525. if m.id == nil || m.oldValue == nil {
  46526. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46527. }
  46528. oldValue, err := m.oldValue(ctx)
  46529. if err != nil {
  46530. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46531. }
  46532. return oldValue.Avatar, nil
  46533. }
  46534. // ResetAvatar resets all changes to the "avatar" field.
  46535. func (m *WxCardUserMutation) ResetAvatar() {
  46536. m.avatar = nil
  46537. }
  46538. // SetNickname sets the "nickname" field.
  46539. func (m *WxCardUserMutation) SetNickname(s string) {
  46540. m.nickname = &s
  46541. }
  46542. // Nickname returns the value of the "nickname" field in the mutation.
  46543. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  46544. v := m.nickname
  46545. if v == nil {
  46546. return
  46547. }
  46548. return *v, true
  46549. }
  46550. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  46551. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46553. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  46554. if !m.op.Is(OpUpdateOne) {
  46555. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46556. }
  46557. if m.id == nil || m.oldValue == nil {
  46558. return v, errors.New("OldNickname requires an ID field in the mutation")
  46559. }
  46560. oldValue, err := m.oldValue(ctx)
  46561. if err != nil {
  46562. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46563. }
  46564. return oldValue.Nickname, nil
  46565. }
  46566. // ResetNickname resets all changes to the "nickname" field.
  46567. func (m *WxCardUserMutation) ResetNickname() {
  46568. m.nickname = nil
  46569. }
  46570. // SetRemark sets the "remark" field.
  46571. func (m *WxCardUserMutation) SetRemark(s string) {
  46572. m.remark = &s
  46573. }
  46574. // Remark returns the value of the "remark" field in the mutation.
  46575. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  46576. v := m.remark
  46577. if v == nil {
  46578. return
  46579. }
  46580. return *v, true
  46581. }
  46582. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  46583. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46585. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  46586. if !m.op.Is(OpUpdateOne) {
  46587. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  46588. }
  46589. if m.id == nil || m.oldValue == nil {
  46590. return v, errors.New("OldRemark requires an ID field in the mutation")
  46591. }
  46592. oldValue, err := m.oldValue(ctx)
  46593. if err != nil {
  46594. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  46595. }
  46596. return oldValue.Remark, nil
  46597. }
  46598. // ResetRemark resets all changes to the "remark" field.
  46599. func (m *WxCardUserMutation) ResetRemark() {
  46600. m.remark = nil
  46601. }
  46602. // SetPhone sets the "phone" field.
  46603. func (m *WxCardUserMutation) SetPhone(s string) {
  46604. m.phone = &s
  46605. }
  46606. // Phone returns the value of the "phone" field in the mutation.
  46607. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  46608. v := m.phone
  46609. if v == nil {
  46610. return
  46611. }
  46612. return *v, true
  46613. }
  46614. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  46615. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46617. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  46618. if !m.op.Is(OpUpdateOne) {
  46619. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46620. }
  46621. if m.id == nil || m.oldValue == nil {
  46622. return v, errors.New("OldPhone requires an ID field in the mutation")
  46623. }
  46624. oldValue, err := m.oldValue(ctx)
  46625. if err != nil {
  46626. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46627. }
  46628. return oldValue.Phone, nil
  46629. }
  46630. // ResetPhone resets all changes to the "phone" field.
  46631. func (m *WxCardUserMutation) ResetPhone() {
  46632. m.phone = nil
  46633. }
  46634. // SetOpenID sets the "open_id" field.
  46635. func (m *WxCardUserMutation) SetOpenID(s string) {
  46636. m.open_id = &s
  46637. }
  46638. // OpenID returns the value of the "open_id" field in the mutation.
  46639. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  46640. v := m.open_id
  46641. if v == nil {
  46642. return
  46643. }
  46644. return *v, true
  46645. }
  46646. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  46647. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46649. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  46650. if !m.op.Is(OpUpdateOne) {
  46651. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  46652. }
  46653. if m.id == nil || m.oldValue == nil {
  46654. return v, errors.New("OldOpenID requires an ID field in the mutation")
  46655. }
  46656. oldValue, err := m.oldValue(ctx)
  46657. if err != nil {
  46658. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  46659. }
  46660. return oldValue.OpenID, nil
  46661. }
  46662. // ResetOpenID resets all changes to the "open_id" field.
  46663. func (m *WxCardUserMutation) ResetOpenID() {
  46664. m.open_id = nil
  46665. }
  46666. // SetUnionID sets the "union_id" field.
  46667. func (m *WxCardUserMutation) SetUnionID(s string) {
  46668. m.union_id = &s
  46669. }
  46670. // UnionID returns the value of the "union_id" field in the mutation.
  46671. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  46672. v := m.union_id
  46673. if v == nil {
  46674. return
  46675. }
  46676. return *v, true
  46677. }
  46678. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  46679. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46681. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  46682. if !m.op.Is(OpUpdateOne) {
  46683. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  46684. }
  46685. if m.id == nil || m.oldValue == nil {
  46686. return v, errors.New("OldUnionID requires an ID field in the mutation")
  46687. }
  46688. oldValue, err := m.oldValue(ctx)
  46689. if err != nil {
  46690. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  46691. }
  46692. return oldValue.UnionID, nil
  46693. }
  46694. // ResetUnionID resets all changes to the "union_id" field.
  46695. func (m *WxCardUserMutation) ResetUnionID() {
  46696. m.union_id = nil
  46697. }
  46698. // SetSessionKey sets the "session_key" field.
  46699. func (m *WxCardUserMutation) SetSessionKey(s string) {
  46700. m.session_key = &s
  46701. }
  46702. // SessionKey returns the value of the "session_key" field in the mutation.
  46703. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  46704. v := m.session_key
  46705. if v == nil {
  46706. return
  46707. }
  46708. return *v, true
  46709. }
  46710. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  46711. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46713. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  46714. if !m.op.Is(OpUpdateOne) {
  46715. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  46716. }
  46717. if m.id == nil || m.oldValue == nil {
  46718. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  46719. }
  46720. oldValue, err := m.oldValue(ctx)
  46721. if err != nil {
  46722. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  46723. }
  46724. return oldValue.SessionKey, nil
  46725. }
  46726. // ResetSessionKey resets all changes to the "session_key" field.
  46727. func (m *WxCardUserMutation) ResetSessionKey() {
  46728. m.session_key = nil
  46729. }
  46730. // SetIsVip sets the "is_vip" field.
  46731. func (m *WxCardUserMutation) SetIsVip(i int) {
  46732. m.is_vip = &i
  46733. m.addis_vip = nil
  46734. }
  46735. // IsVip returns the value of the "is_vip" field in the mutation.
  46736. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  46737. v := m.is_vip
  46738. if v == nil {
  46739. return
  46740. }
  46741. return *v, true
  46742. }
  46743. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  46744. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  46745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46746. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  46747. if !m.op.Is(OpUpdateOne) {
  46748. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  46749. }
  46750. if m.id == nil || m.oldValue == nil {
  46751. return v, errors.New("OldIsVip requires an ID field in the mutation")
  46752. }
  46753. oldValue, err := m.oldValue(ctx)
  46754. if err != nil {
  46755. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  46756. }
  46757. return oldValue.IsVip, nil
  46758. }
  46759. // AddIsVip adds i to the "is_vip" field.
  46760. func (m *WxCardUserMutation) AddIsVip(i int) {
  46761. if m.addis_vip != nil {
  46762. *m.addis_vip += i
  46763. } else {
  46764. m.addis_vip = &i
  46765. }
  46766. }
  46767. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  46768. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  46769. v := m.addis_vip
  46770. if v == nil {
  46771. return
  46772. }
  46773. return *v, true
  46774. }
  46775. // ResetIsVip resets all changes to the "is_vip" field.
  46776. func (m *WxCardUserMutation) ResetIsVip() {
  46777. m.is_vip = nil
  46778. m.addis_vip = nil
  46779. }
  46780. // Where appends a list predicates to the WxCardUserMutation builder.
  46781. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  46782. m.predicates = append(m.predicates, ps...)
  46783. }
  46784. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  46785. // users can use type-assertion to append predicates that do not depend on any generated package.
  46786. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  46787. p := make([]predicate.WxCardUser, len(ps))
  46788. for i := range ps {
  46789. p[i] = ps[i]
  46790. }
  46791. m.Where(p...)
  46792. }
  46793. // Op returns the operation name.
  46794. func (m *WxCardUserMutation) Op() Op {
  46795. return m.op
  46796. }
  46797. // SetOp allows setting the mutation operation.
  46798. func (m *WxCardUserMutation) SetOp(op Op) {
  46799. m.op = op
  46800. }
  46801. // Type returns the node type of this mutation (WxCardUser).
  46802. func (m *WxCardUserMutation) Type() string {
  46803. return m.typ
  46804. }
  46805. // Fields returns all fields that were changed during this mutation. Note that in
  46806. // order to get all numeric fields that were incremented/decremented, call
  46807. // AddedFields().
  46808. func (m *WxCardUserMutation) Fields() []string {
  46809. fields := make([]string, 0, 13)
  46810. if m.created_at != nil {
  46811. fields = append(fields, wxcarduser.FieldCreatedAt)
  46812. }
  46813. if m.updated_at != nil {
  46814. fields = append(fields, wxcarduser.FieldUpdatedAt)
  46815. }
  46816. if m.deleted_at != nil {
  46817. fields = append(fields, wxcarduser.FieldDeletedAt)
  46818. }
  46819. if m.wxid != nil {
  46820. fields = append(fields, wxcarduser.FieldWxid)
  46821. }
  46822. if m.account != nil {
  46823. fields = append(fields, wxcarduser.FieldAccount)
  46824. }
  46825. if m.avatar != nil {
  46826. fields = append(fields, wxcarduser.FieldAvatar)
  46827. }
  46828. if m.nickname != nil {
  46829. fields = append(fields, wxcarduser.FieldNickname)
  46830. }
  46831. if m.remark != nil {
  46832. fields = append(fields, wxcarduser.FieldRemark)
  46833. }
  46834. if m.phone != nil {
  46835. fields = append(fields, wxcarduser.FieldPhone)
  46836. }
  46837. if m.open_id != nil {
  46838. fields = append(fields, wxcarduser.FieldOpenID)
  46839. }
  46840. if m.union_id != nil {
  46841. fields = append(fields, wxcarduser.FieldUnionID)
  46842. }
  46843. if m.session_key != nil {
  46844. fields = append(fields, wxcarduser.FieldSessionKey)
  46845. }
  46846. if m.is_vip != nil {
  46847. fields = append(fields, wxcarduser.FieldIsVip)
  46848. }
  46849. return fields
  46850. }
  46851. // Field returns the value of a field with the given name. The second boolean
  46852. // return value indicates that this field was not set, or was not defined in the
  46853. // schema.
  46854. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  46855. switch name {
  46856. case wxcarduser.FieldCreatedAt:
  46857. return m.CreatedAt()
  46858. case wxcarduser.FieldUpdatedAt:
  46859. return m.UpdatedAt()
  46860. case wxcarduser.FieldDeletedAt:
  46861. return m.DeletedAt()
  46862. case wxcarduser.FieldWxid:
  46863. return m.Wxid()
  46864. case wxcarduser.FieldAccount:
  46865. return m.Account()
  46866. case wxcarduser.FieldAvatar:
  46867. return m.Avatar()
  46868. case wxcarduser.FieldNickname:
  46869. return m.Nickname()
  46870. case wxcarduser.FieldRemark:
  46871. return m.Remark()
  46872. case wxcarduser.FieldPhone:
  46873. return m.Phone()
  46874. case wxcarduser.FieldOpenID:
  46875. return m.OpenID()
  46876. case wxcarduser.FieldUnionID:
  46877. return m.UnionID()
  46878. case wxcarduser.FieldSessionKey:
  46879. return m.SessionKey()
  46880. case wxcarduser.FieldIsVip:
  46881. return m.IsVip()
  46882. }
  46883. return nil, false
  46884. }
  46885. // OldField returns the old value of the field from the database. An error is
  46886. // returned if the mutation operation is not UpdateOne, or the query to the
  46887. // database failed.
  46888. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46889. switch name {
  46890. case wxcarduser.FieldCreatedAt:
  46891. return m.OldCreatedAt(ctx)
  46892. case wxcarduser.FieldUpdatedAt:
  46893. return m.OldUpdatedAt(ctx)
  46894. case wxcarduser.FieldDeletedAt:
  46895. return m.OldDeletedAt(ctx)
  46896. case wxcarduser.FieldWxid:
  46897. return m.OldWxid(ctx)
  46898. case wxcarduser.FieldAccount:
  46899. return m.OldAccount(ctx)
  46900. case wxcarduser.FieldAvatar:
  46901. return m.OldAvatar(ctx)
  46902. case wxcarduser.FieldNickname:
  46903. return m.OldNickname(ctx)
  46904. case wxcarduser.FieldRemark:
  46905. return m.OldRemark(ctx)
  46906. case wxcarduser.FieldPhone:
  46907. return m.OldPhone(ctx)
  46908. case wxcarduser.FieldOpenID:
  46909. return m.OldOpenID(ctx)
  46910. case wxcarduser.FieldUnionID:
  46911. return m.OldUnionID(ctx)
  46912. case wxcarduser.FieldSessionKey:
  46913. return m.OldSessionKey(ctx)
  46914. case wxcarduser.FieldIsVip:
  46915. return m.OldIsVip(ctx)
  46916. }
  46917. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  46918. }
  46919. // SetField sets the value of a field with the given name. It returns an error if
  46920. // the field is not defined in the schema, or if the type mismatched the field
  46921. // type.
  46922. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  46923. switch name {
  46924. case wxcarduser.FieldCreatedAt:
  46925. v, ok := value.(time.Time)
  46926. if !ok {
  46927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46928. }
  46929. m.SetCreatedAt(v)
  46930. return nil
  46931. case wxcarduser.FieldUpdatedAt:
  46932. v, ok := value.(time.Time)
  46933. if !ok {
  46934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46935. }
  46936. m.SetUpdatedAt(v)
  46937. return nil
  46938. case wxcarduser.FieldDeletedAt:
  46939. v, ok := value.(time.Time)
  46940. if !ok {
  46941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46942. }
  46943. m.SetDeletedAt(v)
  46944. return nil
  46945. case wxcarduser.FieldWxid:
  46946. v, ok := value.(string)
  46947. if !ok {
  46948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46949. }
  46950. m.SetWxid(v)
  46951. return nil
  46952. case wxcarduser.FieldAccount:
  46953. v, ok := value.(string)
  46954. if !ok {
  46955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46956. }
  46957. m.SetAccount(v)
  46958. return nil
  46959. case wxcarduser.FieldAvatar:
  46960. v, ok := value.(string)
  46961. if !ok {
  46962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46963. }
  46964. m.SetAvatar(v)
  46965. return nil
  46966. case wxcarduser.FieldNickname:
  46967. v, ok := value.(string)
  46968. if !ok {
  46969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46970. }
  46971. m.SetNickname(v)
  46972. return nil
  46973. case wxcarduser.FieldRemark:
  46974. v, ok := value.(string)
  46975. if !ok {
  46976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46977. }
  46978. m.SetRemark(v)
  46979. return nil
  46980. case wxcarduser.FieldPhone:
  46981. v, ok := value.(string)
  46982. if !ok {
  46983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46984. }
  46985. m.SetPhone(v)
  46986. return nil
  46987. case wxcarduser.FieldOpenID:
  46988. v, ok := value.(string)
  46989. if !ok {
  46990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46991. }
  46992. m.SetOpenID(v)
  46993. return nil
  46994. case wxcarduser.FieldUnionID:
  46995. v, ok := value.(string)
  46996. if !ok {
  46997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46998. }
  46999. m.SetUnionID(v)
  47000. return nil
  47001. case wxcarduser.FieldSessionKey:
  47002. v, ok := value.(string)
  47003. if !ok {
  47004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47005. }
  47006. m.SetSessionKey(v)
  47007. return nil
  47008. case wxcarduser.FieldIsVip:
  47009. v, ok := value.(int)
  47010. if !ok {
  47011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47012. }
  47013. m.SetIsVip(v)
  47014. return nil
  47015. }
  47016. return fmt.Errorf("unknown WxCardUser field %s", name)
  47017. }
  47018. // AddedFields returns all numeric fields that were incremented/decremented during
  47019. // this mutation.
  47020. func (m *WxCardUserMutation) AddedFields() []string {
  47021. var fields []string
  47022. if m.addis_vip != nil {
  47023. fields = append(fields, wxcarduser.FieldIsVip)
  47024. }
  47025. return fields
  47026. }
  47027. // AddedField returns the numeric value that was incremented/decremented on a field
  47028. // with the given name. The second boolean return value indicates that this field
  47029. // was not set, or was not defined in the schema.
  47030. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  47031. switch name {
  47032. case wxcarduser.FieldIsVip:
  47033. return m.AddedIsVip()
  47034. }
  47035. return nil, false
  47036. }
  47037. // AddField adds the value to the field with the given name. It returns an error if
  47038. // the field is not defined in the schema, or if the type mismatched the field
  47039. // type.
  47040. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  47041. switch name {
  47042. case wxcarduser.FieldIsVip:
  47043. v, ok := value.(int)
  47044. if !ok {
  47045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47046. }
  47047. m.AddIsVip(v)
  47048. return nil
  47049. }
  47050. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  47051. }
  47052. // ClearedFields returns all nullable fields that were cleared during this
  47053. // mutation.
  47054. func (m *WxCardUserMutation) ClearedFields() []string {
  47055. var fields []string
  47056. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  47057. fields = append(fields, wxcarduser.FieldDeletedAt)
  47058. }
  47059. return fields
  47060. }
  47061. // FieldCleared returns a boolean indicating if a field with the given name was
  47062. // cleared in this mutation.
  47063. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  47064. _, ok := m.clearedFields[name]
  47065. return ok
  47066. }
  47067. // ClearField clears the value of the field with the given name. It returns an
  47068. // error if the field is not defined in the schema.
  47069. func (m *WxCardUserMutation) ClearField(name string) error {
  47070. switch name {
  47071. case wxcarduser.FieldDeletedAt:
  47072. m.ClearDeletedAt()
  47073. return nil
  47074. }
  47075. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  47076. }
  47077. // ResetField resets all changes in the mutation for the field with the given name.
  47078. // It returns an error if the field is not defined in the schema.
  47079. func (m *WxCardUserMutation) ResetField(name string) error {
  47080. switch name {
  47081. case wxcarduser.FieldCreatedAt:
  47082. m.ResetCreatedAt()
  47083. return nil
  47084. case wxcarduser.FieldUpdatedAt:
  47085. m.ResetUpdatedAt()
  47086. return nil
  47087. case wxcarduser.FieldDeletedAt:
  47088. m.ResetDeletedAt()
  47089. return nil
  47090. case wxcarduser.FieldWxid:
  47091. m.ResetWxid()
  47092. return nil
  47093. case wxcarduser.FieldAccount:
  47094. m.ResetAccount()
  47095. return nil
  47096. case wxcarduser.FieldAvatar:
  47097. m.ResetAvatar()
  47098. return nil
  47099. case wxcarduser.FieldNickname:
  47100. m.ResetNickname()
  47101. return nil
  47102. case wxcarduser.FieldRemark:
  47103. m.ResetRemark()
  47104. return nil
  47105. case wxcarduser.FieldPhone:
  47106. m.ResetPhone()
  47107. return nil
  47108. case wxcarduser.FieldOpenID:
  47109. m.ResetOpenID()
  47110. return nil
  47111. case wxcarduser.FieldUnionID:
  47112. m.ResetUnionID()
  47113. return nil
  47114. case wxcarduser.FieldSessionKey:
  47115. m.ResetSessionKey()
  47116. return nil
  47117. case wxcarduser.FieldIsVip:
  47118. m.ResetIsVip()
  47119. return nil
  47120. }
  47121. return fmt.Errorf("unknown WxCardUser field %s", name)
  47122. }
  47123. // AddedEdges returns all edge names that were set/added in this mutation.
  47124. func (m *WxCardUserMutation) AddedEdges() []string {
  47125. edges := make([]string, 0, 0)
  47126. return edges
  47127. }
  47128. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47129. // name in this mutation.
  47130. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  47131. return nil
  47132. }
  47133. // RemovedEdges returns all edge names that were removed in this mutation.
  47134. func (m *WxCardUserMutation) RemovedEdges() []string {
  47135. edges := make([]string, 0, 0)
  47136. return edges
  47137. }
  47138. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47139. // the given name in this mutation.
  47140. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  47141. return nil
  47142. }
  47143. // ClearedEdges returns all edge names that were cleared in this mutation.
  47144. func (m *WxCardUserMutation) ClearedEdges() []string {
  47145. edges := make([]string, 0, 0)
  47146. return edges
  47147. }
  47148. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47149. // was cleared in this mutation.
  47150. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  47151. return false
  47152. }
  47153. // ClearEdge clears the value of the edge with the given name. It returns an error
  47154. // if that edge is not defined in the schema.
  47155. func (m *WxCardUserMutation) ClearEdge(name string) error {
  47156. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  47157. }
  47158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47159. // It returns an error if the edge is not defined in the schema.
  47160. func (m *WxCardUserMutation) ResetEdge(name string) error {
  47161. return fmt.Errorf("unknown WxCardUser edge %s", name)
  47162. }
  47163. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  47164. type WxCardVisitMutation struct {
  47165. config
  47166. op Op
  47167. typ string
  47168. id *uint64
  47169. created_at *time.Time
  47170. updated_at *time.Time
  47171. deleted_at *time.Time
  47172. user_id *uint64
  47173. adduser_id *int64
  47174. bot_id *uint64
  47175. addbot_id *int64
  47176. bot_type *uint8
  47177. addbot_type *int8
  47178. clearedFields map[string]struct{}
  47179. done bool
  47180. oldValue func(context.Context) (*WxCardVisit, error)
  47181. predicates []predicate.WxCardVisit
  47182. }
  47183. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  47184. // wxcardvisitOption allows management of the mutation configuration using functional options.
  47185. type wxcardvisitOption func(*WxCardVisitMutation)
  47186. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  47187. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  47188. m := &WxCardVisitMutation{
  47189. config: c,
  47190. op: op,
  47191. typ: TypeWxCardVisit,
  47192. clearedFields: make(map[string]struct{}),
  47193. }
  47194. for _, opt := range opts {
  47195. opt(m)
  47196. }
  47197. return m
  47198. }
  47199. // withWxCardVisitID sets the ID field of the mutation.
  47200. func withWxCardVisitID(id uint64) wxcardvisitOption {
  47201. return func(m *WxCardVisitMutation) {
  47202. var (
  47203. err error
  47204. once sync.Once
  47205. value *WxCardVisit
  47206. )
  47207. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  47208. once.Do(func() {
  47209. if m.done {
  47210. err = errors.New("querying old values post mutation is not allowed")
  47211. } else {
  47212. value, err = m.Client().WxCardVisit.Get(ctx, id)
  47213. }
  47214. })
  47215. return value, err
  47216. }
  47217. m.id = &id
  47218. }
  47219. }
  47220. // withWxCardVisit sets the old WxCardVisit of the mutation.
  47221. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  47222. return func(m *WxCardVisitMutation) {
  47223. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  47224. return node, nil
  47225. }
  47226. m.id = &node.ID
  47227. }
  47228. }
  47229. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47230. // executed in a transaction (ent.Tx), a transactional client is returned.
  47231. func (m WxCardVisitMutation) Client() *Client {
  47232. client := &Client{config: m.config}
  47233. client.init()
  47234. return client
  47235. }
  47236. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47237. // it returns an error otherwise.
  47238. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  47239. if _, ok := m.driver.(*txDriver); !ok {
  47240. return nil, errors.New("ent: mutation is not running in a transaction")
  47241. }
  47242. tx := &Tx{config: m.config}
  47243. tx.init()
  47244. return tx, nil
  47245. }
  47246. // SetID sets the value of the id field. Note that this
  47247. // operation is only accepted on creation of WxCardVisit entities.
  47248. func (m *WxCardVisitMutation) SetID(id uint64) {
  47249. m.id = &id
  47250. }
  47251. // ID returns the ID value in the mutation. Note that the ID is only available
  47252. // if it was provided to the builder or after it was returned from the database.
  47253. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  47254. if m.id == nil {
  47255. return
  47256. }
  47257. return *m.id, true
  47258. }
  47259. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47260. // That means, if the mutation is applied within a transaction with an isolation level such
  47261. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47262. // or updated by the mutation.
  47263. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  47264. switch {
  47265. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47266. id, exists := m.ID()
  47267. if exists {
  47268. return []uint64{id}, nil
  47269. }
  47270. fallthrough
  47271. case m.op.Is(OpUpdate | OpDelete):
  47272. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  47273. default:
  47274. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47275. }
  47276. }
  47277. // SetCreatedAt sets the "created_at" field.
  47278. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  47279. m.created_at = &t
  47280. }
  47281. // CreatedAt returns the value of the "created_at" field in the mutation.
  47282. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  47283. v := m.created_at
  47284. if v == nil {
  47285. return
  47286. }
  47287. return *v, true
  47288. }
  47289. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  47290. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47292. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47293. if !m.op.Is(OpUpdateOne) {
  47294. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47295. }
  47296. if m.id == nil || m.oldValue == nil {
  47297. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47298. }
  47299. oldValue, err := m.oldValue(ctx)
  47300. if err != nil {
  47301. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47302. }
  47303. return oldValue.CreatedAt, nil
  47304. }
  47305. // ResetCreatedAt resets all changes to the "created_at" field.
  47306. func (m *WxCardVisitMutation) ResetCreatedAt() {
  47307. m.created_at = nil
  47308. }
  47309. // SetUpdatedAt sets the "updated_at" field.
  47310. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  47311. m.updated_at = &t
  47312. }
  47313. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47314. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  47315. v := m.updated_at
  47316. if v == nil {
  47317. return
  47318. }
  47319. return *v, true
  47320. }
  47321. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  47322. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47324. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47325. if !m.op.Is(OpUpdateOne) {
  47326. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47327. }
  47328. if m.id == nil || m.oldValue == nil {
  47329. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47330. }
  47331. oldValue, err := m.oldValue(ctx)
  47332. if err != nil {
  47333. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47334. }
  47335. return oldValue.UpdatedAt, nil
  47336. }
  47337. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47338. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  47339. m.updated_at = nil
  47340. }
  47341. // SetDeletedAt sets the "deleted_at" field.
  47342. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  47343. m.deleted_at = &t
  47344. }
  47345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47346. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  47347. v := m.deleted_at
  47348. if v == nil {
  47349. return
  47350. }
  47351. return *v, true
  47352. }
  47353. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  47354. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47356. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47357. if !m.op.Is(OpUpdateOne) {
  47358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47359. }
  47360. if m.id == nil || m.oldValue == nil {
  47361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47362. }
  47363. oldValue, err := m.oldValue(ctx)
  47364. if err != nil {
  47365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47366. }
  47367. return oldValue.DeletedAt, nil
  47368. }
  47369. // ClearDeletedAt clears the value of the "deleted_at" field.
  47370. func (m *WxCardVisitMutation) ClearDeletedAt() {
  47371. m.deleted_at = nil
  47372. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  47373. }
  47374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47375. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  47376. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  47377. return ok
  47378. }
  47379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47380. func (m *WxCardVisitMutation) ResetDeletedAt() {
  47381. m.deleted_at = nil
  47382. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  47383. }
  47384. // SetUserID sets the "user_id" field.
  47385. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  47386. m.user_id = &u
  47387. m.adduser_id = nil
  47388. }
  47389. // UserID returns the value of the "user_id" field in the mutation.
  47390. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  47391. v := m.user_id
  47392. if v == nil {
  47393. return
  47394. }
  47395. return *v, true
  47396. }
  47397. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  47398. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47400. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  47401. if !m.op.Is(OpUpdateOne) {
  47402. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  47403. }
  47404. if m.id == nil || m.oldValue == nil {
  47405. return v, errors.New("OldUserID requires an ID field in the mutation")
  47406. }
  47407. oldValue, err := m.oldValue(ctx)
  47408. if err != nil {
  47409. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  47410. }
  47411. return oldValue.UserID, nil
  47412. }
  47413. // AddUserID adds u to the "user_id" field.
  47414. func (m *WxCardVisitMutation) AddUserID(u int64) {
  47415. if m.adduser_id != nil {
  47416. *m.adduser_id += u
  47417. } else {
  47418. m.adduser_id = &u
  47419. }
  47420. }
  47421. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  47422. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  47423. v := m.adduser_id
  47424. if v == nil {
  47425. return
  47426. }
  47427. return *v, true
  47428. }
  47429. // ClearUserID clears the value of the "user_id" field.
  47430. func (m *WxCardVisitMutation) ClearUserID() {
  47431. m.user_id = nil
  47432. m.adduser_id = nil
  47433. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  47434. }
  47435. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  47436. func (m *WxCardVisitMutation) UserIDCleared() bool {
  47437. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  47438. return ok
  47439. }
  47440. // ResetUserID resets all changes to the "user_id" field.
  47441. func (m *WxCardVisitMutation) ResetUserID() {
  47442. m.user_id = nil
  47443. m.adduser_id = nil
  47444. delete(m.clearedFields, wxcardvisit.FieldUserID)
  47445. }
  47446. // SetBotID sets the "bot_id" field.
  47447. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  47448. m.bot_id = &u
  47449. m.addbot_id = nil
  47450. }
  47451. // BotID returns the value of the "bot_id" field in the mutation.
  47452. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  47453. v := m.bot_id
  47454. if v == nil {
  47455. return
  47456. }
  47457. return *v, true
  47458. }
  47459. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  47460. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47462. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  47463. if !m.op.Is(OpUpdateOne) {
  47464. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  47465. }
  47466. if m.id == nil || m.oldValue == nil {
  47467. return v, errors.New("OldBotID requires an ID field in the mutation")
  47468. }
  47469. oldValue, err := m.oldValue(ctx)
  47470. if err != nil {
  47471. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  47472. }
  47473. return oldValue.BotID, nil
  47474. }
  47475. // AddBotID adds u to the "bot_id" field.
  47476. func (m *WxCardVisitMutation) AddBotID(u int64) {
  47477. if m.addbot_id != nil {
  47478. *m.addbot_id += u
  47479. } else {
  47480. m.addbot_id = &u
  47481. }
  47482. }
  47483. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  47484. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  47485. v := m.addbot_id
  47486. if v == nil {
  47487. return
  47488. }
  47489. return *v, true
  47490. }
  47491. // ResetBotID resets all changes to the "bot_id" field.
  47492. func (m *WxCardVisitMutation) ResetBotID() {
  47493. m.bot_id = nil
  47494. m.addbot_id = nil
  47495. }
  47496. // SetBotType sets the "bot_type" field.
  47497. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  47498. m.bot_type = &u
  47499. m.addbot_type = nil
  47500. }
  47501. // BotType returns the value of the "bot_type" field in the mutation.
  47502. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  47503. v := m.bot_type
  47504. if v == nil {
  47505. return
  47506. }
  47507. return *v, true
  47508. }
  47509. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  47510. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  47511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47512. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  47513. if !m.op.Is(OpUpdateOne) {
  47514. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  47515. }
  47516. if m.id == nil || m.oldValue == nil {
  47517. return v, errors.New("OldBotType requires an ID field in the mutation")
  47518. }
  47519. oldValue, err := m.oldValue(ctx)
  47520. if err != nil {
  47521. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  47522. }
  47523. return oldValue.BotType, nil
  47524. }
  47525. // AddBotType adds u to the "bot_type" field.
  47526. func (m *WxCardVisitMutation) AddBotType(u int8) {
  47527. if m.addbot_type != nil {
  47528. *m.addbot_type += u
  47529. } else {
  47530. m.addbot_type = &u
  47531. }
  47532. }
  47533. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  47534. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  47535. v := m.addbot_type
  47536. if v == nil {
  47537. return
  47538. }
  47539. return *v, true
  47540. }
  47541. // ResetBotType resets all changes to the "bot_type" field.
  47542. func (m *WxCardVisitMutation) ResetBotType() {
  47543. m.bot_type = nil
  47544. m.addbot_type = nil
  47545. }
  47546. // Where appends a list predicates to the WxCardVisitMutation builder.
  47547. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  47548. m.predicates = append(m.predicates, ps...)
  47549. }
  47550. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  47551. // users can use type-assertion to append predicates that do not depend on any generated package.
  47552. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  47553. p := make([]predicate.WxCardVisit, len(ps))
  47554. for i := range ps {
  47555. p[i] = ps[i]
  47556. }
  47557. m.Where(p...)
  47558. }
  47559. // Op returns the operation name.
  47560. func (m *WxCardVisitMutation) Op() Op {
  47561. return m.op
  47562. }
  47563. // SetOp allows setting the mutation operation.
  47564. func (m *WxCardVisitMutation) SetOp(op Op) {
  47565. m.op = op
  47566. }
  47567. // Type returns the node type of this mutation (WxCardVisit).
  47568. func (m *WxCardVisitMutation) Type() string {
  47569. return m.typ
  47570. }
  47571. // Fields returns all fields that were changed during this mutation. Note that in
  47572. // order to get all numeric fields that were incremented/decremented, call
  47573. // AddedFields().
  47574. func (m *WxCardVisitMutation) Fields() []string {
  47575. fields := make([]string, 0, 6)
  47576. if m.created_at != nil {
  47577. fields = append(fields, wxcardvisit.FieldCreatedAt)
  47578. }
  47579. if m.updated_at != nil {
  47580. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  47581. }
  47582. if m.deleted_at != nil {
  47583. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47584. }
  47585. if m.user_id != nil {
  47586. fields = append(fields, wxcardvisit.FieldUserID)
  47587. }
  47588. if m.bot_id != nil {
  47589. fields = append(fields, wxcardvisit.FieldBotID)
  47590. }
  47591. if m.bot_type != nil {
  47592. fields = append(fields, wxcardvisit.FieldBotType)
  47593. }
  47594. return fields
  47595. }
  47596. // Field returns the value of a field with the given name. The second boolean
  47597. // return value indicates that this field was not set, or was not defined in the
  47598. // schema.
  47599. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  47600. switch name {
  47601. case wxcardvisit.FieldCreatedAt:
  47602. return m.CreatedAt()
  47603. case wxcardvisit.FieldUpdatedAt:
  47604. return m.UpdatedAt()
  47605. case wxcardvisit.FieldDeletedAt:
  47606. return m.DeletedAt()
  47607. case wxcardvisit.FieldUserID:
  47608. return m.UserID()
  47609. case wxcardvisit.FieldBotID:
  47610. return m.BotID()
  47611. case wxcardvisit.FieldBotType:
  47612. return m.BotType()
  47613. }
  47614. return nil, false
  47615. }
  47616. // OldField returns the old value of the field from the database. An error is
  47617. // returned if the mutation operation is not UpdateOne, or the query to the
  47618. // database failed.
  47619. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47620. switch name {
  47621. case wxcardvisit.FieldCreatedAt:
  47622. return m.OldCreatedAt(ctx)
  47623. case wxcardvisit.FieldUpdatedAt:
  47624. return m.OldUpdatedAt(ctx)
  47625. case wxcardvisit.FieldDeletedAt:
  47626. return m.OldDeletedAt(ctx)
  47627. case wxcardvisit.FieldUserID:
  47628. return m.OldUserID(ctx)
  47629. case wxcardvisit.FieldBotID:
  47630. return m.OldBotID(ctx)
  47631. case wxcardvisit.FieldBotType:
  47632. return m.OldBotType(ctx)
  47633. }
  47634. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  47635. }
  47636. // SetField sets the value of a field with the given name. It returns an error if
  47637. // the field is not defined in the schema, or if the type mismatched the field
  47638. // type.
  47639. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  47640. switch name {
  47641. case wxcardvisit.FieldCreatedAt:
  47642. v, ok := value.(time.Time)
  47643. if !ok {
  47644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47645. }
  47646. m.SetCreatedAt(v)
  47647. return nil
  47648. case wxcardvisit.FieldUpdatedAt:
  47649. v, ok := value.(time.Time)
  47650. if !ok {
  47651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47652. }
  47653. m.SetUpdatedAt(v)
  47654. return nil
  47655. case wxcardvisit.FieldDeletedAt:
  47656. v, ok := value.(time.Time)
  47657. if !ok {
  47658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47659. }
  47660. m.SetDeletedAt(v)
  47661. return nil
  47662. case wxcardvisit.FieldUserID:
  47663. v, ok := value.(uint64)
  47664. if !ok {
  47665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47666. }
  47667. m.SetUserID(v)
  47668. return nil
  47669. case wxcardvisit.FieldBotID:
  47670. v, ok := value.(uint64)
  47671. if !ok {
  47672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47673. }
  47674. m.SetBotID(v)
  47675. return nil
  47676. case wxcardvisit.FieldBotType:
  47677. v, ok := value.(uint8)
  47678. if !ok {
  47679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47680. }
  47681. m.SetBotType(v)
  47682. return nil
  47683. }
  47684. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47685. }
  47686. // AddedFields returns all numeric fields that were incremented/decremented during
  47687. // this mutation.
  47688. func (m *WxCardVisitMutation) AddedFields() []string {
  47689. var fields []string
  47690. if m.adduser_id != nil {
  47691. fields = append(fields, wxcardvisit.FieldUserID)
  47692. }
  47693. if m.addbot_id != nil {
  47694. fields = append(fields, wxcardvisit.FieldBotID)
  47695. }
  47696. if m.addbot_type != nil {
  47697. fields = append(fields, wxcardvisit.FieldBotType)
  47698. }
  47699. return fields
  47700. }
  47701. // AddedField returns the numeric value that was incremented/decremented on a field
  47702. // with the given name. The second boolean return value indicates that this field
  47703. // was not set, or was not defined in the schema.
  47704. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  47705. switch name {
  47706. case wxcardvisit.FieldUserID:
  47707. return m.AddedUserID()
  47708. case wxcardvisit.FieldBotID:
  47709. return m.AddedBotID()
  47710. case wxcardvisit.FieldBotType:
  47711. return m.AddedBotType()
  47712. }
  47713. return nil, false
  47714. }
  47715. // AddField adds the value to the field with the given name. It returns an error if
  47716. // the field is not defined in the schema, or if the type mismatched the field
  47717. // type.
  47718. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  47719. switch name {
  47720. case wxcardvisit.FieldUserID:
  47721. v, ok := value.(int64)
  47722. if !ok {
  47723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47724. }
  47725. m.AddUserID(v)
  47726. return nil
  47727. case wxcardvisit.FieldBotID:
  47728. v, ok := value.(int64)
  47729. if !ok {
  47730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47731. }
  47732. m.AddBotID(v)
  47733. return nil
  47734. case wxcardvisit.FieldBotType:
  47735. v, ok := value.(int8)
  47736. if !ok {
  47737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47738. }
  47739. m.AddBotType(v)
  47740. return nil
  47741. }
  47742. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  47743. }
  47744. // ClearedFields returns all nullable fields that were cleared during this
  47745. // mutation.
  47746. func (m *WxCardVisitMutation) ClearedFields() []string {
  47747. var fields []string
  47748. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  47749. fields = append(fields, wxcardvisit.FieldDeletedAt)
  47750. }
  47751. if m.FieldCleared(wxcardvisit.FieldUserID) {
  47752. fields = append(fields, wxcardvisit.FieldUserID)
  47753. }
  47754. return fields
  47755. }
  47756. // FieldCleared returns a boolean indicating if a field with the given name was
  47757. // cleared in this mutation.
  47758. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  47759. _, ok := m.clearedFields[name]
  47760. return ok
  47761. }
  47762. // ClearField clears the value of the field with the given name. It returns an
  47763. // error if the field is not defined in the schema.
  47764. func (m *WxCardVisitMutation) ClearField(name string) error {
  47765. switch name {
  47766. case wxcardvisit.FieldDeletedAt:
  47767. m.ClearDeletedAt()
  47768. return nil
  47769. case wxcardvisit.FieldUserID:
  47770. m.ClearUserID()
  47771. return nil
  47772. }
  47773. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  47774. }
  47775. // ResetField resets all changes in the mutation for the field with the given name.
  47776. // It returns an error if the field is not defined in the schema.
  47777. func (m *WxCardVisitMutation) ResetField(name string) error {
  47778. switch name {
  47779. case wxcardvisit.FieldCreatedAt:
  47780. m.ResetCreatedAt()
  47781. return nil
  47782. case wxcardvisit.FieldUpdatedAt:
  47783. m.ResetUpdatedAt()
  47784. return nil
  47785. case wxcardvisit.FieldDeletedAt:
  47786. m.ResetDeletedAt()
  47787. return nil
  47788. case wxcardvisit.FieldUserID:
  47789. m.ResetUserID()
  47790. return nil
  47791. case wxcardvisit.FieldBotID:
  47792. m.ResetBotID()
  47793. return nil
  47794. case wxcardvisit.FieldBotType:
  47795. m.ResetBotType()
  47796. return nil
  47797. }
  47798. return fmt.Errorf("unknown WxCardVisit field %s", name)
  47799. }
  47800. // AddedEdges returns all edge names that were set/added in this mutation.
  47801. func (m *WxCardVisitMutation) AddedEdges() []string {
  47802. edges := make([]string, 0, 0)
  47803. return edges
  47804. }
  47805. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47806. // name in this mutation.
  47807. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  47808. return nil
  47809. }
  47810. // RemovedEdges returns all edge names that were removed in this mutation.
  47811. func (m *WxCardVisitMutation) RemovedEdges() []string {
  47812. edges := make([]string, 0, 0)
  47813. return edges
  47814. }
  47815. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47816. // the given name in this mutation.
  47817. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  47818. return nil
  47819. }
  47820. // ClearedEdges returns all edge names that were cleared in this mutation.
  47821. func (m *WxCardVisitMutation) ClearedEdges() []string {
  47822. edges := make([]string, 0, 0)
  47823. return edges
  47824. }
  47825. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47826. // was cleared in this mutation.
  47827. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  47828. return false
  47829. }
  47830. // ClearEdge clears the value of the edge with the given name. It returns an error
  47831. // if that edge is not defined in the schema.
  47832. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  47833. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  47834. }
  47835. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47836. // It returns an error if the edge is not defined in the schema.
  47837. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  47838. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  47839. }
  47840. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  47841. type XunjiMutation struct {
  47842. config
  47843. op Op
  47844. typ string
  47845. id *uint64
  47846. created_at *time.Time
  47847. updated_at *time.Time
  47848. status *uint8
  47849. addstatus *int8
  47850. deleted_at *time.Time
  47851. app_key *string
  47852. app_secret *string
  47853. token *string
  47854. encoding_key *string
  47855. organization_id *uint64
  47856. addorganization_id *int64
  47857. clearedFields map[string]struct{}
  47858. done bool
  47859. oldValue func(context.Context) (*Xunji, error)
  47860. predicates []predicate.Xunji
  47861. }
  47862. var _ ent.Mutation = (*XunjiMutation)(nil)
  47863. // xunjiOption allows management of the mutation configuration using functional options.
  47864. type xunjiOption func(*XunjiMutation)
  47865. // newXunjiMutation creates new mutation for the Xunji entity.
  47866. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  47867. m := &XunjiMutation{
  47868. config: c,
  47869. op: op,
  47870. typ: TypeXunji,
  47871. clearedFields: make(map[string]struct{}),
  47872. }
  47873. for _, opt := range opts {
  47874. opt(m)
  47875. }
  47876. return m
  47877. }
  47878. // withXunjiID sets the ID field of the mutation.
  47879. func withXunjiID(id uint64) xunjiOption {
  47880. return func(m *XunjiMutation) {
  47881. var (
  47882. err error
  47883. once sync.Once
  47884. value *Xunji
  47885. )
  47886. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  47887. once.Do(func() {
  47888. if m.done {
  47889. err = errors.New("querying old values post mutation is not allowed")
  47890. } else {
  47891. value, err = m.Client().Xunji.Get(ctx, id)
  47892. }
  47893. })
  47894. return value, err
  47895. }
  47896. m.id = &id
  47897. }
  47898. }
  47899. // withXunji sets the old Xunji of the mutation.
  47900. func withXunji(node *Xunji) xunjiOption {
  47901. return func(m *XunjiMutation) {
  47902. m.oldValue = func(context.Context) (*Xunji, error) {
  47903. return node, nil
  47904. }
  47905. m.id = &node.ID
  47906. }
  47907. }
  47908. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47909. // executed in a transaction (ent.Tx), a transactional client is returned.
  47910. func (m XunjiMutation) Client() *Client {
  47911. client := &Client{config: m.config}
  47912. client.init()
  47913. return client
  47914. }
  47915. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47916. // it returns an error otherwise.
  47917. func (m XunjiMutation) Tx() (*Tx, error) {
  47918. if _, ok := m.driver.(*txDriver); !ok {
  47919. return nil, errors.New("ent: mutation is not running in a transaction")
  47920. }
  47921. tx := &Tx{config: m.config}
  47922. tx.init()
  47923. return tx, nil
  47924. }
  47925. // SetID sets the value of the id field. Note that this
  47926. // operation is only accepted on creation of Xunji entities.
  47927. func (m *XunjiMutation) SetID(id uint64) {
  47928. m.id = &id
  47929. }
  47930. // ID returns the ID value in the mutation. Note that the ID is only available
  47931. // if it was provided to the builder or after it was returned from the database.
  47932. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  47933. if m.id == nil {
  47934. return
  47935. }
  47936. return *m.id, true
  47937. }
  47938. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47939. // That means, if the mutation is applied within a transaction with an isolation level such
  47940. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47941. // or updated by the mutation.
  47942. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  47943. switch {
  47944. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47945. id, exists := m.ID()
  47946. if exists {
  47947. return []uint64{id}, nil
  47948. }
  47949. fallthrough
  47950. case m.op.Is(OpUpdate | OpDelete):
  47951. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  47952. default:
  47953. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47954. }
  47955. }
  47956. // SetCreatedAt sets the "created_at" field.
  47957. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  47958. m.created_at = &t
  47959. }
  47960. // CreatedAt returns the value of the "created_at" field in the mutation.
  47961. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  47962. v := m.created_at
  47963. if v == nil {
  47964. return
  47965. }
  47966. return *v, true
  47967. }
  47968. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  47969. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  47970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47971. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47972. if !m.op.Is(OpUpdateOne) {
  47973. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47974. }
  47975. if m.id == nil || m.oldValue == nil {
  47976. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47977. }
  47978. oldValue, err := m.oldValue(ctx)
  47979. if err != nil {
  47980. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47981. }
  47982. return oldValue.CreatedAt, nil
  47983. }
  47984. // ResetCreatedAt resets all changes to the "created_at" field.
  47985. func (m *XunjiMutation) ResetCreatedAt() {
  47986. m.created_at = nil
  47987. }
  47988. // SetUpdatedAt sets the "updated_at" field.
  47989. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  47990. m.updated_at = &t
  47991. }
  47992. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47993. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  47994. v := m.updated_at
  47995. if v == nil {
  47996. return
  47997. }
  47998. return *v, true
  47999. }
  48000. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  48001. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48003. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48004. if !m.op.Is(OpUpdateOne) {
  48005. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48006. }
  48007. if m.id == nil || m.oldValue == nil {
  48008. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48009. }
  48010. oldValue, err := m.oldValue(ctx)
  48011. if err != nil {
  48012. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48013. }
  48014. return oldValue.UpdatedAt, nil
  48015. }
  48016. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48017. func (m *XunjiMutation) ResetUpdatedAt() {
  48018. m.updated_at = nil
  48019. }
  48020. // SetStatus sets the "status" field.
  48021. func (m *XunjiMutation) SetStatus(u uint8) {
  48022. m.status = &u
  48023. m.addstatus = nil
  48024. }
  48025. // Status returns the value of the "status" field in the mutation.
  48026. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  48027. v := m.status
  48028. if v == nil {
  48029. return
  48030. }
  48031. return *v, true
  48032. }
  48033. // OldStatus returns the old "status" field's value of the Xunji entity.
  48034. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48036. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48037. if !m.op.Is(OpUpdateOne) {
  48038. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48039. }
  48040. if m.id == nil || m.oldValue == nil {
  48041. return v, errors.New("OldStatus requires an ID field in the mutation")
  48042. }
  48043. oldValue, err := m.oldValue(ctx)
  48044. if err != nil {
  48045. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48046. }
  48047. return oldValue.Status, nil
  48048. }
  48049. // AddStatus adds u to the "status" field.
  48050. func (m *XunjiMutation) AddStatus(u int8) {
  48051. if m.addstatus != nil {
  48052. *m.addstatus += u
  48053. } else {
  48054. m.addstatus = &u
  48055. }
  48056. }
  48057. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48058. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  48059. v := m.addstatus
  48060. if v == nil {
  48061. return
  48062. }
  48063. return *v, true
  48064. }
  48065. // ClearStatus clears the value of the "status" field.
  48066. func (m *XunjiMutation) ClearStatus() {
  48067. m.status = nil
  48068. m.addstatus = nil
  48069. m.clearedFields[xunji.FieldStatus] = struct{}{}
  48070. }
  48071. // StatusCleared returns if the "status" field was cleared in this mutation.
  48072. func (m *XunjiMutation) StatusCleared() bool {
  48073. _, ok := m.clearedFields[xunji.FieldStatus]
  48074. return ok
  48075. }
  48076. // ResetStatus resets all changes to the "status" field.
  48077. func (m *XunjiMutation) ResetStatus() {
  48078. m.status = nil
  48079. m.addstatus = nil
  48080. delete(m.clearedFields, xunji.FieldStatus)
  48081. }
  48082. // SetDeletedAt sets the "deleted_at" field.
  48083. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  48084. m.deleted_at = &t
  48085. }
  48086. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48087. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  48088. v := m.deleted_at
  48089. if v == nil {
  48090. return
  48091. }
  48092. return *v, true
  48093. }
  48094. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  48095. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48097. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48098. if !m.op.Is(OpUpdateOne) {
  48099. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48100. }
  48101. if m.id == nil || m.oldValue == nil {
  48102. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48103. }
  48104. oldValue, err := m.oldValue(ctx)
  48105. if err != nil {
  48106. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48107. }
  48108. return oldValue.DeletedAt, nil
  48109. }
  48110. // ClearDeletedAt clears the value of the "deleted_at" field.
  48111. func (m *XunjiMutation) ClearDeletedAt() {
  48112. m.deleted_at = nil
  48113. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  48114. }
  48115. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48116. func (m *XunjiMutation) DeletedAtCleared() bool {
  48117. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  48118. return ok
  48119. }
  48120. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48121. func (m *XunjiMutation) ResetDeletedAt() {
  48122. m.deleted_at = nil
  48123. delete(m.clearedFields, xunji.FieldDeletedAt)
  48124. }
  48125. // SetAppKey sets the "app_key" field.
  48126. func (m *XunjiMutation) SetAppKey(s string) {
  48127. m.app_key = &s
  48128. }
  48129. // AppKey returns the value of the "app_key" field in the mutation.
  48130. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  48131. v := m.app_key
  48132. if v == nil {
  48133. return
  48134. }
  48135. return *v, true
  48136. }
  48137. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  48138. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48140. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  48141. if !m.op.Is(OpUpdateOne) {
  48142. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  48143. }
  48144. if m.id == nil || m.oldValue == nil {
  48145. return v, errors.New("OldAppKey requires an ID field in the mutation")
  48146. }
  48147. oldValue, err := m.oldValue(ctx)
  48148. if err != nil {
  48149. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  48150. }
  48151. return oldValue.AppKey, nil
  48152. }
  48153. // ClearAppKey clears the value of the "app_key" field.
  48154. func (m *XunjiMutation) ClearAppKey() {
  48155. m.app_key = nil
  48156. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  48157. }
  48158. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  48159. func (m *XunjiMutation) AppKeyCleared() bool {
  48160. _, ok := m.clearedFields[xunji.FieldAppKey]
  48161. return ok
  48162. }
  48163. // ResetAppKey resets all changes to the "app_key" field.
  48164. func (m *XunjiMutation) ResetAppKey() {
  48165. m.app_key = nil
  48166. delete(m.clearedFields, xunji.FieldAppKey)
  48167. }
  48168. // SetAppSecret sets the "app_secret" field.
  48169. func (m *XunjiMutation) SetAppSecret(s string) {
  48170. m.app_secret = &s
  48171. }
  48172. // AppSecret returns the value of the "app_secret" field in the mutation.
  48173. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  48174. v := m.app_secret
  48175. if v == nil {
  48176. return
  48177. }
  48178. return *v, true
  48179. }
  48180. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  48181. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48183. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  48184. if !m.op.Is(OpUpdateOne) {
  48185. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  48186. }
  48187. if m.id == nil || m.oldValue == nil {
  48188. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  48189. }
  48190. oldValue, err := m.oldValue(ctx)
  48191. if err != nil {
  48192. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  48193. }
  48194. return oldValue.AppSecret, nil
  48195. }
  48196. // ClearAppSecret clears the value of the "app_secret" field.
  48197. func (m *XunjiMutation) ClearAppSecret() {
  48198. m.app_secret = nil
  48199. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  48200. }
  48201. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  48202. func (m *XunjiMutation) AppSecretCleared() bool {
  48203. _, ok := m.clearedFields[xunji.FieldAppSecret]
  48204. return ok
  48205. }
  48206. // ResetAppSecret resets all changes to the "app_secret" field.
  48207. func (m *XunjiMutation) ResetAppSecret() {
  48208. m.app_secret = nil
  48209. delete(m.clearedFields, xunji.FieldAppSecret)
  48210. }
  48211. // SetToken sets the "token" field.
  48212. func (m *XunjiMutation) SetToken(s string) {
  48213. m.token = &s
  48214. }
  48215. // Token returns the value of the "token" field in the mutation.
  48216. func (m *XunjiMutation) Token() (r string, exists bool) {
  48217. v := m.token
  48218. if v == nil {
  48219. return
  48220. }
  48221. return *v, true
  48222. }
  48223. // OldToken returns the old "token" field's value of the Xunji entity.
  48224. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48226. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  48227. if !m.op.Is(OpUpdateOne) {
  48228. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  48229. }
  48230. if m.id == nil || m.oldValue == nil {
  48231. return v, errors.New("OldToken requires an ID field in the mutation")
  48232. }
  48233. oldValue, err := m.oldValue(ctx)
  48234. if err != nil {
  48235. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  48236. }
  48237. return oldValue.Token, nil
  48238. }
  48239. // ClearToken clears the value of the "token" field.
  48240. func (m *XunjiMutation) ClearToken() {
  48241. m.token = nil
  48242. m.clearedFields[xunji.FieldToken] = struct{}{}
  48243. }
  48244. // TokenCleared returns if the "token" field was cleared in this mutation.
  48245. func (m *XunjiMutation) TokenCleared() bool {
  48246. _, ok := m.clearedFields[xunji.FieldToken]
  48247. return ok
  48248. }
  48249. // ResetToken resets all changes to the "token" field.
  48250. func (m *XunjiMutation) ResetToken() {
  48251. m.token = nil
  48252. delete(m.clearedFields, xunji.FieldToken)
  48253. }
  48254. // SetEncodingKey sets the "encoding_key" field.
  48255. func (m *XunjiMutation) SetEncodingKey(s string) {
  48256. m.encoding_key = &s
  48257. }
  48258. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  48259. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  48260. v := m.encoding_key
  48261. if v == nil {
  48262. return
  48263. }
  48264. return *v, true
  48265. }
  48266. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  48267. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48269. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  48270. if !m.op.Is(OpUpdateOne) {
  48271. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  48272. }
  48273. if m.id == nil || m.oldValue == nil {
  48274. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  48275. }
  48276. oldValue, err := m.oldValue(ctx)
  48277. if err != nil {
  48278. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  48279. }
  48280. return oldValue.EncodingKey, nil
  48281. }
  48282. // ClearEncodingKey clears the value of the "encoding_key" field.
  48283. func (m *XunjiMutation) ClearEncodingKey() {
  48284. m.encoding_key = nil
  48285. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  48286. }
  48287. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  48288. func (m *XunjiMutation) EncodingKeyCleared() bool {
  48289. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  48290. return ok
  48291. }
  48292. // ResetEncodingKey resets all changes to the "encoding_key" field.
  48293. func (m *XunjiMutation) ResetEncodingKey() {
  48294. m.encoding_key = nil
  48295. delete(m.clearedFields, xunji.FieldEncodingKey)
  48296. }
  48297. // SetOrganizationID sets the "organization_id" field.
  48298. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  48299. m.organization_id = &u
  48300. m.addorganization_id = nil
  48301. }
  48302. // OrganizationID returns the value of the "organization_id" field in the mutation.
  48303. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  48304. v := m.organization_id
  48305. if v == nil {
  48306. return
  48307. }
  48308. return *v, true
  48309. }
  48310. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  48311. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  48312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48313. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  48314. if !m.op.Is(OpUpdateOne) {
  48315. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  48316. }
  48317. if m.id == nil || m.oldValue == nil {
  48318. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  48319. }
  48320. oldValue, err := m.oldValue(ctx)
  48321. if err != nil {
  48322. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  48323. }
  48324. return oldValue.OrganizationID, nil
  48325. }
  48326. // AddOrganizationID adds u to the "organization_id" field.
  48327. func (m *XunjiMutation) AddOrganizationID(u int64) {
  48328. if m.addorganization_id != nil {
  48329. *m.addorganization_id += u
  48330. } else {
  48331. m.addorganization_id = &u
  48332. }
  48333. }
  48334. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  48335. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  48336. v := m.addorganization_id
  48337. if v == nil {
  48338. return
  48339. }
  48340. return *v, true
  48341. }
  48342. // ResetOrganizationID resets all changes to the "organization_id" field.
  48343. func (m *XunjiMutation) ResetOrganizationID() {
  48344. m.organization_id = nil
  48345. m.addorganization_id = nil
  48346. }
  48347. // Where appends a list predicates to the XunjiMutation builder.
  48348. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  48349. m.predicates = append(m.predicates, ps...)
  48350. }
  48351. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  48352. // users can use type-assertion to append predicates that do not depend on any generated package.
  48353. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  48354. p := make([]predicate.Xunji, len(ps))
  48355. for i := range ps {
  48356. p[i] = ps[i]
  48357. }
  48358. m.Where(p...)
  48359. }
  48360. // Op returns the operation name.
  48361. func (m *XunjiMutation) Op() Op {
  48362. return m.op
  48363. }
  48364. // SetOp allows setting the mutation operation.
  48365. func (m *XunjiMutation) SetOp(op Op) {
  48366. m.op = op
  48367. }
  48368. // Type returns the node type of this mutation (Xunji).
  48369. func (m *XunjiMutation) Type() string {
  48370. return m.typ
  48371. }
  48372. // Fields returns all fields that were changed during this mutation. Note that in
  48373. // order to get all numeric fields that were incremented/decremented, call
  48374. // AddedFields().
  48375. func (m *XunjiMutation) Fields() []string {
  48376. fields := make([]string, 0, 9)
  48377. if m.created_at != nil {
  48378. fields = append(fields, xunji.FieldCreatedAt)
  48379. }
  48380. if m.updated_at != nil {
  48381. fields = append(fields, xunji.FieldUpdatedAt)
  48382. }
  48383. if m.status != nil {
  48384. fields = append(fields, xunji.FieldStatus)
  48385. }
  48386. if m.deleted_at != nil {
  48387. fields = append(fields, xunji.FieldDeletedAt)
  48388. }
  48389. if m.app_key != nil {
  48390. fields = append(fields, xunji.FieldAppKey)
  48391. }
  48392. if m.app_secret != nil {
  48393. fields = append(fields, xunji.FieldAppSecret)
  48394. }
  48395. if m.token != nil {
  48396. fields = append(fields, xunji.FieldToken)
  48397. }
  48398. if m.encoding_key != nil {
  48399. fields = append(fields, xunji.FieldEncodingKey)
  48400. }
  48401. if m.organization_id != nil {
  48402. fields = append(fields, xunji.FieldOrganizationID)
  48403. }
  48404. return fields
  48405. }
  48406. // Field returns the value of a field with the given name. The second boolean
  48407. // return value indicates that this field was not set, or was not defined in the
  48408. // schema.
  48409. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  48410. switch name {
  48411. case xunji.FieldCreatedAt:
  48412. return m.CreatedAt()
  48413. case xunji.FieldUpdatedAt:
  48414. return m.UpdatedAt()
  48415. case xunji.FieldStatus:
  48416. return m.Status()
  48417. case xunji.FieldDeletedAt:
  48418. return m.DeletedAt()
  48419. case xunji.FieldAppKey:
  48420. return m.AppKey()
  48421. case xunji.FieldAppSecret:
  48422. return m.AppSecret()
  48423. case xunji.FieldToken:
  48424. return m.Token()
  48425. case xunji.FieldEncodingKey:
  48426. return m.EncodingKey()
  48427. case xunji.FieldOrganizationID:
  48428. return m.OrganizationID()
  48429. }
  48430. return nil, false
  48431. }
  48432. // OldField returns the old value of the field from the database. An error is
  48433. // returned if the mutation operation is not UpdateOne, or the query to the
  48434. // database failed.
  48435. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48436. switch name {
  48437. case xunji.FieldCreatedAt:
  48438. return m.OldCreatedAt(ctx)
  48439. case xunji.FieldUpdatedAt:
  48440. return m.OldUpdatedAt(ctx)
  48441. case xunji.FieldStatus:
  48442. return m.OldStatus(ctx)
  48443. case xunji.FieldDeletedAt:
  48444. return m.OldDeletedAt(ctx)
  48445. case xunji.FieldAppKey:
  48446. return m.OldAppKey(ctx)
  48447. case xunji.FieldAppSecret:
  48448. return m.OldAppSecret(ctx)
  48449. case xunji.FieldToken:
  48450. return m.OldToken(ctx)
  48451. case xunji.FieldEncodingKey:
  48452. return m.OldEncodingKey(ctx)
  48453. case xunji.FieldOrganizationID:
  48454. return m.OldOrganizationID(ctx)
  48455. }
  48456. return nil, fmt.Errorf("unknown Xunji field %s", name)
  48457. }
  48458. // SetField sets the value of a field with the given name. It returns an error if
  48459. // the field is not defined in the schema, or if the type mismatched the field
  48460. // type.
  48461. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  48462. switch name {
  48463. case xunji.FieldCreatedAt:
  48464. v, ok := value.(time.Time)
  48465. if !ok {
  48466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48467. }
  48468. m.SetCreatedAt(v)
  48469. return nil
  48470. case xunji.FieldUpdatedAt:
  48471. v, ok := value.(time.Time)
  48472. if !ok {
  48473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48474. }
  48475. m.SetUpdatedAt(v)
  48476. return nil
  48477. case xunji.FieldStatus:
  48478. v, ok := value.(uint8)
  48479. if !ok {
  48480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48481. }
  48482. m.SetStatus(v)
  48483. return nil
  48484. case xunji.FieldDeletedAt:
  48485. v, ok := value.(time.Time)
  48486. if !ok {
  48487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48488. }
  48489. m.SetDeletedAt(v)
  48490. return nil
  48491. case xunji.FieldAppKey:
  48492. v, ok := value.(string)
  48493. if !ok {
  48494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48495. }
  48496. m.SetAppKey(v)
  48497. return nil
  48498. case xunji.FieldAppSecret:
  48499. v, ok := value.(string)
  48500. if !ok {
  48501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48502. }
  48503. m.SetAppSecret(v)
  48504. return nil
  48505. case xunji.FieldToken:
  48506. v, ok := value.(string)
  48507. if !ok {
  48508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48509. }
  48510. m.SetToken(v)
  48511. return nil
  48512. case xunji.FieldEncodingKey:
  48513. v, ok := value.(string)
  48514. if !ok {
  48515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48516. }
  48517. m.SetEncodingKey(v)
  48518. return nil
  48519. case xunji.FieldOrganizationID:
  48520. v, ok := value.(uint64)
  48521. if !ok {
  48522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48523. }
  48524. m.SetOrganizationID(v)
  48525. return nil
  48526. }
  48527. return fmt.Errorf("unknown Xunji field %s", name)
  48528. }
  48529. // AddedFields returns all numeric fields that were incremented/decremented during
  48530. // this mutation.
  48531. func (m *XunjiMutation) AddedFields() []string {
  48532. var fields []string
  48533. if m.addstatus != nil {
  48534. fields = append(fields, xunji.FieldStatus)
  48535. }
  48536. if m.addorganization_id != nil {
  48537. fields = append(fields, xunji.FieldOrganizationID)
  48538. }
  48539. return fields
  48540. }
  48541. // AddedField returns the numeric value that was incremented/decremented on a field
  48542. // with the given name. The second boolean return value indicates that this field
  48543. // was not set, or was not defined in the schema.
  48544. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  48545. switch name {
  48546. case xunji.FieldStatus:
  48547. return m.AddedStatus()
  48548. case xunji.FieldOrganizationID:
  48549. return m.AddedOrganizationID()
  48550. }
  48551. return nil, false
  48552. }
  48553. // AddField adds the value to the field with the given name. It returns an error if
  48554. // the field is not defined in the schema, or if the type mismatched the field
  48555. // type.
  48556. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  48557. switch name {
  48558. case xunji.FieldStatus:
  48559. v, ok := value.(int8)
  48560. if !ok {
  48561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48562. }
  48563. m.AddStatus(v)
  48564. return nil
  48565. case xunji.FieldOrganizationID:
  48566. v, ok := value.(int64)
  48567. if !ok {
  48568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48569. }
  48570. m.AddOrganizationID(v)
  48571. return nil
  48572. }
  48573. return fmt.Errorf("unknown Xunji numeric field %s", name)
  48574. }
  48575. // ClearedFields returns all nullable fields that were cleared during this
  48576. // mutation.
  48577. func (m *XunjiMutation) ClearedFields() []string {
  48578. var fields []string
  48579. if m.FieldCleared(xunji.FieldStatus) {
  48580. fields = append(fields, xunji.FieldStatus)
  48581. }
  48582. if m.FieldCleared(xunji.FieldDeletedAt) {
  48583. fields = append(fields, xunji.FieldDeletedAt)
  48584. }
  48585. if m.FieldCleared(xunji.FieldAppKey) {
  48586. fields = append(fields, xunji.FieldAppKey)
  48587. }
  48588. if m.FieldCleared(xunji.FieldAppSecret) {
  48589. fields = append(fields, xunji.FieldAppSecret)
  48590. }
  48591. if m.FieldCleared(xunji.FieldToken) {
  48592. fields = append(fields, xunji.FieldToken)
  48593. }
  48594. if m.FieldCleared(xunji.FieldEncodingKey) {
  48595. fields = append(fields, xunji.FieldEncodingKey)
  48596. }
  48597. return fields
  48598. }
  48599. // FieldCleared returns a boolean indicating if a field with the given name was
  48600. // cleared in this mutation.
  48601. func (m *XunjiMutation) FieldCleared(name string) bool {
  48602. _, ok := m.clearedFields[name]
  48603. return ok
  48604. }
  48605. // ClearField clears the value of the field with the given name. It returns an
  48606. // error if the field is not defined in the schema.
  48607. func (m *XunjiMutation) ClearField(name string) error {
  48608. switch name {
  48609. case xunji.FieldStatus:
  48610. m.ClearStatus()
  48611. return nil
  48612. case xunji.FieldDeletedAt:
  48613. m.ClearDeletedAt()
  48614. return nil
  48615. case xunji.FieldAppKey:
  48616. m.ClearAppKey()
  48617. return nil
  48618. case xunji.FieldAppSecret:
  48619. m.ClearAppSecret()
  48620. return nil
  48621. case xunji.FieldToken:
  48622. m.ClearToken()
  48623. return nil
  48624. case xunji.FieldEncodingKey:
  48625. m.ClearEncodingKey()
  48626. return nil
  48627. }
  48628. return fmt.Errorf("unknown Xunji nullable field %s", name)
  48629. }
  48630. // ResetField resets all changes in the mutation for the field with the given name.
  48631. // It returns an error if the field is not defined in the schema.
  48632. func (m *XunjiMutation) ResetField(name string) error {
  48633. switch name {
  48634. case xunji.FieldCreatedAt:
  48635. m.ResetCreatedAt()
  48636. return nil
  48637. case xunji.FieldUpdatedAt:
  48638. m.ResetUpdatedAt()
  48639. return nil
  48640. case xunji.FieldStatus:
  48641. m.ResetStatus()
  48642. return nil
  48643. case xunji.FieldDeletedAt:
  48644. m.ResetDeletedAt()
  48645. return nil
  48646. case xunji.FieldAppKey:
  48647. m.ResetAppKey()
  48648. return nil
  48649. case xunji.FieldAppSecret:
  48650. m.ResetAppSecret()
  48651. return nil
  48652. case xunji.FieldToken:
  48653. m.ResetToken()
  48654. return nil
  48655. case xunji.FieldEncodingKey:
  48656. m.ResetEncodingKey()
  48657. return nil
  48658. case xunji.FieldOrganizationID:
  48659. m.ResetOrganizationID()
  48660. return nil
  48661. }
  48662. return fmt.Errorf("unknown Xunji field %s", name)
  48663. }
  48664. // AddedEdges returns all edge names that were set/added in this mutation.
  48665. func (m *XunjiMutation) AddedEdges() []string {
  48666. edges := make([]string, 0, 0)
  48667. return edges
  48668. }
  48669. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48670. // name in this mutation.
  48671. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  48672. return nil
  48673. }
  48674. // RemovedEdges returns all edge names that were removed in this mutation.
  48675. func (m *XunjiMutation) RemovedEdges() []string {
  48676. edges := make([]string, 0, 0)
  48677. return edges
  48678. }
  48679. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48680. // the given name in this mutation.
  48681. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  48682. return nil
  48683. }
  48684. // ClearedEdges returns all edge names that were cleared in this mutation.
  48685. func (m *XunjiMutation) ClearedEdges() []string {
  48686. edges := make([]string, 0, 0)
  48687. return edges
  48688. }
  48689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48690. // was cleared in this mutation.
  48691. func (m *XunjiMutation) EdgeCleared(name string) bool {
  48692. return false
  48693. }
  48694. // ClearEdge clears the value of the edge with the given name. It returns an error
  48695. // if that edge is not defined in the schema.
  48696. func (m *XunjiMutation) ClearEdge(name string) error {
  48697. return fmt.Errorf("unknown Xunji unique edge %s", name)
  48698. }
  48699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48700. // It returns an error if the edge is not defined in the schema.
  48701. func (m *XunjiMutation) ResetEdge(name string) error {
  48702. return fmt.Errorf("unknown Xunji edge %s", name)
  48703. }
  48704. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  48705. type XunjiServiceMutation struct {
  48706. config
  48707. op Op
  48708. typ string
  48709. id *uint64
  48710. created_at *time.Time
  48711. updated_at *time.Time
  48712. status *uint8
  48713. addstatus *int8
  48714. deleted_at *time.Time
  48715. xunji_id *uint64
  48716. addxunji_id *int64
  48717. organization_id *uint64
  48718. addorganization_id *int64
  48719. wxid *string
  48720. api_base *string
  48721. api_key *string
  48722. clearedFields map[string]struct{}
  48723. agent *uint64
  48724. clearedagent bool
  48725. done bool
  48726. oldValue func(context.Context) (*XunjiService, error)
  48727. predicates []predicate.XunjiService
  48728. }
  48729. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  48730. // xunjiserviceOption allows management of the mutation configuration using functional options.
  48731. type xunjiserviceOption func(*XunjiServiceMutation)
  48732. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  48733. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  48734. m := &XunjiServiceMutation{
  48735. config: c,
  48736. op: op,
  48737. typ: TypeXunjiService,
  48738. clearedFields: make(map[string]struct{}),
  48739. }
  48740. for _, opt := range opts {
  48741. opt(m)
  48742. }
  48743. return m
  48744. }
  48745. // withXunjiServiceID sets the ID field of the mutation.
  48746. func withXunjiServiceID(id uint64) xunjiserviceOption {
  48747. return func(m *XunjiServiceMutation) {
  48748. var (
  48749. err error
  48750. once sync.Once
  48751. value *XunjiService
  48752. )
  48753. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  48754. once.Do(func() {
  48755. if m.done {
  48756. err = errors.New("querying old values post mutation is not allowed")
  48757. } else {
  48758. value, err = m.Client().XunjiService.Get(ctx, id)
  48759. }
  48760. })
  48761. return value, err
  48762. }
  48763. m.id = &id
  48764. }
  48765. }
  48766. // withXunjiService sets the old XunjiService of the mutation.
  48767. func withXunjiService(node *XunjiService) xunjiserviceOption {
  48768. return func(m *XunjiServiceMutation) {
  48769. m.oldValue = func(context.Context) (*XunjiService, error) {
  48770. return node, nil
  48771. }
  48772. m.id = &node.ID
  48773. }
  48774. }
  48775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48776. // executed in a transaction (ent.Tx), a transactional client is returned.
  48777. func (m XunjiServiceMutation) Client() *Client {
  48778. client := &Client{config: m.config}
  48779. client.init()
  48780. return client
  48781. }
  48782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48783. // it returns an error otherwise.
  48784. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  48785. if _, ok := m.driver.(*txDriver); !ok {
  48786. return nil, errors.New("ent: mutation is not running in a transaction")
  48787. }
  48788. tx := &Tx{config: m.config}
  48789. tx.init()
  48790. return tx, nil
  48791. }
  48792. // SetID sets the value of the id field. Note that this
  48793. // operation is only accepted on creation of XunjiService entities.
  48794. func (m *XunjiServiceMutation) SetID(id uint64) {
  48795. m.id = &id
  48796. }
  48797. // ID returns the ID value in the mutation. Note that the ID is only available
  48798. // if it was provided to the builder or after it was returned from the database.
  48799. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  48800. if m.id == nil {
  48801. return
  48802. }
  48803. return *m.id, true
  48804. }
  48805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48806. // That means, if the mutation is applied within a transaction with an isolation level such
  48807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48808. // or updated by the mutation.
  48809. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  48810. switch {
  48811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48812. id, exists := m.ID()
  48813. if exists {
  48814. return []uint64{id}, nil
  48815. }
  48816. fallthrough
  48817. case m.op.Is(OpUpdate | OpDelete):
  48818. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  48819. default:
  48820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48821. }
  48822. }
  48823. // SetCreatedAt sets the "created_at" field.
  48824. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  48825. m.created_at = &t
  48826. }
  48827. // CreatedAt returns the value of the "created_at" field in the mutation.
  48828. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  48829. v := m.created_at
  48830. if v == nil {
  48831. return
  48832. }
  48833. return *v, true
  48834. }
  48835. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  48836. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48838. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48839. if !m.op.Is(OpUpdateOne) {
  48840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48841. }
  48842. if m.id == nil || m.oldValue == nil {
  48843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48844. }
  48845. oldValue, err := m.oldValue(ctx)
  48846. if err != nil {
  48847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48848. }
  48849. return oldValue.CreatedAt, nil
  48850. }
  48851. // ResetCreatedAt resets all changes to the "created_at" field.
  48852. func (m *XunjiServiceMutation) ResetCreatedAt() {
  48853. m.created_at = nil
  48854. }
  48855. // SetUpdatedAt sets the "updated_at" field.
  48856. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  48857. m.updated_at = &t
  48858. }
  48859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48860. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  48861. v := m.updated_at
  48862. if v == nil {
  48863. return
  48864. }
  48865. return *v, true
  48866. }
  48867. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  48868. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48870. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48871. if !m.op.Is(OpUpdateOne) {
  48872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48873. }
  48874. if m.id == nil || m.oldValue == nil {
  48875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48876. }
  48877. oldValue, err := m.oldValue(ctx)
  48878. if err != nil {
  48879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48880. }
  48881. return oldValue.UpdatedAt, nil
  48882. }
  48883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48884. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  48885. m.updated_at = nil
  48886. }
  48887. // SetStatus sets the "status" field.
  48888. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  48889. m.status = &u
  48890. m.addstatus = nil
  48891. }
  48892. // Status returns the value of the "status" field in the mutation.
  48893. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  48894. v := m.status
  48895. if v == nil {
  48896. return
  48897. }
  48898. return *v, true
  48899. }
  48900. // OldStatus returns the old "status" field's value of the XunjiService entity.
  48901. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48903. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  48904. if !m.op.Is(OpUpdateOne) {
  48905. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  48906. }
  48907. if m.id == nil || m.oldValue == nil {
  48908. return v, errors.New("OldStatus requires an ID field in the mutation")
  48909. }
  48910. oldValue, err := m.oldValue(ctx)
  48911. if err != nil {
  48912. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  48913. }
  48914. return oldValue.Status, nil
  48915. }
  48916. // AddStatus adds u to the "status" field.
  48917. func (m *XunjiServiceMutation) AddStatus(u int8) {
  48918. if m.addstatus != nil {
  48919. *m.addstatus += u
  48920. } else {
  48921. m.addstatus = &u
  48922. }
  48923. }
  48924. // AddedStatus returns the value that was added to the "status" field in this mutation.
  48925. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  48926. v := m.addstatus
  48927. if v == nil {
  48928. return
  48929. }
  48930. return *v, true
  48931. }
  48932. // ClearStatus clears the value of the "status" field.
  48933. func (m *XunjiServiceMutation) ClearStatus() {
  48934. m.status = nil
  48935. m.addstatus = nil
  48936. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  48937. }
  48938. // StatusCleared returns if the "status" field was cleared in this mutation.
  48939. func (m *XunjiServiceMutation) StatusCleared() bool {
  48940. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  48941. return ok
  48942. }
  48943. // ResetStatus resets all changes to the "status" field.
  48944. func (m *XunjiServiceMutation) ResetStatus() {
  48945. m.status = nil
  48946. m.addstatus = nil
  48947. delete(m.clearedFields, xunjiservice.FieldStatus)
  48948. }
  48949. // SetDeletedAt sets the "deleted_at" field.
  48950. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  48951. m.deleted_at = &t
  48952. }
  48953. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48954. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  48955. v := m.deleted_at
  48956. if v == nil {
  48957. return
  48958. }
  48959. return *v, true
  48960. }
  48961. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  48962. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  48963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48964. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48965. if !m.op.Is(OpUpdateOne) {
  48966. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48967. }
  48968. if m.id == nil || m.oldValue == nil {
  48969. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48970. }
  48971. oldValue, err := m.oldValue(ctx)
  48972. if err != nil {
  48973. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48974. }
  48975. return oldValue.DeletedAt, nil
  48976. }
  48977. // ClearDeletedAt clears the value of the "deleted_at" field.
  48978. func (m *XunjiServiceMutation) ClearDeletedAt() {
  48979. m.deleted_at = nil
  48980. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  48981. }
  48982. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48983. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  48984. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  48985. return ok
  48986. }
  48987. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48988. func (m *XunjiServiceMutation) ResetDeletedAt() {
  48989. m.deleted_at = nil
  48990. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  48991. }
  48992. // SetXunjiID sets the "xunji_id" field.
  48993. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  48994. m.xunji_id = &u
  48995. m.addxunji_id = nil
  48996. }
  48997. // XunjiID returns the value of the "xunji_id" field in the mutation.
  48998. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  48999. v := m.xunji_id
  49000. if v == nil {
  49001. return
  49002. }
  49003. return *v, true
  49004. }
  49005. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  49006. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49008. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  49009. if !m.op.Is(OpUpdateOne) {
  49010. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  49011. }
  49012. if m.id == nil || m.oldValue == nil {
  49013. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  49014. }
  49015. oldValue, err := m.oldValue(ctx)
  49016. if err != nil {
  49017. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  49018. }
  49019. return oldValue.XunjiID, nil
  49020. }
  49021. // AddXunjiID adds u to the "xunji_id" field.
  49022. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  49023. if m.addxunji_id != nil {
  49024. *m.addxunji_id += u
  49025. } else {
  49026. m.addxunji_id = &u
  49027. }
  49028. }
  49029. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  49030. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  49031. v := m.addxunji_id
  49032. if v == nil {
  49033. return
  49034. }
  49035. return *v, true
  49036. }
  49037. // ResetXunjiID resets all changes to the "xunji_id" field.
  49038. func (m *XunjiServiceMutation) ResetXunjiID() {
  49039. m.xunji_id = nil
  49040. m.addxunji_id = nil
  49041. }
  49042. // SetAgentID sets the "agent_id" field.
  49043. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  49044. m.agent = &u
  49045. }
  49046. // AgentID returns the value of the "agent_id" field in the mutation.
  49047. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  49048. v := m.agent
  49049. if v == nil {
  49050. return
  49051. }
  49052. return *v, true
  49053. }
  49054. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  49055. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49057. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  49058. if !m.op.Is(OpUpdateOne) {
  49059. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  49060. }
  49061. if m.id == nil || m.oldValue == nil {
  49062. return v, errors.New("OldAgentID requires an ID field in the mutation")
  49063. }
  49064. oldValue, err := m.oldValue(ctx)
  49065. if err != nil {
  49066. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  49067. }
  49068. return oldValue.AgentID, nil
  49069. }
  49070. // ResetAgentID resets all changes to the "agent_id" field.
  49071. func (m *XunjiServiceMutation) ResetAgentID() {
  49072. m.agent = nil
  49073. }
  49074. // SetOrganizationID sets the "organization_id" field.
  49075. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  49076. m.organization_id = &u
  49077. m.addorganization_id = nil
  49078. }
  49079. // OrganizationID returns the value of the "organization_id" field in the mutation.
  49080. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  49081. v := m.organization_id
  49082. if v == nil {
  49083. return
  49084. }
  49085. return *v, true
  49086. }
  49087. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  49088. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49090. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  49091. if !m.op.Is(OpUpdateOne) {
  49092. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  49093. }
  49094. if m.id == nil || m.oldValue == nil {
  49095. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  49096. }
  49097. oldValue, err := m.oldValue(ctx)
  49098. if err != nil {
  49099. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  49100. }
  49101. return oldValue.OrganizationID, nil
  49102. }
  49103. // AddOrganizationID adds u to the "organization_id" field.
  49104. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  49105. if m.addorganization_id != nil {
  49106. *m.addorganization_id += u
  49107. } else {
  49108. m.addorganization_id = &u
  49109. }
  49110. }
  49111. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  49112. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  49113. v := m.addorganization_id
  49114. if v == nil {
  49115. return
  49116. }
  49117. return *v, true
  49118. }
  49119. // ResetOrganizationID resets all changes to the "organization_id" field.
  49120. func (m *XunjiServiceMutation) ResetOrganizationID() {
  49121. m.organization_id = nil
  49122. m.addorganization_id = nil
  49123. }
  49124. // SetWxid sets the "wxid" field.
  49125. func (m *XunjiServiceMutation) SetWxid(s string) {
  49126. m.wxid = &s
  49127. }
  49128. // Wxid returns the value of the "wxid" field in the mutation.
  49129. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  49130. v := m.wxid
  49131. if v == nil {
  49132. return
  49133. }
  49134. return *v, true
  49135. }
  49136. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  49137. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49139. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  49140. if !m.op.Is(OpUpdateOne) {
  49141. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  49142. }
  49143. if m.id == nil || m.oldValue == nil {
  49144. return v, errors.New("OldWxid requires an ID field in the mutation")
  49145. }
  49146. oldValue, err := m.oldValue(ctx)
  49147. if err != nil {
  49148. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  49149. }
  49150. return oldValue.Wxid, nil
  49151. }
  49152. // ResetWxid resets all changes to the "wxid" field.
  49153. func (m *XunjiServiceMutation) ResetWxid() {
  49154. m.wxid = nil
  49155. }
  49156. // SetAPIBase sets the "api_base" field.
  49157. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  49158. m.api_base = &s
  49159. }
  49160. // APIBase returns the value of the "api_base" field in the mutation.
  49161. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  49162. v := m.api_base
  49163. if v == nil {
  49164. return
  49165. }
  49166. return *v, true
  49167. }
  49168. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  49169. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49171. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49172. if !m.op.Is(OpUpdateOne) {
  49173. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49174. }
  49175. if m.id == nil || m.oldValue == nil {
  49176. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49177. }
  49178. oldValue, err := m.oldValue(ctx)
  49179. if err != nil {
  49180. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49181. }
  49182. return oldValue.APIBase, nil
  49183. }
  49184. // ClearAPIBase clears the value of the "api_base" field.
  49185. func (m *XunjiServiceMutation) ClearAPIBase() {
  49186. m.api_base = nil
  49187. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  49188. }
  49189. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49190. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  49191. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  49192. return ok
  49193. }
  49194. // ResetAPIBase resets all changes to the "api_base" field.
  49195. func (m *XunjiServiceMutation) ResetAPIBase() {
  49196. m.api_base = nil
  49197. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  49198. }
  49199. // SetAPIKey sets the "api_key" field.
  49200. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  49201. m.api_key = &s
  49202. }
  49203. // APIKey returns the value of the "api_key" field in the mutation.
  49204. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  49205. v := m.api_key
  49206. if v == nil {
  49207. return
  49208. }
  49209. return *v, true
  49210. }
  49211. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  49212. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  49213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49214. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49215. if !m.op.Is(OpUpdateOne) {
  49216. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49217. }
  49218. if m.id == nil || m.oldValue == nil {
  49219. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49220. }
  49221. oldValue, err := m.oldValue(ctx)
  49222. if err != nil {
  49223. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49224. }
  49225. return oldValue.APIKey, nil
  49226. }
  49227. // ClearAPIKey clears the value of the "api_key" field.
  49228. func (m *XunjiServiceMutation) ClearAPIKey() {
  49229. m.api_key = nil
  49230. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  49231. }
  49232. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49233. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  49234. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  49235. return ok
  49236. }
  49237. // ResetAPIKey resets all changes to the "api_key" field.
  49238. func (m *XunjiServiceMutation) ResetAPIKey() {
  49239. m.api_key = nil
  49240. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  49241. }
  49242. // ClearAgent clears the "agent" edge to the Agent entity.
  49243. func (m *XunjiServiceMutation) ClearAgent() {
  49244. m.clearedagent = true
  49245. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  49246. }
  49247. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  49248. func (m *XunjiServiceMutation) AgentCleared() bool {
  49249. return m.clearedagent
  49250. }
  49251. // AgentIDs returns the "agent" edge IDs in the mutation.
  49252. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  49253. // AgentID instead. It exists only for internal usage by the builders.
  49254. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  49255. if id := m.agent; id != nil {
  49256. ids = append(ids, *id)
  49257. }
  49258. return
  49259. }
  49260. // ResetAgent resets all changes to the "agent" edge.
  49261. func (m *XunjiServiceMutation) ResetAgent() {
  49262. m.agent = nil
  49263. m.clearedagent = false
  49264. }
  49265. // Where appends a list predicates to the XunjiServiceMutation builder.
  49266. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  49267. m.predicates = append(m.predicates, ps...)
  49268. }
  49269. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  49270. // users can use type-assertion to append predicates that do not depend on any generated package.
  49271. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  49272. p := make([]predicate.XunjiService, len(ps))
  49273. for i := range ps {
  49274. p[i] = ps[i]
  49275. }
  49276. m.Where(p...)
  49277. }
  49278. // Op returns the operation name.
  49279. func (m *XunjiServiceMutation) Op() Op {
  49280. return m.op
  49281. }
  49282. // SetOp allows setting the mutation operation.
  49283. func (m *XunjiServiceMutation) SetOp(op Op) {
  49284. m.op = op
  49285. }
  49286. // Type returns the node type of this mutation (XunjiService).
  49287. func (m *XunjiServiceMutation) Type() string {
  49288. return m.typ
  49289. }
  49290. // Fields returns all fields that were changed during this mutation. Note that in
  49291. // order to get all numeric fields that were incremented/decremented, call
  49292. // AddedFields().
  49293. func (m *XunjiServiceMutation) Fields() []string {
  49294. fields := make([]string, 0, 10)
  49295. if m.created_at != nil {
  49296. fields = append(fields, xunjiservice.FieldCreatedAt)
  49297. }
  49298. if m.updated_at != nil {
  49299. fields = append(fields, xunjiservice.FieldUpdatedAt)
  49300. }
  49301. if m.status != nil {
  49302. fields = append(fields, xunjiservice.FieldStatus)
  49303. }
  49304. if m.deleted_at != nil {
  49305. fields = append(fields, xunjiservice.FieldDeletedAt)
  49306. }
  49307. if m.xunji_id != nil {
  49308. fields = append(fields, xunjiservice.FieldXunjiID)
  49309. }
  49310. if m.agent != nil {
  49311. fields = append(fields, xunjiservice.FieldAgentID)
  49312. }
  49313. if m.organization_id != nil {
  49314. fields = append(fields, xunjiservice.FieldOrganizationID)
  49315. }
  49316. if m.wxid != nil {
  49317. fields = append(fields, xunjiservice.FieldWxid)
  49318. }
  49319. if m.api_base != nil {
  49320. fields = append(fields, xunjiservice.FieldAPIBase)
  49321. }
  49322. if m.api_key != nil {
  49323. fields = append(fields, xunjiservice.FieldAPIKey)
  49324. }
  49325. return fields
  49326. }
  49327. // Field returns the value of a field with the given name. The second boolean
  49328. // return value indicates that this field was not set, or was not defined in the
  49329. // schema.
  49330. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  49331. switch name {
  49332. case xunjiservice.FieldCreatedAt:
  49333. return m.CreatedAt()
  49334. case xunjiservice.FieldUpdatedAt:
  49335. return m.UpdatedAt()
  49336. case xunjiservice.FieldStatus:
  49337. return m.Status()
  49338. case xunjiservice.FieldDeletedAt:
  49339. return m.DeletedAt()
  49340. case xunjiservice.FieldXunjiID:
  49341. return m.XunjiID()
  49342. case xunjiservice.FieldAgentID:
  49343. return m.AgentID()
  49344. case xunjiservice.FieldOrganizationID:
  49345. return m.OrganizationID()
  49346. case xunjiservice.FieldWxid:
  49347. return m.Wxid()
  49348. case xunjiservice.FieldAPIBase:
  49349. return m.APIBase()
  49350. case xunjiservice.FieldAPIKey:
  49351. return m.APIKey()
  49352. }
  49353. return nil, false
  49354. }
  49355. // OldField returns the old value of the field from the database. An error is
  49356. // returned if the mutation operation is not UpdateOne, or the query to the
  49357. // database failed.
  49358. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49359. switch name {
  49360. case xunjiservice.FieldCreatedAt:
  49361. return m.OldCreatedAt(ctx)
  49362. case xunjiservice.FieldUpdatedAt:
  49363. return m.OldUpdatedAt(ctx)
  49364. case xunjiservice.FieldStatus:
  49365. return m.OldStatus(ctx)
  49366. case xunjiservice.FieldDeletedAt:
  49367. return m.OldDeletedAt(ctx)
  49368. case xunjiservice.FieldXunjiID:
  49369. return m.OldXunjiID(ctx)
  49370. case xunjiservice.FieldAgentID:
  49371. return m.OldAgentID(ctx)
  49372. case xunjiservice.FieldOrganizationID:
  49373. return m.OldOrganizationID(ctx)
  49374. case xunjiservice.FieldWxid:
  49375. return m.OldWxid(ctx)
  49376. case xunjiservice.FieldAPIBase:
  49377. return m.OldAPIBase(ctx)
  49378. case xunjiservice.FieldAPIKey:
  49379. return m.OldAPIKey(ctx)
  49380. }
  49381. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  49382. }
  49383. // SetField sets the value of a field with the given name. It returns an error if
  49384. // the field is not defined in the schema, or if the type mismatched the field
  49385. // type.
  49386. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  49387. switch name {
  49388. case xunjiservice.FieldCreatedAt:
  49389. v, ok := value.(time.Time)
  49390. if !ok {
  49391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49392. }
  49393. m.SetCreatedAt(v)
  49394. return nil
  49395. case xunjiservice.FieldUpdatedAt:
  49396. v, ok := value.(time.Time)
  49397. if !ok {
  49398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49399. }
  49400. m.SetUpdatedAt(v)
  49401. return nil
  49402. case xunjiservice.FieldStatus:
  49403. v, ok := value.(uint8)
  49404. if !ok {
  49405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49406. }
  49407. m.SetStatus(v)
  49408. return nil
  49409. case xunjiservice.FieldDeletedAt:
  49410. v, ok := value.(time.Time)
  49411. if !ok {
  49412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49413. }
  49414. m.SetDeletedAt(v)
  49415. return nil
  49416. case xunjiservice.FieldXunjiID:
  49417. v, ok := value.(uint64)
  49418. if !ok {
  49419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49420. }
  49421. m.SetXunjiID(v)
  49422. return nil
  49423. case xunjiservice.FieldAgentID:
  49424. v, ok := value.(uint64)
  49425. if !ok {
  49426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49427. }
  49428. m.SetAgentID(v)
  49429. return nil
  49430. case xunjiservice.FieldOrganizationID:
  49431. v, ok := value.(uint64)
  49432. if !ok {
  49433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49434. }
  49435. m.SetOrganizationID(v)
  49436. return nil
  49437. case xunjiservice.FieldWxid:
  49438. v, ok := value.(string)
  49439. if !ok {
  49440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49441. }
  49442. m.SetWxid(v)
  49443. return nil
  49444. case xunjiservice.FieldAPIBase:
  49445. v, ok := value.(string)
  49446. if !ok {
  49447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49448. }
  49449. m.SetAPIBase(v)
  49450. return nil
  49451. case xunjiservice.FieldAPIKey:
  49452. v, ok := value.(string)
  49453. if !ok {
  49454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49455. }
  49456. m.SetAPIKey(v)
  49457. return nil
  49458. }
  49459. return fmt.Errorf("unknown XunjiService field %s", name)
  49460. }
  49461. // AddedFields returns all numeric fields that were incremented/decremented during
  49462. // this mutation.
  49463. func (m *XunjiServiceMutation) AddedFields() []string {
  49464. var fields []string
  49465. if m.addstatus != nil {
  49466. fields = append(fields, xunjiservice.FieldStatus)
  49467. }
  49468. if m.addxunji_id != nil {
  49469. fields = append(fields, xunjiservice.FieldXunjiID)
  49470. }
  49471. if m.addorganization_id != nil {
  49472. fields = append(fields, xunjiservice.FieldOrganizationID)
  49473. }
  49474. return fields
  49475. }
  49476. // AddedField returns the numeric value that was incremented/decremented on a field
  49477. // with the given name. The second boolean return value indicates that this field
  49478. // was not set, or was not defined in the schema.
  49479. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  49480. switch name {
  49481. case xunjiservice.FieldStatus:
  49482. return m.AddedStatus()
  49483. case xunjiservice.FieldXunjiID:
  49484. return m.AddedXunjiID()
  49485. case xunjiservice.FieldOrganizationID:
  49486. return m.AddedOrganizationID()
  49487. }
  49488. return nil, false
  49489. }
  49490. // AddField adds the value to the field with the given name. It returns an error if
  49491. // the field is not defined in the schema, or if the type mismatched the field
  49492. // type.
  49493. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  49494. switch name {
  49495. case xunjiservice.FieldStatus:
  49496. v, ok := value.(int8)
  49497. if !ok {
  49498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49499. }
  49500. m.AddStatus(v)
  49501. return nil
  49502. case xunjiservice.FieldXunjiID:
  49503. v, ok := value.(int64)
  49504. if !ok {
  49505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49506. }
  49507. m.AddXunjiID(v)
  49508. return nil
  49509. case xunjiservice.FieldOrganizationID:
  49510. v, ok := value.(int64)
  49511. if !ok {
  49512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49513. }
  49514. m.AddOrganizationID(v)
  49515. return nil
  49516. }
  49517. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  49518. }
  49519. // ClearedFields returns all nullable fields that were cleared during this
  49520. // mutation.
  49521. func (m *XunjiServiceMutation) ClearedFields() []string {
  49522. var fields []string
  49523. if m.FieldCleared(xunjiservice.FieldStatus) {
  49524. fields = append(fields, xunjiservice.FieldStatus)
  49525. }
  49526. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  49527. fields = append(fields, xunjiservice.FieldDeletedAt)
  49528. }
  49529. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  49530. fields = append(fields, xunjiservice.FieldAPIBase)
  49531. }
  49532. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  49533. fields = append(fields, xunjiservice.FieldAPIKey)
  49534. }
  49535. return fields
  49536. }
  49537. // FieldCleared returns a boolean indicating if a field with the given name was
  49538. // cleared in this mutation.
  49539. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  49540. _, ok := m.clearedFields[name]
  49541. return ok
  49542. }
  49543. // ClearField clears the value of the field with the given name. It returns an
  49544. // error if the field is not defined in the schema.
  49545. func (m *XunjiServiceMutation) ClearField(name string) error {
  49546. switch name {
  49547. case xunjiservice.FieldStatus:
  49548. m.ClearStatus()
  49549. return nil
  49550. case xunjiservice.FieldDeletedAt:
  49551. m.ClearDeletedAt()
  49552. return nil
  49553. case xunjiservice.FieldAPIBase:
  49554. m.ClearAPIBase()
  49555. return nil
  49556. case xunjiservice.FieldAPIKey:
  49557. m.ClearAPIKey()
  49558. return nil
  49559. }
  49560. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  49561. }
  49562. // ResetField resets all changes in the mutation for the field with the given name.
  49563. // It returns an error if the field is not defined in the schema.
  49564. func (m *XunjiServiceMutation) ResetField(name string) error {
  49565. switch name {
  49566. case xunjiservice.FieldCreatedAt:
  49567. m.ResetCreatedAt()
  49568. return nil
  49569. case xunjiservice.FieldUpdatedAt:
  49570. m.ResetUpdatedAt()
  49571. return nil
  49572. case xunjiservice.FieldStatus:
  49573. m.ResetStatus()
  49574. return nil
  49575. case xunjiservice.FieldDeletedAt:
  49576. m.ResetDeletedAt()
  49577. return nil
  49578. case xunjiservice.FieldXunjiID:
  49579. m.ResetXunjiID()
  49580. return nil
  49581. case xunjiservice.FieldAgentID:
  49582. m.ResetAgentID()
  49583. return nil
  49584. case xunjiservice.FieldOrganizationID:
  49585. m.ResetOrganizationID()
  49586. return nil
  49587. case xunjiservice.FieldWxid:
  49588. m.ResetWxid()
  49589. return nil
  49590. case xunjiservice.FieldAPIBase:
  49591. m.ResetAPIBase()
  49592. return nil
  49593. case xunjiservice.FieldAPIKey:
  49594. m.ResetAPIKey()
  49595. return nil
  49596. }
  49597. return fmt.Errorf("unknown XunjiService field %s", name)
  49598. }
  49599. // AddedEdges returns all edge names that were set/added in this mutation.
  49600. func (m *XunjiServiceMutation) AddedEdges() []string {
  49601. edges := make([]string, 0, 1)
  49602. if m.agent != nil {
  49603. edges = append(edges, xunjiservice.EdgeAgent)
  49604. }
  49605. return edges
  49606. }
  49607. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49608. // name in this mutation.
  49609. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  49610. switch name {
  49611. case xunjiservice.EdgeAgent:
  49612. if id := m.agent; id != nil {
  49613. return []ent.Value{*id}
  49614. }
  49615. }
  49616. return nil
  49617. }
  49618. // RemovedEdges returns all edge names that were removed in this mutation.
  49619. func (m *XunjiServiceMutation) RemovedEdges() []string {
  49620. edges := make([]string, 0, 1)
  49621. return edges
  49622. }
  49623. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49624. // the given name in this mutation.
  49625. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  49626. return nil
  49627. }
  49628. // ClearedEdges returns all edge names that were cleared in this mutation.
  49629. func (m *XunjiServiceMutation) ClearedEdges() []string {
  49630. edges := make([]string, 0, 1)
  49631. if m.clearedagent {
  49632. edges = append(edges, xunjiservice.EdgeAgent)
  49633. }
  49634. return edges
  49635. }
  49636. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49637. // was cleared in this mutation.
  49638. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  49639. switch name {
  49640. case xunjiservice.EdgeAgent:
  49641. return m.clearedagent
  49642. }
  49643. return false
  49644. }
  49645. // ClearEdge clears the value of the edge with the given name. It returns an error
  49646. // if that edge is not defined in the schema.
  49647. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  49648. switch name {
  49649. case xunjiservice.EdgeAgent:
  49650. m.ClearAgent()
  49651. return nil
  49652. }
  49653. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  49654. }
  49655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49656. // It returns an error if the edge is not defined in the schema.
  49657. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  49658. switch name {
  49659. case xunjiservice.EdgeAgent:
  49660. m.ResetAgent()
  49661. return nil
  49662. }
  49663. return fmt.Errorf("unknown XunjiService edge %s", name)
  49664. }